about summary refs log tree commit diff stats
path: root/emacs-prelude/personal/lisp/init-git.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs-prelude/personal/lisp/init-git.el')
-rw-r--r--emacs-prelude/personal/lisp/init-git.el22
1 files changed, 12 insertions, 10 deletions
diff --git a/emacs-prelude/personal/lisp/init-git.el b/emacs-prelude/personal/lisp/init-git.el
index 626b3d0..041ff8e 100644
--- a/emacs-prelude/personal/lisp/init-git.el
+++ b/emacs-prelude/personal/lisp/init-git.el
@@ -4,18 +4,19 @@
   (defun my/magit-set-upstream ()
     (interactive)
     (magit-shell-command-topdir "git upstream"))
+  ;; update stale git info on the modeline (based on code removed from doom modeline)
+  (defun my/magit-refresh-state ()
+    (interactive)
+    (dolist (buf (buffer-list))
+            (when (and (not (buffer-modified-p buf))
+                       (buffer-file-name buf)
+                       (file-exists-p (buffer-file-name buf))
+                       (file-in-directory-p (buffer-file-name buf) (magit-toplevel)))
+              (with-current-buffer buf
+                (vc-refresh-state)))))
   :config
   (key-chord-define-global "UU" 'my/magit-set-upstream)
-  ;; prevent the git info on the modeline from becoming stale (based on code removed from doom modeline)
-  :hook (magit-post-refresh .
-    (lambda ()
-      (dolist (buf (buffer-list))
-        (when (and (not (buffer-modified-p buf))
-                   (buffer-file-name buf)
-                   (file-exists-p (buffer-file-name buf))
-                   (file-in-directory-p (buffer-file-name buf) (magit-toplevel)))
-          (with-current-buffer buf
-            (vc-refresh-state)))))))
+  (key-chord-define-global "RR" 'my/magit-refresh-state))
 
 (prelude-require-package 'forge)
 (use-package forge
@@ -32,3 +33,4 @@
   ("C-c j r" . git-gutter:revert-hunk))
 
 (provide 'init-git)
+