unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Matthias Meulien <orontee@gmail.com>
To: 52148@debbugs.gnu.org
Subject: bug#52148: Acknowledgement (29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill)
Date: Sun, 28 Nov 2021 21:25:48 +0100	[thread overview]
Message-ID: <87fsrgkoxf.fsf@gmail.com> (raw)
In-Reply-To: <handler.52148.B.16380496132406.ack@debbugs.gnu.org> (GNU bug Tracking System's message of "Sat, 27 Nov 2021 21:47:02 +0000")

[-- Attachment #1: Type: text/plain, Size: 118 bytes --]

Patch update: After I introduced the user option, the code was broken
and buffers killed whatever the user answered.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-project-kill-buffers-can-display-list-of-buffers-to-.patch --]
[-- Type: text/x-diff, Size: 3704 bytes --]

From 65225000aabd1464bb81b655b5c0e7103bea4333 Mon Sep 17 00:00:00 2001
From: Matthias Meulien <orontee@gmail.com>
Date: Sat, 27 Nov 2021 22:43:20 +0100
Subject: [PATCH] project-kill-buffers can display list of buffers to kill

* lisp/progmodes/project.el
(project-kill-buffers-display-buffer-list): Option to toggle
temporarily display of the list of buffers to kill when calling
project-kill-buffers
(project-kill-buffers): Handle
project-kill-buffers-display-buffer-list option
---
 etc/NEWS                  |  4 ++++
 lisp/progmodes/project.el | 39 +++++++++++++++++++++++++++++++++++----
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 87a7a43a5e..2bc1e0046a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -427,6 +427,10 @@ it with new 'term-{faint,italic,slow-blink,fast-blink}' faces.
 *** 'project-find-file' and 'project-or-external-find-file' now accept
 a prefix argument which is interpreted to mean "include all files".
 
+*** 'project-kill-buffers' can display the list of buffers to kill.
+Customize the user option 'project-kill-buffers-display-buffer-list'
+to enable the display of the buffer list.
+
 +++
 *** New command 'xref-go-forward'.
 It is bound to 'C-M-,' and jumps to the location where 'xref-go-back'
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ed076a683d..fba9c7b2f5 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1210,6 +1210,15 @@ project-kill-buffer-conditions
   :group 'project
   :package-version '(project . "0.6.0"))
 
+(defcustom project-kill-buffers-display-buffer-list nil
+  "Non-nil to display list of buffers to kill before killing project buffers.
+Used by `project-kill-buffers'."
+  :type 'boolean
+  :version "29.1"
+  :group 'project
+  :package-version '(project . "0.8.1")
+  :safe #'booleanp)
+
 (defun project--buffer-list (pr)
   "Return the list of all buffers in project PR."
   (let ((conn (file-remote-p (project-root pr)))
@@ -1276,14 +1285,36 @@ project-kill-buffers
 interactively."
   (interactive)
   (let* ((pr (project-current t))
-         (bufs (project--buffers-to-kill pr)))
+         (bufs (project--buffers-to-kill pr))
+         (query-user (lambda ()
+                       (yes-or-no-p
+                        (format "Kill %d buffers in %s? "
+                                (length bufs)
+                                (project-root pr)))))
+         (confirm))
     (cond (no-confirm
            (mapc #'kill-buffer bufs))
           ((null bufs)
            (message "No buffers to kill"))
-          ((yes-or-no-p (format "Kill %d buffers in %s? "
-                                (length bufs)
-                                (project-root pr)))
+          (project-kill-buffers-display-buffer-list
+           (when
+               (with-current-buffer-window
+                   (get-buffer-create "*Buffer List*")
+                   `(display-buffer--maybe-at-bottom
+                     (dedicated . t)
+                     (window-height . (fit-window-to-buffer))
+                     (preserve-size . (nil . t))
+                     (body-function
+                      . ,#'(lambda (_window)
+                             (list-buffers-noselect nil bufs))))
+                   #'(lambda (window _value)
+                       (with-selected-window window
+                         (unwind-protect
+                             (funcall query-user)
+                           (when (window-live-p window)
+                             (quit-restore-window window 'kill))))))
+             (mapc #'kill-buffer bufs)))
+          ((funcall query-user)
            (mapc #'kill-buffer bufs)))))
 
 \f
-- 
2.30.2


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
Matthias

  parent reply	other threads:[~2021-11-28 20:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-27 21:46 bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill Matthias Meulien
2021-11-28  7:03 ` Eli Zaretskii
2021-11-28  8:11   ` Matthias Meulien
2021-11-28  8:33     ` Eli Zaretskii
2021-11-28  8:42       ` Matthias Meulien
2021-11-28  8:21   ` Matthias Meulien
     [not found] ` <handler.52148.B.16380496132406.ack@debbugs.gnu.org>
2021-11-28 20:25   ` Matthias Meulien [this message]
2021-11-29 15:42     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fsrgkoxf.fsf@gmail.com \
    --to=orontee@gmail.com \
    --cc=52148@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).