Refresh vc when magit refreshes #826

Magit does not inform vc that changes have occurred to open buffers.
This fixes that (and indirectly fixes branch display in the modeline).
This commit is contained in:
Henrik Lissner 2018-08-23 17:09:37 +02:00
parent c7abe743d1
commit 641cef9848
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 10 additions and 1 deletions

View file

@ -36,7 +36,15 @@ available.")
(add-hook! '(magit-mode-hook magit-popup-mode-hook) (add-hook! '(magit-mode-hook magit-popup-mode-hook)
#'hide-mode-line-mode) #'hide-mode-line-mode)
;; properly kill leftover magit buffers on quit ;; properly kill leftover magit buffers on quit
(define-key magit-status-mode-map [remap magit-mode-bury-buffer] #'+magit/quit)) (define-key magit-status-mode-map [remap magit-mode-bury-buffer] #'+magit/quit)
(defun +magit|update-vc ()
"Update vc in all verson-controlled buffers when magit refreshes."
(dolist (buf (buffer-list))
(with-current-buffer buf
(vc-refresh-state))))
(add-hook 'magit-post-refresh-hook #'+magit|update-vc))
(def-package! magit-todos (def-package! magit-todos

View file

@ -529,6 +529,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-revert-hook #'+doom-modeline--update-vcs)
(add-hook 'after-save-hook #'+doom-modeline--update-vcs) (add-hook 'after-save-hook #'+doom-modeline--update-vcs)
(add-hook 'find-file-hook #'+doom-modeline--update-vcs t) (add-hook 'find-file-hook #'+doom-modeline--update-vcs t)
(advice-add #'vc-refresh-state :after #'+doom-modeline--update-vcs)
(def-modeline-segment! vcs (def-modeline-segment! vcs
"Displays the current branch, colored based on its state." "Displays the current branch, colored based on its state."