emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit 18728adc76 4/9: magit-zap-caches: With a prefix


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 18728adc76 4/9: magit-zap-caches: With a prefix discard complete caches
Date: Tue, 22 Feb 2022 05:58:10 -0500 (EST)

branch: elpa/git-commit
commit 18728adc7610e56419321a53ff9011d8d928a8c8
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-zap-caches: With a prefix discard complete caches
---
 lisp/magit-mode.el | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index 95d4898a1e..5d8764c59a 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -1421,20 +1421,31 @@ Unless specified, REPOSITORY is the current buffer's 
repository."
         (magit-repository-local-get
          (cons mode 'magit-section-visibility-cache))))
 
-(defun magit-zap-caches ()
+(defun magit-zap-caches (&optional all)
   "Zap caches for the current repository.
+
 Remove the repository's entry from `magit-repository-local-cache'
 and set `magit-section-visibility-cache' to nil in all of the
-repository's Magit buffers."
+repository's Magit buffers.
+
+With a prefix argument or if optional ALL is non-nil, discard the
+mentioned caches completely."
   (interactive)
-  (magit-with-toplevel
-    (setq magit-repository-local-cache
-          (cl-delete default-directory
-                     magit-repository-local-cache
-                     :key #'car :test #'equal)))
-  (dolist (buffer (magit-mode-get-buffers))
-    (with-current-buffer buffer
-      (setq magit-section-visibility-cache nil)))
+  (cond (all
+         (setq magit-repository-local-cache nil)
+         (dolist (buffer (buffer-list))
+           (with-current-buffer buffer
+             (when (derived-mode-p 'magit-mode)
+               (setq magit-section-visibility-cache nil)))))
+        (t
+         (magit-with-toplevel
+           (setq magit-repository-local-cache
+                 (cl-delete default-directory
+                            magit-repository-local-cache
+                            :key #'car :test #'equal)))
+         (dolist (buffer (magit-mode-get-buffers))
+           (with-current-buffer buffer
+             (setq magit-section-visibility-cache nil)))))
   (setq magit--libgit-available-p 'unknown))
 
 ;;; Utilities



reply via email to

[Prev in Thread] Current Thread [Next in Thread]