mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 19:19:53 +00:00
Refactor segment and modeline definitions.
This commit is contained in:
parent
b70235290d
commit
e0acf3863d
1 changed files with 13 additions and 12 deletions
|
@ -244,7 +244,7 @@ active.")
|
||||||
`(let (byte-compile-warnings)
|
`(let (byte-compile-warnings)
|
||||||
(byte-compile #',sym))))))))
|
(byte-compile #',sym))))))))
|
||||||
|
|
||||||
(defsubst doom-modeline--prepare-segments (segments)
|
(defun doom-modeline--prepare-segments (segments)
|
||||||
"Prepare mode-line `SEGMENTS'."
|
"Prepare mode-line `SEGMENTS'."
|
||||||
(let (forms it)
|
(let (forms it)
|
||||||
(dolist (seg segments)
|
(dolist (seg segments)
|
||||||
|
@ -252,7 +252,7 @@ active.")
|
||||||
(push seg forms))
|
(push seg forms))
|
||||||
((symbolp seg)
|
((symbolp seg)
|
||||||
(cond ((setq it (cdr (assq seg doom-modeline-fn-alist)))
|
(cond ((setq it (cdr (assq seg doom-modeline-fn-alist)))
|
||||||
(push (list it) forms))
|
(push (list :eval (list it)) forms))
|
||||||
((setq it (cdr (assq seg doom-modeline-var-alist)))
|
((setq it (cdr (assq seg doom-modeline-var-alist)))
|
||||||
(push it forms))
|
(push it forms))
|
||||||
((error "%s is not a defined segment" seg))))
|
((error "%s is not a defined segment" seg))))
|
||||||
|
@ -276,19 +276,20 @@ active.")
|
||||||
(rhs-forms (doom-modeline--prepare-segments rhs)))
|
(rhs-forms (doom-modeline--prepare-segments rhs)))
|
||||||
(defalias sym
|
(defalias sym
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let ((lhs (eval `(list ,@lhs-forms) t))
|
(let ((rhs-str (format-mode-line rhs-forms)))
|
||||||
(rhs (eval `(list ,@rhs-forms) t)))
|
(list lhs-forms
|
||||||
(let ((rhs-str (format-mode-line rhs)))
|
(propertize
|
||||||
(list lhs
|
" " 'display
|
||||||
(propertize
|
`((space :align-to (- (+ right right-fringe right-margin)
|
||||||
" " 'display
|
,(+ 1 (string-width rhs-str))))))
|
||||||
`((space :align-to (- (+ right right-fringe right-margin)
|
rhs-str)))
|
||||||
,(+ 1 (string-width rhs-str))))))
|
|
||||||
rhs-str))))
|
|
||||||
(concat "Modeline:\n"
|
(concat "Modeline:\n"
|
||||||
(format " %s\n %s"
|
(format " %s\n %s"
|
||||||
(prin1-to-string lhs)
|
(prin1-to-string lhs)
|
||||||
(prin1-to-string rhs))))))
|
(prin1-to-string rhs))))
|
||||||
|
(unless (bound-and-true-p byte-compile-current-file)
|
||||||
|
(let (byte-compile-warnings)
|
||||||
|
(byte-compile sym)))))
|
||||||
|
|
||||||
(defun doom-modeline (key)
|
(defun doom-modeline (key)
|
||||||
"Return a mode-line configuration associated with KEY (a symbol).
|
"Return a mode-line configuration associated with KEY (a symbol).
|
||||||
|
|
Loading…
Reference in a new issue