From cc29f43045dda06bbddc37c6601bca89daf3bd71 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Fri, 8 Mar 2019 15:23:59 +0700 Subject: [PATCH] Optimize performance. See #139. --- doom-modeline-segments.el | 16 ++++++---------- doom-modeline.el | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index fccfd79..99bcace 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -215,7 +215,7 @@ Uses `all-the-icons-material' to fetch the icon." "lock" "%1*" 'doom-modeline-warning)) - ((buffer-modified-p) + ((and buffer-file-name (buffer-modified-p)) (doom-modeline-buffer-file-state-icon "save" "%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-save-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 '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-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) @@ -275,10 +273,9 @@ Uses `all-the-icons-material' to fetch the icon." (if buffer-file-name (doom-modeline-buffer-file-name) (propertize "%b" - 'face (cond - ((buffer-modified-p) 'doom-modeline-buffer-modified) - ((doom-modeline--active) 'doom-modeline-buffer-file) - (t 'mode-line-inactive)) + 'face (if (doom-modeline--active) + 'doom-modeline-buffer-file + 'mode-line-inactive) 'help-echo "Buffer name mouse-1: Previous buffer\nmouse-3: Next buffer" '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) (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-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-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 #'fill-paragraph :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) (if (fboundp 'doom-modeline-refresh-frame) diff --git a/doom-modeline.el b/doom-modeline.el index 4834ed2..ccd8a49 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -4,7 +4,7 @@ ;; Author: Vincent Zhang ;; 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")) ;; Keywords: faces mode-line