branch: elpa/magit
commit 6195f952da0ed4b0a2dfcf58db4352111bba4df9
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-revision-use-dedicated-buffers: New option
    
    Closes #5330.
    Closes #5248.
---
 docs/CHANGELOG.4   |  2 ++
 docs/magit.org     | 18 ++++++++++++++++++
 docs/magit.texi    | 18 ++++++++++++++++++
 lisp/magit-diff.el | 38 +++++++++++++++++++++++++++++++++++---
 4 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/docs/CHANGELOG.4 b/docs/CHANGELOG.4
index 89b40cf4f6..87e463d5fb 100644
--- a/docs/CHANGELOG.4
+++ b/docs/CHANGELOG.4
@@ -63,6 +63,8 @@
 
 - Added new command ~magit-project-dispatch~.  #5163
 
+- Added new option ~magit-revision-use-dedicated-buffers~.  #5330, #5248
+
 Bugfixes:
 
 - ~magit-ignore-submodules-p~ didn't return ~nil~ for ~none~.
diff --git a/docs/magit.org b/docs/magit.org
index 41540aefc8..e92b977f3e 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -3711,6 +3711,24 @@ If the revision buffer is not displayed from a log 
buffer, the file
 restriction is determined as usual (see [[*Transient Arguments and
 Buffer Variables]]).
 
+- User Option: magit-revision-use-dedicated-buffers ::
+
+  Whether ~magit-show-commit~ uses a dedicated buffer for each revision.
+
+  If this is ~nil~, then each revision is initially displayed in the same
+  per-repository buffer.  You can then lock that buffer to the revision;
+  if you later display another revision, the locked buffer continues to
+  display the same revision as before and the new revision is displayed
+  in another bufer.
+
+  If this is ~t~, then each revision is displayed in a dedicated buffer.
+  A revision buffer is only reused (i.e., raised), if it already displays
+  the requested revision.  If you enable this, you will quickly accumulate
+  revision buffers and will have to find a way to keep that under control.
+  ~magit-{blame,log,status}-maybe-update-revision-buffer~ also will stop
+  working, if this is enabled.  For these reasons it is recommended, that
+  you do not enable this."
+
 ** Ediffing
 
 This section describes how to enter Ediff from Magit buffers.  For
diff --git a/docs/magit.texi b/docs/magit.texi
index 1950ca7891..6af84f2aac 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -4376,6 +4376,24 @@ if @code{--follow} is present in the log arguments.
 If the revision buffer is not displayed from a log buffer, the file
 restriction is determined as usual (see @ref{Transient Arguments and Buffer 
Variables}).
 
+@defopt magit-revision-use-dedicated-buffers
+Whether @code{magit-show-commit} uses a dedicated buffer for each revision.
+
+If this is @code{nil}, then each revision is initially displayed in the same
+per-repository buffer.  You can then lock that buffer to the revision;
+if you later display another revision, the locked buffer continues to
+display the same revision as before and the new revision is displayed
+in another bufer.
+
+If this is @code{t}, then each revision is displayed in a dedicated buffer.
+A revision buffer is only reused (i.e., raised), if it already displays
+the requested revision.  If you enable this, you will quickly accumulate
+revision buffers and will have to find a way to keep that under control.
+@code{magit-@{blame,log,status@}-maybe-update-revision-buffer} also will stop
+working, if this is enabled.  For these reasons it is recommended, that
+you do not enable this."
+@end defopt
+
 @node Ediffing
 @section Ediffing
 
diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index 484a6a02b6..5e4503bdf0 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -576,6 +576,26 @@ log's file filter is always honored."
   :group 'magit-revision
   :type 'boolean)
 
+(defcustom magit-revision-use-dedicated-buffers nil
+  "Whether `magit-show-commit' uses a dedicated buffer for each revision.
+
+If this is nil, then each revision is initially displayed in the same
+per-repository buffer.  You can then lock that buffer to the revision;
+if you later display another revision, the locked buffer continues to
+display the same revision as before and the new revision is displayed
+in another bufer.
+
+If this is t, then each revision is displayed in a dedicated buffer.
+A revision buffer is only reused (i.e., raised), if it already displays
+the requested revision.  If you enable this, you will quickly accumulate
+revision buffers and will have to find a way to keep that under control.
+`magit-{blame,log,status}-maybe-update-revision-buffer' also will stop
+working, if this is enabled.  For these reasons it is recommended, that
+you do not enable this."
+  :package-version '(magit . "4.6.1")
+  :group 'magit-revision
+  :type 'boolean)
+
 ;;;; Visit Commands
 
 (defcustom magit-diff-visit-prefer-worktree nil
@@ -1555,8 +1575,19 @@ the file or blob."
 ;;;###autoload
 (defun magit-show-commit (rev &optional args files module)
   "Visit the revision at point in another buffer.
-If there is no revision at point or with a prefix argument prompt
-for a revision."
+
+If there is no revision at point, or with a prefix argument, prompt
+for a revision.
+
+By default the same per-repository revision buffer is reused for all
+revision.  When you want to display multiple revisions at the same
+time, you can lock a revision buffer to its value, which prevents it
+from being reused to display another revision.
+
+Alternatively, you can use a dedicated buffer for every revision.
+To do so, enable `magit-revision-use-dedicated-buffers', but only
+after readings its docstring, to make sure you are can live with
+the trade-offs."
   (interactive
     (pcase-let* ((mcommit (magit-section-value-if 'module-commit))
                  (atpoint (or mcommit
@@ -2997,7 +3028,8 @@ Staging and applying changes is documented in info node
      '("--stat" "--no-ext-diff"))
 
 (defun magit-revision-setup-buffer (rev args files)
-  (magit-setup-buffer #'magit-revision-mode nil
+  (magit-setup-buffer #'magit-revision-mode
+      magit-revision-use-dedicated-buffers
     (magit-buffer-revision rev)
     (magit-buffer-diff-range (format "%s^..%s" rev rev))
     (magit-buffer-diff-type 'committed)

Reply via email to