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.
This commit is contained in:
Henrik Lissner
2025-04-13 06:35:25 -04:00
parent dddc01982b
commit a45ce1e14d

View File

@ -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)