aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/RelNotes/2.12.0.txt7
-rw-r--r--Documentation/magit.org14
-rw-r--r--Documentation/magit.texi14
-rw-r--r--lisp/magit-diff.el7
-rw-r--r--lisp/magit-section.el23
5 files changed, 36 insertions, 29 deletions
diff --git a/Documentation/RelNotes/2.12.0.txt b/Documentation/RelNotes/2.12.0.txt
index 43e0546..a2a6fa1 100644
--- a/Documentation/RelNotes/2.12.0.txt
+++ b/Documentation/RelNotes/2.12.0.txt
@@ -268,10 +268,9 @@ Changes since v2.11.0
of being shown. For `magit-status-mode' and `magit-refs-mode'
buffers the cache now persists when killing the buffer. #2780
-* The new option `magit-section-cache-visibility-types' lets users
- choose for which section types the visibility cache should be done.
- By default that is now also done for `untracked, `unstaged' and
- `staged' sections. #2780
+* The new option `magit-section-cache-visibility' lets users choose
+ for which section types the visibility cache should be done. By
+ default that is done for all sections. #2780
* Added command `magit-remote-prune-refspec', which is necessary
because Git does not ignore invalid refspecs and instead refuses
diff --git a/Documentation/magit.org b/Documentation/magit.org
index dab79b0..e583e0e 100644
--- a/Documentation/magit.org
+++ b/Documentation/magit.org
@@ -7,7 +7,7 @@
#+TEXINFO_DIR_CATEGORY: Emacs
#+TEXINFO_DIR_TITLE: Magit: (magit).
#+TEXINFO_DIR_DESC: Using Git from Emacs with Magit.
-#+SUBTITLE: for version 2.11.0 (2.11.0-411-g73ea37afb+1)
+#+SUBTITLE: for version 2.11.0 (2.11.0-436-g3baeddd4c+1)
#+BIND: ox-texinfo+-before-export-hook ox-texinfo+-update-version-strings
#+TEXINFO_DEFFN: t
@@ -22,7 +22,7 @@ directly from within Emacs. While many fine Git clients exist, only
Magit and Git itself deserve to be called porcelains.
#+TEXINFO: @noindent
-This manual is for Magit version 2.11.0 (2.11.0-411-g73ea37afb+1).
+This manual is for Magit version 2.11.0 (2.11.0-436-g3baeddd4c+1).
#+BEGIN_QUOTE
Copyright (C) 2015-2018 Jonas Bernoulli <jonas@bernoul.li>
@@ -1046,14 +1046,16 @@ then the previous visibility is preserved. The initial visibility of
certain sections can also be overwritten using the hook
~magit-section-set-visibility-hook~.
-- User Option: magit-section-cache-visibility-types
+- User Option: magit-section-cache-visibility
This option controls for which sections the previous visibility
state should be restored if a section disappears and later appears
- again. The value is a list of section types.
+ again. The value is a boolean or a list of section types. If t,
+ then the visibility of all sections is cached. Otherwise this is
+ only done for sections whose type matches one of the listed types.
- This requires that ~magit-section-cached-visibility~ is a member of
- ~magit-section-set-visibility-hook~.
+ This requires that the function ~magit-section-cached-visibility~ is
+ a member of ~magit-section-set-visibility-hook~.
- Variable: magit-section-set-visibility-hook
diff --git a/Documentation/magit.texi b/Documentation/magit.texi
index ddfcb14..9fb4fbe 100644
--- a/Documentation/magit.texi
+++ b/Documentation/magit.texi
@@ -30,7 +30,7 @@ General Public License for more details.
@finalout
@titlepage
@title Magit User Manual
-@subtitle for version 2.11.0 (2.11.0-411-g73ea37afb+1)
+@subtitle for version 2.11.0 (2.11.0-436-g3baeddd4c+1)
@author Jonas Bernoulli
@page
@vskip 0pt plus 1filll
@@ -52,7 +52,7 @@ directly from within Emacs. While many fine Git clients exist, only
Magit and Git itself deserve to be called porcelains.
@noindent
-This manual is for Magit version 2.11.0 (2.11.0-411-g73ea37afb+1).
+This manual is for Magit version 2.11.0 (2.11.0-436-g3baeddd4c+1).
@quotation
Copyright (C) 2015-2018 Jonas Bernoulli <jonas@@bernoul.li>
@@ -1511,14 +1511,16 @@ then the previous visibility is preserved. The initial visibility of
certain sections can also be overwritten using the hook
@code{magit-section-set-visibility-hook}.
-@defopt magit-section-cache-visibility-types
+@defopt magit-section-cache-visibility
This option controls for which sections the previous visibility
state should be restored if a section disappears and later appears
-again. The value is a list of section types.
+again. The value is a boolean or a list of section types. If t,
+then the visibility of all sections is cached. Otherwise this is
+only done for sections whose type matches one of the listed types.
-This requires that @code{magit-section-cached-visibility} is a member of
-@code{magit-section-set-visibility-hook}.
+This requires that the function @code{magit-section-cached-visibility} is
+a member of @code{magit-section-set-visibility-hook}.
@end defopt
@defvar magit-section-set-visibility-hook
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 0acaa7f..3d76800 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -999,13 +999,6 @@ for a revision."
(expand-file-name (file-name-as-directory module))))
(unless (magit-rev-verify-commit rev)
(user-error "%s is not a commit" rev))
- (-when-let (buffer (magit-mode-get-buffer 'magit-revision-mode))
- (with-current-buffer buffer
- (let ((prev (car magit-refresh-args)))
- (unless (equal rev prev)
- (dolist (child (cdr (oref magit-root-section children)))
- (when (magit-file-section-p child)
- (magit-section-cache-visibility child)))))))
(magit-mode-setup #'magit-revision-mode rev nil args files)))
;;;; Setting commands
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 84dcc23..1db9c61 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -110,12 +110,22 @@ hardcoded section specific default (see `magit-insert-section')."
:options '(magit-diff-expansion-threshold
magit-section-cached-visibility))
-(defcustom magit-section-cache-visibility-types
- '(unpulled unpushed untracked unstaged staged)
- "List of section types for which visibility should be cached."
+(defcustom magit-section-cache-visibility t
+ "Whether to cache visibility of sections.
+
+Sections always retain their visibility state when they are being
+recreated during a refresh. But if a section disappears and then
+later reappears again, then this option controls whether this is
+the case.
+
+If t, then cache the the visibility of all sections. If a list
+of section types, then only do so for matching sections. If nil,
+then don't do so for any sections."
:package-version '(magit . "2.12.0")
:group 'magit-section
- :type '(repeat symbol))
+ :type '(choice (const :tag "Don't cache visibility" nil)
+ (const :tag "Cache visibility of all sections" t)
+ (repeat :tag "Cache visibility for section types" symbol)))
(defface magit-section-highlight
'((((class color) (background light)) :background "grey95")
@@ -1039,8 +1049,9 @@ invisible."
(cl-defun magit-section-maybe-cache-visibility
(&optional (section magit-insert-section--current))
- (when (memq (oref section type)
- magit-section-cache-visibility-types)
+ (when (or (eq magit-section-cache-visibility t)
+ (memq (oref section type)
+ magit-section-cache-visibility))
(magit-section-cache-visibility section)))
(defun magit-preserve-section-visibility-cache ()