Fix #173: Vertical separators showing up when modeline is inactive.

This commit is contained in:
Vincent Zhang 2019-05-18 23:53:47 +08:00
parent 66029d4590
commit 230ffe8efc
3 changed files with 148 additions and 154 deletions

View file

@ -86,6 +86,21 @@ It returns a file name which can be used directly as argument of
;; multiple-cursors ;; multiple-cursors
("i-cursor" . "\xf246") ("i-cursor" . "\xf246")
;; vcs
("git-compare" . "\xf0ac")
("git-merge" . "\xf023")
("arrow-down" . "\xf03f")
("alert" . "\xf02d")
("git-branch" . "\xf020")
;; checker: flycheck/flymake
("do_not_disturb_alt" . "\xe611")
("check" . "\xe5ca")
("access_time" . "\xe192")
("sim_card_alert" . "\xe624")
("pause" . "\xe034")
("priority_high" . "\xe645")
;; LSP ;; LSP
("rocket" . "\xf135") ("rocket" . "\xf135")
@ -373,9 +388,9 @@ Given ~/Projects/FOSS/emacs/lisp/comint.el
" " " "
'face (if (doom-modeline--active) 'mode-line 'mode-line-inactive) 'face (if (doom-modeline--active) 'mode-line 'mode-line-inactive)
'display `((space :align-to (- (+ right right-fringe right-margin) 'display `((space :align-to (- (+ right right-fringe right-margin)
,(+ 1 (string-width ,(string-width
(format-mode-line (format-mode-line
(cons "" rhs-forms)))))))) (cons "" rhs-forms)))))))
rhs-forms)) rhs-forms))
(concat "Modeline:\n" (concat "Modeline:\n"
(format " %s\n %s" (format " %s\n %s"

View file

@ -192,17 +192,25 @@
(doom-modeline-def-segment buffer-default-directory (doom-modeline-def-segment buffer-default-directory
"Displays `default-directory'. This is for special buffers like the scratch "Displays `default-directory'. This is for special buffers like the scratch
buffer where knowing the current project directory is important." buffer where knowing the current project directory is important."
(let ((face (if (doom-modeline--active) (let ((active (doom-modeline--active))
'doom-modeline-buffer-path (icon (doom-modeline-icon-octicon "file-directory"
'mode-line-inactive))) :face 'doom-modeline-buffer-path
(concat (doom-modeline-whitespace)
(doom-modeline-icon-octicon
"file-directory"
:face face
:v-adjust -0.05 :v-adjust -0.05
:height 1.25) :height 1.25)))
(when doom-modeline-icon (doom-modeline-whitespace)) (concat (doom-modeline-whitespace)
(propertize (abbreviate-file-name default-directory) 'face face)))) (when doom-modeline-icon
(concat
(if active
icon
(propertize icon 'face `(:inherit
,(get-text-property 0 'face icon)
:inherit
mode-line-inactive)))
(doom-modeline-whitespace)))
(propertize (abbreviate-file-name default-directory)
'face (if active
'doom-modeline-buffer-path
'mode-line-inactive)))))
;; ;;
(defvar-local doom-modeline--buffer-file-icon nil) (defvar-local doom-modeline--buffer-file-icon nil)
@ -374,22 +382,14 @@ directory, the file name, and its state (modified, read-only or non-existent)."
(when (and doom-modeline-icon doom-modeline-major-mode-icon) (when (and doom-modeline-icon doom-modeline-major-mode-icon)
(when-let ((icon (or doom-modeline--buffer-file-icon (when-let ((icon (or doom-modeline--buffer-file-icon
(doom-modeline-update-buffer-file-icon)))) (doom-modeline-update-buffer-file-icon))))
(unless (string-empty-p icon) (when icon
(concat (concat
(propertize icon 'face
(if active (if active
`(:inherit icon
mode-line (propertize icon 'face `(:inherit
:inherit ,(let* ((props (get-text-property 0 'face icon)))
,(let ((props (get-text-property 0 'face icon)))
(if doom-modeline-major-mode-color-icon (if doom-modeline-major-mode-color-icon
props props (remove :inherit props)))
(remove :inherit props))))
`(:inherit
,(let ((props (get-text-property 0 'face icon)))
(if doom-modeline-major-mode-color-icon
props
(remove :inherit props)))
:inherit :inherit
mode-line-inactive))) mode-line-inactive)))
(doom-modeline-vspc))))) (doom-modeline-vspc)))))
@ -397,14 +397,11 @@ directory, the file name, and its state (modified, read-only or non-existent)."
;; state icon ;; state icon
(when-let ((icon (or doom-modeline--buffer-file-state-icon (when-let ((icon (or doom-modeline--buffer-file-state-icon
(doom-modeline-update-buffer-file-state-icon)))) (doom-modeline-update-buffer-file-state-icon))))
(unless (string-empty-p icon) (when icon
(concat (concat
(propertize icon 'face (if active
(if active `(:inherit icon
mode-line (propertize icon 'face `(:inherit
:inherit
,(get-text-property 0 'face icon))
`(:inherit
,(get-text-property 0 'face icon) ,(get-text-property 0 'face icon)
:inherit :inherit
mode-line-inactive))) mode-line-inactive)))
@ -443,8 +440,7 @@ directory, the file name, and its state (modified, read-only or non-existent)."
(cond ((memq (plist-get sys :category) (cond ((memq (plist-get sys :category)
'(coding-category-undecided coding-category-utf-8)) '(coding-category-undecided coding-category-utf-8))
" UTF-8 ") " UTF-8 ")
(t (upcase (symbol-name (plist-get sys :name)))))) (t (upcase (symbol-name (plist-get sys :name)))))))
(doom-modeline-whitespace))
'face (if (doom-modeline--active) 'mode-line 'mode-line-inactive) 'face (if (doom-modeline--active) 'mode-line 'mode-line-inactive)
'help-echo 'mode-line-mule-info-help-echo 'help-echo 'mode-line-mule-info-help-echo
'mouse-face '(:box 0) 'mouse-face '(:box 0)
@ -482,14 +478,15 @@ directory, the file name, and its state (modified, read-only or non-existent)."
(doom-modeline-def-segment major-mode (doom-modeline-def-segment major-mode
"The major mode, including environment and text-scale info." "The major mode, including environment and text-scale info."
(propertize (propertize
(concat (format-mode-line (concat
`(:propertize ("" mode-name) (doom-modeline-whitespace)
help-echo "Major mode\n\ (propertize mode-name
'help-echo "Major mode\n\
mouse-1: Display major mode menu\n\ mouse-1: Display major mode menu\n\
mouse-2: Show help for major mode\n\ mouse-2: Show help for major mode\n\
mouse-3: Toggle minor modes" mouse-3: Toggle minor modes"
mouse-face mode-line-highlight 'mouse-face 'mode-line-highlight
local-map ,mode-line-major-mode-keymap)) 'local-map mode-line-major-mode-keymap)
(when (and doom-modeline-env-version doom-modeline-env--version) (when (and doom-modeline-env-version doom-modeline-env--version)
(format " %s" doom-modeline-env--version)) (format " %s" doom-modeline-env--version))
(and (boundp 'text-scale-mode-amount) (and (boundp 'text-scale-mode-amount)
@ -498,7 +495,8 @@ mouse-3: Toggle minor modes"
(if (> text-scale-mode-amount 0) (if (> text-scale-mode-amount 0)
" (%+d)" " (%+d)"
" (%-d)") " (%-d)")
text-scale-mode-amount))) text-scale-mode-amount))
(doom-modeline-whitespace))
'face (if (doom-modeline--active) 'face (if (doom-modeline--active)
'doom-modeline-buffer-major-mode 'doom-modeline-buffer-major-mode
'mode-line-inactive))) 'mode-line-inactive)))
@ -543,7 +541,7 @@ mouse-1: Display minor modes menu"
"%%%%" "%%%%"
(format-mode-line '("" minor-mode-alist)) (format-mode-line '("" minor-mode-alist))
t t) t t)
" ") (doom-modeline-whitespace))
'face (if active 'face (if active
'doom-modeline-buffer-minor-mode 'doom-modeline-buffer-minor-mode
'mode-line-inactive)))))) 'mode-line-inactive))))))
@ -622,27 +620,17 @@ Uses `all-the-icons-octicon' to fetch the icon."
(when-let ((icon (or doom-modeline--vcs-icon (doom-modeline-update-vcs-icon))) (when-let ((icon (or doom-modeline--vcs-icon (doom-modeline-update-vcs-icon)))
(text (or doom-modeline--vcs-text (doom-modeline-update-vcs-text)))) (text (or doom-modeline--vcs-text (doom-modeline-update-vcs-text))))
(concat (concat
(doom-modeline-whitespace) (doom-modeline-whitespace) (doom-modeline-whitespace)
(propertize icon 'face (if active
(if active `(:inherit icon
mode-line (propertize icon 'face `(:inherit
:inherit
,(get-text-property 0 'face icon))
`(:inherit
,(get-text-property 0 'face icon) ,(get-text-property 0 'face icon)
:inherit :inherit
mode-line-inactive))) mode-line-inactive)))
(if doom-modeline-icon (if doom-modeline-icon (doom-modeline-vspc))
(doom-modeline-vspc)) (if active
(propertize text 'face text
(if active `(:inherit (propertize text 'face 'mode-line-inactive))
,(get-text-property 0 'face text)
:inherit
mode-line)
`(:inherit
,(get-text-property 0 'face text)
:inherit
mode-line-inactive)))
(doom-modeline-whitespace))))) (doom-modeline-whitespace)))))
@ -691,8 +679,8 @@ Uses `all-the-icons-material' to fetch the icon."
(`interrupted (doom-modeline-checker-icon "pause" "!" 'doom-modeline-debug)) (`interrupted (doom-modeline-checker-icon "pause" "!" 'doom-modeline-debug))
(`suspicious (doom-modeline-checker-icon "priority_high" "!" 'doom-modeline-urgent)) (`suspicious (doom-modeline-checker-icon "priority_high" "!" 'doom-modeline-urgent))
(_ nil)))) (_ nil))))
(propertize (when icon
icon (propertize icon
'help-echo (concat "Flycheck\n" 'help-echo (concat "Flycheck\n"
(pcase status (pcase status
('finished "mouse-1: Display minor mode menu ('finished "mouse-1: Display minor mode menu
@ -710,7 +698,7 @@ mouse-2: Show help for minor mode")
(lambda () (lambda ()
(interactive) (interactive)
(describe-function 'flycheck-mode))) (describe-function 'flycheck-mode)))
map))))) map))))))
(add-hook 'flycheck-status-changed-functions #'doom-modeline-update-flycheck-icon) (add-hook 'flycheck-status-changed-functions #'doom-modeline-update-flycheck-icon)
(add-hook 'flycheck-mode-hook #'doom-modeline-update-flycheck-icon) (add-hook 'flycheck-mode-hook #'doom-modeline-update-flycheck-icon)
@ -957,19 +945,15 @@ icons."
`(,doom-modeline--flymake-icon . ,doom-modeline--flymake-text)) `(,doom-modeline--flymake-icon . ,doom-modeline--flymake-text))
((bound-and-true-p flycheck-mode) ((bound-and-true-p flycheck-mode)
`(,doom-modeline--flycheck-icon . ,doom-modeline--flycheck-text))))) `(,doom-modeline--flycheck-icon . ,doom-modeline--flycheck-text)))))
(if seg (when seg
(let ((icon (car seg)) (let ((icon (car seg))
(text (cdr seg))) (text (cdr seg)))
(concat (concat
(doom-modeline-whitespace) (doom-modeline-whitespace)
(unless vc-mode (doom-modeline-whitespace))
(when icon (when icon
(propertize icon 'face (if active
(if active `(:inherit icon
mode-line (propertize icon 'face `(:inherit
:inherit
,(get-text-property 0 'face icon))
`(:inherit
,(get-text-property 0 'face icon) ,(get-text-property 0 'face icon)
:inherit :inherit
mode-line-inactive)))) mode-line-inactive))))
@ -978,9 +962,7 @@ icons."
(when text (when text
(if active (if active
text text
(propertize text 'face 'mode-line-inactive))) (propertize text 'face 'mode-line-inactive))))))))
(doom-modeline-whitespace)))
"")))
;; ;;
@ -1589,7 +1571,7 @@ mouse-3: Describe current input method")
"The topic and nodes in the Info buffer." "The topic and nodes in the Info buffer."
(let ((active (doom-modeline--active))) (let ((active (doom-modeline--active)))
(concat (concat
" (" (propertize " (" (if active 'mode-line 'mode-line-inactive))
;; topic ;; topic
(propertize (if (stringp Info-current-file) (propertize (if (stringp Info-current-file)
(replace-regexp-in-string (replace-regexp-in-string
@ -1598,7 +1580,7 @@ mouse-3: Describe current input method")
(file-name-nondirectory Info-current-file))) (file-name-nondirectory Info-current-file)))
(format "*%S*" Info-current-file)) (format "*%S*" Info-current-file))
'face (if active 'doom-modeline-info 'mode-line-inactive)) 'face (if active 'doom-modeline-info 'mode-line-inactive))
") " (propertize ") " (if active 'mode-line 'mode-line-inactive))
;; node ;; node
(if Info-current-node (if Info-current-node
(propertize (replace-regexp-in-string (propertize (replace-regexp-in-string
@ -1629,7 +1611,6 @@ mouse-3: Describe current input method")
(face (if workspaces 'success 'warning)) (face (if workspaces 'success 'warning))
(icon (doom-modeline-lsp-icon "LSP" face))) (icon (doom-modeline-lsp-icon "LSP" face)))
(propertize icon (propertize icon
'face `(:inherit ,(get-text-property 0 'face icon))
'help-echo (if workspaces 'help-echo (if workspaces
(concat "LSP Connected " (concat "LSP Connected "
(string-join (--map (format "[%s]\n" (lsp--workspace-print it)) (string-join (--map (format "[%s]\n" (lsp--workspace-print it))
@ -1679,7 +1660,6 @@ mouse-1: Reload to start server")
(t 'mode-line))) (t 'mode-line)))
(icon (doom-modeline-lsp-icon "EGLOT" face))) (icon (doom-modeline-lsp-icon "EGLOT" face)))
(propertize icon (propertize icon
'face `(:inherit ,(get-text-property 0 'face icon))
'help-echo (cond 'help-echo (cond
(last-error (last-error
(format "EGLOT\nAn error occured: %s (format "EGLOT\nAn error occured: %s
@ -1719,22 +1699,20 @@ mouse-3: Reconnect to server" nick (eglot--major-mode server)))
(doom-modeline-def-segment lsp (doom-modeline-def-segment lsp
"The LSP server state." "The LSP server state."
(when doom-modeline-lsp (when doom-modeline-lsp
(when-let ((active (doom-modeline--active)) (let ((active (doom-modeline--active))
(icon (cond ((bound-and-true-p lsp-mode) (icon (cond ((bound-and-true-p lsp-mode)
doom-modeline--lsp) doom-modeline--lsp)
((bound-and-true-p eglot--managed-mode) ((bound-and-true-p eglot--managed-mode)
doom-modeline--eglot)))) doom-modeline--eglot))))
(concat (concat
(doom-modeline-whitespace) (doom-modeline-whitespace)
(propertize icon 'face (if active (when icon
`(:inherit (if active
mode-line icon
:inherit (propertize icon 'face `(:inherit
,(get-text-property 0 'face icon))
`(:inherit
,(get-text-property 0 'face icon) ,(get-text-property 0 'face icon)
:inherit :inherit
mode-line-inactive))) mode-line-inactive))))
(doom-modeline-whitespace))))) (doom-modeline-whitespace)))))
(defun doom-modeline-override-eglot-modeline () (defun doom-modeline-override-eglot-modeline ()
@ -2159,14 +2137,15 @@ we don't want to remove that so we just return the original."
(when (and doom-modeline-icon doom-modeline-major-mode-icon) (when (and doom-modeline-icon doom-modeline-major-mode-icon)
(concat (doom-modeline-whitespace) (concat (doom-modeline-whitespace)
(let ((icon (doom-modeline-icon-for-mode 'paradox-menu-mode :v-adjust -0.15))) (let ((icon (doom-modeline-icon-for-mode 'paradox-menu-mode :v-adjust -0.15)))
(if active
icon
(propertize icon 'face `(:inherit (propertize icon 'face `(:inherit
,(let ((props (get-text-property 0 'face icon))) ,(let ((props (get-text-property 0 'face icon)))
(if doom-modeline-major-mode-color-icon (if doom-modeline-major-mode-color-icon
props props
(remove :inherit props))) (remove :inherit props)))
:inherit :inherit
,(if active 'mode-line 'mode-line-inactive)))))) mode-line-inactive))))))
(let ((info (format-mode-line 'mode-line-buffer-identification))) (let ((info (format-mode-line 'mode-line-buffer-identification)))
(if active (if active
info info

View file

@ -90,7 +90,7 @@
'(objed-state misc-info persp-name fancy-battery irc mu4e github debug lsp minor-modes input-method indent-info buffer-encoding major-mode process vcs checker)) '(objed-state misc-info persp-name fancy-battery irc mu4e github debug lsp minor-modes input-method indent-info buffer-encoding major-mode process vcs checker))
(doom-modeline-def-modeline 'minimal (doom-modeline-def-modeline 'minimal
'(bar matches " " buffer-info) '(bar matches buffer-info)
'(media-info major-mode)) '(media-info major-mode))
(doom-modeline-def-modeline 'special (doom-modeline-def-modeline 'special
@ -98,12 +98,12 @@
'(objed-state misc-info fancy-battery irc-buffers debug lsp minor-modes input-method indent-info buffer-encoding major-mode process checker)) '(objed-state misc-info fancy-battery irc-buffers debug lsp minor-modes input-method indent-info buffer-encoding major-mode process checker))
(doom-modeline-def-modeline 'project (doom-modeline-def-modeline 'project
'(bar window-number " " buffer-default-directory) '(bar window-number buffer-default-directory)
'(misc-info fancy-battery mu4e github debug " " major-mode process)) '(misc-info fancy-battery mu4e github debug major-mode process))
(doom-modeline-def-modeline 'package (doom-modeline-def-modeline 'package
'(bar window-number package) '(bar window-number package)
'(misc-info " " major-mode process)) '(misc-info major-mode process))
(doom-modeline-def-modeline 'info (doom-modeline-def-modeline 'info
'(bar window-number buffer-info info-nodes buffer-position parrot selection-info) '(bar window-number buffer-info info-nodes buffer-position parrot selection-info)
@ -115,7 +115,7 @@
(doom-modeline-def-modeline 'pdf (doom-modeline-def-modeline 'pdf
'(bar window-number buffer-size buffer-info pdf-pages) '(bar window-number buffer-size buffer-info pdf-pages)
'(misc-info " " major-mode process vcs)) '(misc-info major-mode process vcs))
(doom-modeline-def-modeline 'helm (doom-modeline-def-modeline 'helm
'(bar helm-buffer-id helm-number helm-follow helm-prefix-argument) '(bar helm-buffer-id helm-number helm-follow helm-prefix-argument)