mirror of
https://github.com/vale981/doom-modeline
synced 2025-03-05 17:31:37 -05:00
Refactor: rename the variables and funcations for font width.
This commit is contained in:
parent
f87b868bb9
commit
209ec76f56
1 changed files with 9 additions and 9 deletions
|
@ -627,22 +627,22 @@ It requires `circe' or `erc' package."
|
||||||
((error "%s is not a valid segment" seg))))
|
((error "%s is not a valid segment" seg))))
|
||||||
(nreverse forms)))
|
(nreverse forms)))
|
||||||
|
|
||||||
(defvar doom-modeline--width-cache nil)
|
(defvar doom-modeline--font-width nil)
|
||||||
(defun doom-modeline--window-font-width ()
|
(defun doom-modeline--font-width ()
|
||||||
"Cache the font width."
|
"Cache the font width."
|
||||||
(let ((attributes (face-all-attributes 'mode-line)))
|
(let ((attributes (face-all-attributes 'mode-line)))
|
||||||
(or (cdr (assoc attributes doom-modeline--width-cache))
|
(or (cdr (assoc attributes doom-modeline--font-width))
|
||||||
(let ((width (window-font-width nil 'mode-line)))
|
(let ((width (window-font-width nil 'mode-line)))
|
||||||
(push (cons attributes width) doom-modeline--width-cache)
|
(push (cons attributes width) doom-modeline--font-width)
|
||||||
width))))
|
width))))
|
||||||
|
|
||||||
;; Refresh the font width after setting frame parameters
|
;; Refresh the font width after setting frame parameters
|
||||||
;; to ensure the font width is correct.
|
;; to ensure the font width is correct.
|
||||||
(defun doom-modeline--refresh-width-cache ()
|
(defun doom-modeline--refresh-font-width ()
|
||||||
"Refresh the font width cache."
|
"Refresh the font width cache."
|
||||||
(setq doom-modeline--width-cache nil)
|
(setq doom-modeline--font-width nil)
|
||||||
(doom-modeline--window-font-width))
|
(doom-modeline--font-width))
|
||||||
(add-hook 'window-setup-hook #'doom-modeline--refresh-width-cache)
|
(add-hook 'window-setup-hook #'doom-modeline--refresh-font-width)
|
||||||
|
|
||||||
(defun doom-modeline-def-modeline (name lhs &optional rhs)
|
(defun doom-modeline-def-modeline (name lhs &optional rhs)
|
||||||
"Defines a modeline format and byte-compiles it.
|
"Defines a modeline format and byte-compiles it.
|
||||||
|
@ -664,7 +664,7 @@ It requires `circe' or `erc' package."
|
||||||
(propertize
|
(propertize
|
||||||
(doom-modeline-spc)
|
(doom-modeline-spc)
|
||||||
'display `((space :align-to (- (+ right right-fringe right-margin)
|
'display `((space :align-to (- (+ right right-fringe right-margin)
|
||||||
,(* (/ (doom-modeline--window-font-width)
|
,(* (/ (doom-modeline--font-width)
|
||||||
(frame-char-width) 1.0)
|
(frame-char-width) 1.0)
|
||||||
(string-width
|
(string-width
|
||||||
(format-mode-line
|
(format-mode-line
|
||||||
|
|
Loading…
Add table
Reference in a new issue