unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill
@ 2021-11-27 21:46 Matthias Meulien
  2021-11-28  7:03 ` Eli Zaretskii
       [not found] ` <handler.52148.B.16380496132406.ack@debbugs.gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Matthias Meulien @ 2021-11-27 21:46 UTC (permalink / raw)
  To: 52148

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


This is a feature request. I would find convenient and safer to list
buffers to kill when `project-kill-buffers' is called.

The attached patch is an attempt to implement this feature, inspired by
what I read in `save-buffers-kill-emacs' implementation.


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

From 2041a621ba5be0c4b2f563a554263b37d4192ce2 Mon Sep 17 00:00:00 2001
From: Matthias Meulen <orontee@gmail.com>
Date: Sat, 27 Nov 2021 22:43:20 +0100
Subject: [PATCH] `project-kill-buffers` displays list of buffers to kill

* lisp/progmodes/project.el (project-kill-buffers):
Temporarily display list of buffers to kill
---
 lisp/progmodes/project.el | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ed076a683d..0d8ed3646a 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1281,9 +1281,26 @@ project-kill-buffers
            (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)))
+          ((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
+                          (progn
+                            (setq confirm nil)
+                            (yes-or-no-p
+                             (format "Kill %d buffers in %s? "
+                                     (length bufs)
+                                     (project-root pr))))
+                        (when (window-live-p window)
+                          (quit-restore-window window 'kill))))))
            (mapc #'kill-buffer bufs)))))
 
 \f
-- 
2.30.2


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




In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
 of 2021-11-27 built on carbon
Repository revision: 338f7802373f1cfcc1b3749bbd46091fdef727f4
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure --with-native-compilation'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: fr_FR.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Shell

Minor modes in effect:
  highlight-changes-visible-mode: t
  goto-address-mode: t
  shell-dirtrack-mode: t
  minions-mode: t
  global-company-mode: t
  company-mode: t
  desktop-save-mode: t
  save-place-mode: t
  electric-pair-mode: t
  icomplete-mode: t
  global-so-long-mode: t
  global-auto-revert-mode: t
  auto-insert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-layout-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  window-divider-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/matthias/.config/emacs/elpa/transient-20211105.100/transient hides /usr/local/share/emacs/29.0.50/lisp/transient
/home/matthias/.config/emacs/elpa/dictionary-20201001.1727/dictionary hides /usr/local/share/emacs/29.0.50/lisp/net/dictionary

Features:
(shadow sort mail-extr gnus-msg emacsbug sendmail log-edit pcvs-util
smerge-mode diff whitespace cl-print mule-diag hl-line dabbrev misearch
multi-isearch pulse reftex-dcr reftex reftex-loaddefs reftex-vars
tex-mode mule-util shortdoc help-fns radix-tree add-log checkdoc
lisp-mnt url-http url-auth url-gw nsm mhtml-mode css-mode smie sgml-mode
typescript-mode yaml-mode hideshow cap-words superword subword js python
tramp-sh tramp tramp-loaddefs trampver tramp-integration files-x
tramp-compat ls-lisp follow view enriched disp-table facemenu dired-aux
bug-reference display-line-numbers hilit-chg vc-dir reveal flyspell
ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn
nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar
org-agenda ox-html table ox-ascii ox-publish ox goto-addr org-element
avl-tree ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info
ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe gnus-art
mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr kinsoku svg dom
ol-docview doc-view jka-compr image-mode exif ol-bibtex ol-bbdb ol-w3m
ol-doi org-link-doi vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs
vc-rcs vc bash-completion shell eglot array jsonrpc ert ewoc debug
backtrace flymake-proc flymake compile imenu company-oddmuse
company-keywords company-etags etags fileloop generator xref project
company-gtags company-dabbrev-code company-dabbrev company-files
company-clang company-capf company-cmake company-semantic
company-template company-bbdb avoid minions company pcase carbon-custom
cus-edit cus-load gnus-demon nntp gnus-group gnus-undo gnus-start
gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc
parse-time gnus-spec gnus-win nnoo gnus-int gnus-range message
yank-media rmc puny rfc822 mml mml-sec epa derived epg rfc6068
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader gnus nnheader gnus-util rmail rmail-loaddefs
rfc2047 rfc2045 ietf-drums mail-utils mm-util mail-prsvr wid-edit
gnus-dired dired-x dired dired-loaddefs org-capture org-refile org ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src
ob-comint org-pcomplete pcomplete comint ansi-color ring org-list
org-faces org-entities org-version ob-emacs-lisp ob-core ob-eval
org-table oc-basic bibtex iso8601 time-date ol org-keys oc org-compat
org-macs org-loaddefs format-spec find-func cal-menu calendar
cal-loaddefs dictionary link connection advice markdown-mode
edit-indirect color thingatpt noutline outline skeleton find-file vc-git
diff-mode easy-mmode vc-dispatcher ispell comp comp-cstr warnings rx
cl-extra help-mode desktop frameset server bookmark text-property-search
pp saveplace elec-pair icomplete so-long autorevert filenotify
autoinsert cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs generic-x face-remap proof-site
proof-autoloads info package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x
byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl
tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget keymap hashtable-print-readable backquote threads
dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 685836 76682)
 (symbols 48 40552 1)
 (strings 32 162716 13581)
 (string-bytes 1 5304884)
 (vectors 16 76386)
 (vector-slots 8 1642333 90680)
 (floats 8 721 1258)
 (intervals 56 23699 2008)
 (buffers 992 143))

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill
  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:21   ` Matthias Meulien
       [not found] ` <handler.52148.B.16380496132406.ack@debbugs.gnu.org>
  1 sibling, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2021-11-28  7:03 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: 52148

> From: Matthias Meulien <orontee@gmail.com>
> Date: Sat, 27 Nov 2021 22:46:31 +0100
> 
> This is a feature request. I would find convenient and safer to list
> buffers to kill when `project-kill-buffers' is called.
> 
> The attached patch is an attempt to implement this feature, inspired by
> what I read in `save-buffers-kill-emacs' implementation.

Thanks.  My suggestion is to make this display optional, since it
isn't clear that everyone would like such a buffer to pop up.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill
  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:21   ` Matthias Meulien
  1 sibling, 1 reply; 8+ messages in thread
From: Matthias Meulien @ 2021-11-28  8:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52148

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

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks.  My suggestion is to make this display optional, since it
> isn't clear that everyone would like such a buffer to pop up.

You're right.

Here is an updated patch. Not sure of the value of "package-version" I
should have used...

I also added a NEWS entry.


[-- 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: 3652 bytes --]

From 904f06bbfec2468a0417454f7d8dcdbbe5ff8434 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 | 38 ++++++++++++++++++++++++++++++++++----
 2 files changed, 38 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..47cd5d28d8 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1210,6 +1210,14 @@ 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."
+  :type 'boolean
+  :version "29.0"
+  :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 +1284,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))))))
     (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
+           (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
+                         (progn
+                           (setq confirm nil)
+                           (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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill
  2021-11-28  7:03 ` Eli Zaretskii
  2021-11-28  8:11   ` Matthias Meulien
@ 2021-11-28  8:21   ` Matthias Meulien
  1 sibling, 0 replies; 8+ messages in thread
From: Matthias Meulien @ 2021-11-28  8:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52148

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

Minor patch update to remove an unused variable.


[-- 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: 3567 bytes --]

From 22a88c638c0404a5d28b1904edac1462258d9a1e 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 | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 36 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..f845a01136 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1210,6 +1210,14 @@ 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."
+  :type 'boolean
+  :version "29.0"
+  :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 +1284,34 @@ 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))))))
     (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
+           (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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill
  2021-11-28  8:11   ` Matthias Meulien
@ 2021-11-28  8:33     ` Eli Zaretskii
  2021-11-28  8:42       ` Matthias Meulien
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2021-11-28  8:33 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: 52148

> From: Matthias Meulien <orontee@gmail.com>
> Cc: 52148@debbugs.gnu.org
> Date: Sun, 28 Nov 2021 09:11:52 +0100
> 
> Here is an updated patch. Not sure of the value of "package-version" I
> should have used...
> 
> I also added a NEWS entry.

Thanks.  A couple of minor comments below.

> +(defcustom project-kill-buffers-display-buffer-list nil
> +  "Non-nil to display list of buffers to kill before killing project buffers."

The doc string should mention 'project-kill-buffers' (not necessarily
in the first sentence), to make the context and domain of the option
more clear.

> +  :version "29.0"

This should be "29.1".  We never release NN.0 versions, the first
version of a major release is always NN.1.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill
  2021-11-28  8:33     ` Eli Zaretskii
@ 2021-11-28  8:42       ` Matthias Meulien
  0 siblings, 0 replies; 8+ messages in thread
From: Matthias Meulien @ 2021-11-28  8:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 52148

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

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks.  A couple of minor comments below.

Updated patch:


[-- 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: 3601 bytes --]

From fbb8829f93f7e898b3d243e9ed80101f0f0e1b8b 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 | 37 +++++++++++++++++++++++++++++++++----
 2 files changed, 37 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..14df03570d 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,34 @@ 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))))))
     (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
+           (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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#52148: Acknowledgement (29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill)
       [not found] ` <handler.52148.B.16380496132406.ack@debbugs.gnu.org>
@ 2021-11-28 20:25   ` Matthias Meulien
  2021-11-29 15:42     ` bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Matthias Meulien @ 2021-11-28 20:25 UTC (permalink / raw)
  To: 52148

[-- 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill
  2021-11-28 20:25   ` bug#52148: Acknowledgement (29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill) Matthias Meulien
@ 2021-11-29 15:42     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-29 15:42 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: 52148

Matthias Meulien <orontee@gmail.com> writes:

> Subject: [PATCH] project-kill-buffers can display list of buffers to kill

Thanks; applied to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-29 15:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` bug#52148: Acknowledgement (29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill) Matthias Meulien
2021-11-29 15:42     ` bug#52148: 29.0.50; [PATCH] Make `project-kill-buffers' display list of buffers to kill Lars Ingebrigtsen

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).