Optimize performance.

See #139.
This commit is contained in:
Vincent Zhang 2019-03-08 15:23:59 +07:00
parent a35a403c99
commit cc29f43045
2 changed files with 7 additions and 11 deletions

View file

@ -215,7 +215,7 @@ Uses `all-the-icons-material' to fetch the icon."
"lock" "lock"
"%1*" "%1*"
'doom-modeline-warning)) 'doom-modeline-warning))
((buffer-modified-p) ((and buffer-file-name (buffer-modified-p))
(doom-modeline-buffer-file-state-icon (doom-modeline-buffer-file-state-icon
"save" "save"
"%1*" "%1*"
@ -235,11 +235,9 @@ Uses `all-the-icons-material' to fetch the icon."
(add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-state-icon) (add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-state-icon)
(add-hook 'after-save-hook #'doom-modeline-update-buffer-file-state-icon) (add-hook 'after-save-hook #'doom-modeline-update-buffer-file-state-icon)
(add-hook 'read-only-mode-hook #'doom-modeline-update-buffer-file-state-icon) (add-hook 'read-only-mode-hook #'doom-modeline-update-buffer-file-state-icon)
(add-hook 'after-change-functions #'doom-modeline-update-buffer-file-state-icon) ;; (add-hook 'after-change-functions #'doom-modeline-update-buffer-file-state-icon)
(add-hook 'clone-indirect-buffer-hook #'doom-modeline-update-buffer-file-state-icon) (add-hook 'clone-indirect-buffer-hook #'doom-modeline-update-buffer-file-state-icon)
(add-hook 'evil-insert-state-exit-hook #'doom-modeline-update-buffer-file-state-icon) (add-hook 'evil-insert-state-exit-hook #'doom-modeline-update-buffer-file-state-icon)
(advice-add #'set-buffer-modified-p :after #'doom-modeline-update-buffer-file-state-icon)
(advice-add #'restore-buffer-modified-p :after #'doom-modeline-update-buffer-file-state-icon)
(advice-add #'undo :after #'doom-modeline-update-buffer-file-state-icon) (advice-add #'undo :after #'doom-modeline-update-buffer-file-state-icon)
(advice-add #'undo-tree-undo-1 :after #'doom-modeline-update-buffer-file-state-icon) (advice-add #'undo-tree-undo-1 :after #'doom-modeline-update-buffer-file-state-icon)
(advice-add #'undo-tree-redo-1 :after #'doom-modeline-update-buffer-file-state-icon) (advice-add #'undo-tree-redo-1 :after #'doom-modeline-update-buffer-file-state-icon)
@ -275,10 +273,9 @@ Uses `all-the-icons-material' to fetch the icon."
(if buffer-file-name (if buffer-file-name
(doom-modeline-buffer-file-name) (doom-modeline-buffer-file-name)
(propertize "%b" (propertize "%b"
'face (cond 'face (if (doom-modeline--active)
((buffer-modified-p) 'doom-modeline-buffer-modified) 'doom-modeline-buffer-file
((doom-modeline--active) 'doom-modeline-buffer-file) 'mode-line-inactive)
(t 'mode-line-inactive))
'help-echo "Buffer name 'help-echo "Buffer name
mouse-1: Previous buffer\nmouse-3: Next buffer" mouse-1: Previous buffer\nmouse-3: Next buffer"
'local-map mode-line-buffer-identification-keymap)))) 'local-map mode-line-buffer-identification-keymap))))
@ -290,11 +287,10 @@ mouse-1: Previous buffer\nmouse-3: Next buffer"
(add-hook 'evil-insert-state-exit-hook #'doom-modeline-update-buffer-file-name) (add-hook 'evil-insert-state-exit-hook #'doom-modeline-update-buffer-file-name)
(advice-add #'rename-buffer :after #'doom-modeline-update-buffer-file-name) (advice-add #'rename-buffer :after #'doom-modeline-update-buffer-file-name)
(advice-add #'set-visited-file-name :after #'doom-modeline-update-buffer-file-name) (advice-add #'set-visited-file-name :after #'doom-modeline-update-buffer-file-name)
(advice-add #'set-buffer-modified-p :after #'doom-modeline-update-buffer-file-name)
(advice-add #'restore-buffer-modified-p :after #'doom-modeline-update-buffer-file-name)
(advice-add #'undo :after #'doom-modeline-update-buffer-file-name) (advice-add #'undo :after #'doom-modeline-update-buffer-file-name)
(advice-add #'undo-tree-undo-1 :after #'doom-modeline-update-buffer-file-name) (advice-add #'undo-tree-undo-1 :after #'doom-modeline-update-buffer-file-name)
(advice-add #'undo-tree-redo-1 :after #'doom-modeline-update-buffer-file-name) (advice-add #'undo-tree-redo-1 :after #'doom-modeline-update-buffer-file-name)
(advice-add #'fill-paragraph :after #'doom-modeline-update-buffer-file-name)
(advice-add #'symbol-overlay-rename :after #'doom-modeline-update-buffer-file-name) (advice-add #'symbol-overlay-rename :after #'doom-modeline-update-buffer-file-name)
(advice-add #'doom-modeline-set-selected-window :after #'doom-modeline-update-buffer-file-name) (advice-add #'doom-modeline-set-selected-window :after #'doom-modeline-update-buffer-file-name)
(if (fboundp 'doom-modeline-refresh-frame) (if (fboundp 'doom-modeline-refresh-frame)

View file

@ -4,7 +4,7 @@
;; Author: Vincent Zhang <seagle0128@gmail.com> ;; Author: Vincent Zhang <seagle0128@gmail.com>
;; Homepage: https://github.com/seagle0128/doom-modeline ;; Homepage: https://github.com/seagle0128/doom-modeline
;; Version: 1.8.3 ;; Version: 1.8.4
;; Package-Requires: ((emacs "25.1") (all-the-icons "1.0.0") (shrink-path "0.2.0") (eldoc-eval "0.1") (dash "2.11.0")) ;; Package-Requires: ((emacs "25.1") (all-the-icons "1.0.0") (shrink-path "0.2.0") (eldoc-eval "0.1") (dash "2.11.0"))
;; Keywords: faces mode-line ;; Keywords: faces mode-line