emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#27286: closed (25.2; kill-matching-buffers without


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#27286: closed (25.2; kill-matching-buffers without confirmation)
Date: Tue, 20 Jun 2017 01:37:02 +0000

Your message dated Mon, 19 Jun 2017 21:35:53 -0400
with message-id <address@hidden>
and subject line Re: bug#27286: 25.2; kill-matching-buffers without confirmation
has caused the debbugs.gnu.org bug report #27286,
regarding 25.2; kill-matching-buffers without confirmation
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
27286: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27286
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 25.2; kill-matching-buffers without confirmation Date: Thu, 8 Jun 2017 14:56:17 +0000 (UTC)
Hi there:

Please add a clean way for 'kill-matching-buffers' to not ask for
confirmation. I need this for non-interactive usage.

The work-around usually proposed involves using 'flet' or some other hack, like
copying and modifying an Emacs internal function (which could change in
the future, thus breaking your copy).

I was advised to create this bug so that it "gets more traction".

I have already discussed this enhancement with the Emacs developers, and
I think that there was consensus that this feature would be useful. More 
detailed
information is in this mailing list thread:

Mailing list: emacs-devel
Subject: kill-matching-buffers without confirmation
Date: Mon, 22 May 2017 16:28:10 +0000 (UTC)
URL: https://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00625.html

Many thanks in advance,
  rdiez



--- End Message ---
--- Begin Message --- Subject: Re: bug#27286: 25.2; kill-matching-buffers without confirmation Date: Mon, 19 Jun 2017 21:35:53 -0400 User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
Version: 26.1

I applied the following, though I was tempted to say that this function
should only be used interactively, and that if you want some other
behaviour, you should code your own function.

commit 70d01da
Date:   Mon Jun 19 21:31:50 2017 -0400

    kill-matching-buffers to optionally not confirm
    
    * lisp/files.el (kill-matching-buffers):
    Add option to not confirm killing.  (Bug#27286)

diff --git a/lisp/files.el b/lisp/files.el
index 2930f30..06f49bb 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6077,16 +6077,18 @@ specifies the list of buffers to kill, asking for 
approval for each one."
           (kill-buffer-ask buffer)))
     (setq list (cdr list))))
 
-(defun kill-matching-buffers (regexp &optional internal-too)
+(defun kill-matching-buffers (regexp &optional internal-too no-ask)
   "Kill buffers whose name matches the specified REGEXP.
-The optional second argument indicates whether to kill internal buffers too."
+Ignores buffers whose name starts with a space, unless optional
+prefix argument INTERNAL-TOO is non-nil.  Asks before killing
+each buffer, unless NO-ASK is non-nil."
   (interactive "sKill buffers matching this regular expression: \nP")
   (dolist (buffer (buffer-list))
     (let ((name (buffer-name buffer)))
       (when (and name (not (string-equal name ""))
                  (or internal-too (/= (aref name 0) ?\s))
                  (string-match regexp name))
-        (kill-buffer-ask buffer)))))
+        (funcall (if no-ask 'kill-buffer 'kill-buffer-ask) buffer)))))
 
 
 (defun rename-auto-save-file ()


--- End Message ---

reply via email to

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