From 266cedffa90333c09a7e97ee429fac874fc6c14e Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sun, 30 Sep 2018 15:16:24 +0800 Subject: [PATCH 1/4] Improve major-mode segment: add menus for major/minor modes. --- doom-modeline.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doom-modeline.el b/doom-modeline.el index 3b97cf7..bbc7a8d 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -635,7 +635,14 @@ directory, the file name, and its state (modified, read-only or non-existent)." (doom-modeline-def-segment major-mode "The major mode, including environment and text-scale info." (propertize - (concat (format-mode-line mode-name) + (concat (format-mode-line + `(:propertize ("" mode-name) + help-echo "Major mode\n\ +mouse-1: Display major mode menu\n\ +mouse-2: Show help for major mode\n\ +mouse-3: Toggle minor modes" + mouse-face mode-line-highlight + local-map ,mode-line-major-mode-keymap)) (when doom-modeline-env-version (format " %s" doom-modeline-env-version)) (and (boundp 'text-scale-mode-amount) From 677dc9ab2c31296f9c7dfb31d9519f1d58bc4ece Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sun, 30 Sep 2018 16:45:04 +0800 Subject: [PATCH 2/4] Update workspace face. --- doom-modeline.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doom-modeline.el b/doom-modeline.el index bbc7a8d..ec17457 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -990,7 +990,7 @@ enabled." tag (when num (int-to-string num))))) (propertize (format " %s " str) 'face - (if (doom-modeline--active) 'doom-modeline-highlight))) + (if (doom-modeline--active) 'doom-modeline-buffer-major-mode))) "")) From b70235290d568c77a08a1838458b337270032b42 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sun, 30 Sep 2018 17:02:27 +0800 Subject: [PATCH 3/4] Fix: inactive bar face. DO NOT use :inverse-video in this face since face-background gets invalid color from :reverse-video faces. --- doom-modeline.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doom-modeline.el b/doom-modeline.el index ec17457..701df73 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -189,7 +189,10 @@ Given ~/Projects/FOSS/emacs/lisp/comint.el "The face used for the left-most bar on the mode-line when eldoc-eval is active.") -(defface doom-modeline-inactive-bar '((t (:inherit warning :inverse-video t))) +(defface doom-modeline-inactive-bar `((t (:background + ,(face-foreground 'mode-line-inactive) + :foreground + ,(face-background 'mode-line-inactive)))) "The face used for the left-most bar on the mode-line of an inactive window.") (defface doom-modeline-evil-emacs-state '((t (:inherit doom-modeline-warning))) From e0acf3863d535730806303ac9fa92b2c0764fc79 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sun, 30 Sep 2018 18:06:32 +0800 Subject: [PATCH 4/4] 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).