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

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

[nongnu] elpa/git-commit 430a52c4b3: magit-mode-bury-buffer: Tweak behav


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 430a52c4b3: magit-mode-bury-buffer: Tweak behavior and improve documentation
Date: Mon, 27 Mar 2023 16:00:40 -0400 (EDT)

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

    magit-mode-bury-buffer: Tweak behavior and improve documentation
    
    When killing all buffers, then also use `kill-buffer' explicitly to
    kill the current buffer.  That shouldn't make a difference, but if
    an odd value is used for `magit-bury-buffer-function', then it might.
---
 docs/magit.org     | 13 ++++++++-----
 docs/magit.texi    | 13 ++++++++-----
 lisp/magit-mode.el | 23 +++++++++++------------
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/docs/magit.org b/docs/magit.org
index 27d5051c80..e9a51467ef 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -578,11 +578,14 @@ buffers whose major-modes derive from ~magit-mode~.
 
 - Key: q (magit-mode-bury-buffer) ::
 
-  This command buries the current Magit buffer.
-
-  With a prefix argument, it instead kills the buffer.  With a double
-  prefix argument, also kills all other Magit buffers associated with
-  the current project.
+  This command buries or kills the current Magit buffer.  The function
+  specified by option ~magit-bury-buffer-function~ is used to bury the
+  buffer when called without a prefix argument or to kill it when
+  called with a single prefix argument.
+
+  When called with two or more prefix arguments then it always kills
+  all Magit buffers, associated with the current project, including
+  the current buffer.
 
 - User Option: magit-bury-buffer-function ::
 
diff --git a/docs/magit.texi b/docs/magit.texi
index 0f134e69aa..b6b9ba5aef 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -947,11 +947,14 @@ control how buffer names are uniquified.
 @item @kbd{q} (@code{magit-mode-bury-buffer})
 @kindex q
 @findex magit-mode-bury-buffer
-This command buries the current Magit buffer.
-
-With a prefix argument, it instead kills the buffer.  With a double
-prefix argument, also kills all other Magit buffers associated with
-the current project.
+This command buries or kills the current Magit buffer.  The function
+specified by option @code{magit-bury-buffer-function} is used to bury the
+buffer when called without a prefix argument or to kill it when
+called with a single prefix argument.
+
+When called with two or more prefix arguments then it always kills
+all Magit buffers, associated with the current project, including
+the current buffer.
 @end table
 
 @defopt magit-bury-buffer-function
diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index 77b5286562..83b0a85de6 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -903,19 +903,18 @@ latter is displayed in its place."
 ;;; Bury Buffer
 
 (defun magit-mode-bury-buffer (&optional kill-buffer)
-  "Bury the current buffer.
-With a prefix argument, kill the buffer instead.
-With two prefix arguments, also kill all Magit buffers associated
-with this repository.
-This is done using `magit-bury-buffer-function'."
+  "Bury or kill the current buffer.
+
+Use `magit-bury-buffer-function' to bury the buffer when called
+without a prefix argument or to kill it when called with a single
+prefix argument.
+
+With two prefix arguments, always kill the current and all other
+Magit buffers, associated with this repository."
   (interactive "P")
-  ;; Kill all associated Magit buffers when a double prefix arg is given.
-  (when (>= (prefix-numeric-value kill-buffer) 16)
-    (let ((current (current-buffer)))
-      (dolist (buf (magit-mode-get-buffers))
-        (unless (eq buf current)
-          (kill-buffer buf)))))
-  (funcall magit-bury-buffer-function kill-buffer))
+  (if (>= (prefix-numeric-value kill-buffer) 16)
+      (mapc #'kill-buffer (magit-mode-get-buffers))
+    (funcall magit-bury-buffer-function kill-buffer)))
 
 (defun magit-mode-quit-window (kill-buffer)
   "Quit the selected window and bury its buffer.



reply via email to

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