mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
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.
This commit is contained in:
parent
1d176b856e
commit
8c2ed6b575
3 changed files with 37 additions and 6 deletions
|
@ -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'."
|
`process-file', `start-file-process', or `shell-command'."
|
||||||
(or (file-remote-p file 'localname) file)))
|
(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
|
;; Variables
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -970,8 +970,7 @@ icons."
|
||||||
mode-line-inactive)
|
mode-line-inactive)
|
||||||
'mode-line-inactive)))
|
'mode-line-inactive)))
|
||||||
(when (and doom-modeline-icon icon text) doom-modeline-inactive-vspc)
|
(when (and doom-modeline-icon icon text) doom-modeline-inactive-vspc)
|
||||||
(when text (propertize text 'face 'mode-line-inactive))))
|
(when text (propertize text 'face 'mode-line-inactive))))))
|
||||||
(propertize " " 'face (if active 'mode-line 'mode-line-inactive))))
|
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
(doom-modeline-def-modeline 'minimal
|
(doom-modeline-def-modeline 'minimal
|
||||||
'(bar matches " " buffer-info)
|
'(bar matches " " buffer-info)
|
||||||
'(media-info major-mode " "))
|
'(media-info major-mode))
|
||||||
|
|
||||||
(doom-modeline-def-modeline 'special
|
(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)
|
'(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
|
(doom-modeline-def-modeline 'project
|
||||||
'(bar window-number " " buffer-default-directory)
|
'(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
|
(doom-modeline-def-modeline 'media
|
||||||
'(bar window-number buffer-size buffer-info)
|
'(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
|
(doom-modeline-def-modeline 'pdf
|
||||||
'(bar window-number buffer-size buffer-info pdf-pages)
|
'(bar window-number buffer-size buffer-info pdf-pages)
|
||||||
'(misc-info " " major-mode process vcs " "))
|
'(misc-info " " major-mode process vcs))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue