From fcd1e913c519d51a18e6f8157ccd1a0f0669340c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 26 Sep 2018 12:10:00 -0400 Subject: [PATCH] tools/magit: update vc on +magit/quit Instead of magit-post-refresh-hook, which fires much more frequently. Updating vc across all buffers is expensive, so let's only do it when we quit magit. Warning: this may make quitting magit expensive when you have many buffers open. Still searching for a better solution. --- modules/tools/magit/autoload.el | 11 +++++++++-- modules/tools/magit/config.el | 9 +-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/tools/magit/autoload.el b/modules/tools/magit/autoload.el index 72df14f4f..d6cda9596 100644 --- a/modules/tools/magit/autoload.el +++ b/modules/tools/magit/autoload.el @@ -50,9 +50,16 @@ ;;;###autoload (defun +magit/quit (&optional _kill-buffer) - "Clean up magit buffers after quitting `magit-status'." + "Clean up magit buffers after quitting `magit-status' and refresh version +control in buffers." (interactive) - (mapc #'+magit--kill-buffer (magit-mode-get-buffers))) + (mapc #'+magit--kill-buffer (magit-mode-get-buffers)) + (dolist (buffer (buffer-list)) + (with-current-buffer buffer + (when (fboundp 'vc-refresh-state) + (vc-refresh-state)) + (when (fboundp '+version-control|update-git-gutter) + (+version-control|update-git-gutter))))) (defun +magit--kill-buffer (buf) "TODO" diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index 6792eecec..413ae80ac 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -47,14 +47,7 @@ available.") ;; Don't replace the leader key ;; FIXME remove me when general.el is integrated - (define-key magit-diff-mode-map (kbd doom-leader-key) nil) - - (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)) + (define-key magit-diff-mode-map (kbd doom-leader-key) nil)) (def-package! magit-todos