From 420285ae5f9a818ac361b82ecdc0c6eb93831c6c Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Wed, 5 Dec 2018 03:50:50 +0800 Subject: [PATCH] Refactor segments. Only show global and input in active window. --- doom-modeline.el | 84 ++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 7c205d2..91a6f20 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -825,6 +825,17 @@ directory, the file name, and its state (modified, read-only or non-existent)." " ")) +;; +;; remote host +;; + +(doom-modeline-def-segment remote-host + "Hostname for remote buffers." + (when default-directory + (when-let ((host (file-remote-p default-directory 'host))) + (concat "@" host)))) + + ;; ;; major-mode ;; @@ -860,6 +871,27 @@ mouse-3: Toggle minor modes" "The process info." mode-line-process) + +;; +;; minor modes +;; + +(doom-modeline-def-segment minor-modes + (when doom-modeline-minor-modes + `((:propertize (" " minor-mode-alist " ") + mouse-face mode-line-highlight + help-echo "Minor mode\n\ +mouse-1: Display minor mode menu\n\ +mouse-2: Show help for minor mode\n\ +mouse-3: Toggle minor modes" + local-map ,mode-line-minor-mode-keymap) + (:propertize "%n" + mouse-face mode-line-highlight + help-echo "mouse-2: Remove narrowing from buffer" + local-map ,(make-mode-line-mouse-map + 'mouse-2 #'mode-line-widen))))) + + ;; ;; vcs ;; @@ -1275,32 +1307,14 @@ Requires `eyebrowse-mode' to be enabled." "")) -;; -;; minor modes -;; - -(doom-modeline-def-segment minor-modes - (when doom-modeline-minor-modes - `((:propertize (" " minor-mode-alist " ") - mouse-face mode-line-highlight - help-echo "Minor mode\n\ -mouse-1: Display minor mode menu\n\ -mouse-2: Show help for minor mode\n\ -mouse-3: Toggle minor modes" - local-map ,mode-line-minor-mode-keymap) - (:propertize "%n" - mouse-face mode-line-highlight - help-echo "mouse-2: Remove narrowing from buffer" - local-map ,(make-mode-line-mouse-map - 'mouse-2 #'mode-line-widen))))) - ;; ;; global ;; (doom-modeline-def-segment global "For the time string and whatever uses global-mode-string." - (if (< 0 (length global-mode-string)) + (if (and (doom-modeline--active) + (< 0 (length global-mode-string))) '("" global-mode-string " ") "")) @@ -1381,25 +1395,17 @@ See `mode-line-percent-position'.") (doom-modeline-def-segment input-method "The current input method." - (cond - (current-input-method - (concat " " current-input-method-title " ")) - ((and (bound-and-true-p evil-local-mode) - (bound-and-true-p evil-input-method)) - (concat - (nth 3 (assoc default-input-method input-method-alist)) - " ")))) - - -;; -;; remote host -;; - -(doom-modeline-def-segment remote-host - "Hostname for remote buffers." - (when default-directory - (when-let ((host (file-remote-p default-directory 'host))) - (concat "@" host)))) + (when (doom-modeline--active) + (propertize + (cond + (current-input-method + (concat " " current-input-method-title " ")) + ((and (bound-and-true-p evil-local-mode) + (bound-and-true-p evil-input-method)) + (concat + (nth 3 (assoc default-input-method input-method-alist)) + " "))) + 'face 'doom-modeline-buffer-major-mode))) ;;