From e0acf3863d535730806303ac9fa92b2c0764fc79 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sun, 30 Sep 2018 18:06:32 +0800 Subject: [PATCH] Refactor segment and modeline definitions. --- doom-modeline.el | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 701df73..7ca9002 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -244,7 +244,7 @@ active.") `(let (byte-compile-warnings) (byte-compile #',sym)))))))) -(defsubst doom-modeline--prepare-segments (segments) +(defun doom-modeline--prepare-segments (segments) "Prepare mode-line `SEGMENTS'." (let (forms it) (dolist (seg segments) @@ -252,7 +252,7 @@ active.") (push seg forms)) ((symbolp seg) (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))) (push it forms)) ((error "%s is not a defined segment" seg)))) @@ -276,19 +276,20 @@ active.") (rhs-forms (doom-modeline--prepare-segments rhs))) (defalias sym (lambda () - (let ((lhs (eval `(list ,@lhs-forms) t)) - (rhs (eval `(list ,@rhs-forms) t))) - (let ((rhs-str (format-mode-line rhs))) - (list lhs - (propertize - " " 'display - `((space :align-to (- (+ right right-fringe right-margin) - ,(+ 1 (string-width rhs-str)))))) - rhs-str)))) + (let ((rhs-str (format-mode-line rhs-forms))) + (list lhs-forms + (propertize + " " 'display + `((space :align-to (- (+ right right-fringe right-margin) + ,(+ 1 (string-width rhs-str)))))) + rhs-str))) (concat "Modeline:\n" (format " %s\n %s" (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) "Return a mode-line configuration associated with KEY (a symbol).