diff --git a/doom-modeline-core.el b/doom-modeline-core.el index 95261ff..2ea7481 100644 --- a/doom-modeline-core.el +++ b/doom-modeline-core.el @@ -56,6 +56,38 @@ It returns a file name which can be used directly as argument of `process-file', `start-file-process', or `shell-command'." (or (file-remote-p file 'localname) file))) +;; Set correct font width for `all-the-icons' for appropriate mode-line width. +;; @see https://emacs.stackexchange.com/questions/14420/how-can-i-fix-incorrect-character-width +(defun doom-modeline--set-char-widths (alist) + "Set correct widths of icons characters in ALIST." + (while (char-table-parent char-width-table) + (setq char-width-table (char-table-parent char-width-table))) + (dolist (pair alist) + (let ((width (car pair)) + (chars (cdr pair)) + (table (make-char-table nil))) + (dolist (char chars) + (set-char-table-range table char width)) + (optimize-char-table table) + (set-char-table-parent table char-width-table) + (setq char-width-table table)))) + +(defun doom-moddeline--set-font-widths (alist) + (let (fonts) + (dolist (pair alist) + (push (string-to-char (cdr pair)) fonts)) + (doom-modeline--set-char-widths + `((2 . ,fonts))))) + +;; TODO: better performance? +(doom-moddeline--set-font-widths all-the-icons-data/alltheicons-alist) +;; (doom-moddeline--set-font-widths all-the-icons-data/file-icon-alist) +(doom-moddeline--set-font-widths all-the-icons-data/fa-icon-alist) +(doom-moddeline--set-font-widths all-the-icons-data/octicons-alist) +;; (doom-moddeline--set-font-widths all-the-icons-data/weather-icons-alist) +(doom-moddeline--set-font-widths all-the-icons-data/material-icons-alist) + + ;; ;; Variables ;; diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index 9e61ae0..fee1154 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -970,8 +970,7 @@ icons." mode-line-inactive) 'mode-line-inactive))) (when (and doom-modeline-icon icon text) doom-modeline-inactive-vspc) - (when text (propertize text 'face 'mode-line-inactive)))) - (propertize " " 'face (if active 'mode-line 'mode-line-inactive)))) + (when text (propertize text 'face 'mode-line-inactive)))))) ""))) diff --git a/doom-modeline.el b/doom-modeline.el index 8bfd04e..d9b8341 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -90,7 +90,7 @@ (doom-modeline-def-modeline 'minimal '(bar matches " " buffer-info) - '(media-info major-mode " ")) + '(media-info major-mode)) (doom-modeline-def-modeline 'special '(bar window-number evil-state god-state ryo-modal xah-fly-keys matches buffer-info-simple buffer-position parrot selection-info) @@ -98,15 +98,15 @@ (doom-modeline-def-modeline 'project '(bar window-number " " buffer-default-directory) - '(misc-info mu4e github debug fancy-battery " " major-mode process " ")) + '(misc-info mu4e github debug fancy-battery " " major-mode process)) (doom-modeline-def-modeline 'media '(bar window-number buffer-size buffer-info) - '(misc-info media-info major-mode process vcs " ")) + '(misc-info media-info major-mode process vcs)) (doom-modeline-def-modeline 'pdf '(bar window-number buffer-size buffer-info pdf-pages) - '(misc-info " " major-mode process vcs " ")) + '(misc-info " " major-mode process vcs)) ;;