From f7a573906d8f58043c0bd09c3bbf4162c710055e Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Tue, 25 Sep 2018 00:05:01 +0800 Subject: [PATCH] Update vc state on modeline while selecting the window. This might address this issue: Modeline VC branch name not updating on magit-checkout. In doom-modeline, only show vc state in active window, so it makes sense to update vc state while selecting the window, and it won't bring performance issue. Refer to: https://github.com/hlissner/doom-emacs/issues/826 https://github.com/seagle0128/doom-modeline/commit/3d8e81b7e132629c2f16eb99338084cc1a8ffe81 --- doom-modeline.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doom-modeline.el b/doom-modeline.el index 2b0b711..93608e6 100644 --- a/doom-modeline.el +++ b/doom-modeline.el @@ -661,7 +661,7 @@ directory, the file name, and its state (modified, read-only or non-existent)." ;; (defvar-local doom-modeline--vcs nil) -(defun doom-modeline--update-vcs () +(defun doom-modeline--update-vcs (&rest _) "Update vsc state in mode-line." (setq doom-modeline--vcs (when (and vc-mode buffer-file-name) @@ -699,7 +699,7 @@ directory, the file name, and its state (modified, read-only or non-existent)." (add-hook 'after-revert-hook #'doom-modeline--update-vcs) (add-hook 'after-save-hook #'doom-modeline--update-vcs) (add-hook 'find-file-hook #'doom-modeline--update-vcs t) -(advice-add #'vc-refresh-state :after #'doom-modeline--update-vcs) +(advice-add #'select-window :after #'doom-modeline--update-vcs) (doom-modeline-def-segment vcs "Displays the current branch, colored based on its state."