From a45ce1e14d09b585369ce59d62a79588cd46780a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 13 Apr 2025 06:35:25 -0400 Subject: [PATCH] fix(magit): do less on magit-refresh-buffer Inhibit recentf-cleanup and projectile caching, and silence it's logging on refresh-buffer. The former can potentially be slow and isn't necessary on top of invalidating the cache, and the latter is noise. --- modules/tools/magit/config.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/tools/magit/config.el b/modules/tools/magit/config.el index 137479e7f..ce8487552 100644 --- a/modules/tools/magit/config.el +++ b/modules/tools/magit/config.el @@ -71,12 +71,18 @@ FUNCTION ;; Turn ref links into clickable buttons. (add-hook 'magit-process-mode-hook #'goto-address-mode) - ;; Since the project likely now contains new files, best we undo the - ;; projectile cache so it can be regenerated later. + ;; Since the project likely now contains new files, purge the projectile cache + ;; so `projectile-find-file' et all don't produce an stale file list. (add-hook! 'magit-refresh-buffer-hook (defun +magit-invalidate-projectile-cache-h () - (let (projectile-require-project-root) - (projectile-invalidate-cache nil)))) + ;; Only invalidate the hot cache and nothing else (everything else is + ;; expensive busy work, and we don't want to slow down magit's + ;; refreshing). + (let (projectile-require-project-root + projectile-enable-caching + projectile-verbose) + (letf! ((#'recentf-cleanup #'ignore)) + (projectile-invalidate-cache nil))))) ;; Use a more efficient strategy to auto-revert buffers whose git state has ;; changed: refresh the visible buffers immediately... (add-hook 'magit-post-refresh-hook #'+magit-mark-stale-buffers-h)