all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* kill-matching-buffers
@ 2007-03-30 14:23 sds
  2007-03-30 16:14 ` kill-matching-buffers Chong Yidong
  2007-03-31  7:19 ` kill-matching-buffers Richard Stallman
  0 siblings, 2 replies; 4+ messages in thread
From: sds @ 2007-03-30 14:23 UTC (permalink / raw)
  To: emacs-devel

I find the appended patch quite usefull.
is this functionality already available elsewhere or are there any other
objections to this patch?

-- 
Sam Steingold (http://www.podval.org/~sds) on Fedora Core release 5 (Bordeaux)
http://mideasttruth.com http://jihadwatch.org http://truepeace.org
http://iris.org.il http://dhimmi.com http://openvotingconsortium.org
Cannot handle the fatal error due to a fatal error in the fatal error handler.


--- files.el	26 Mar 2007 09:30:01 -0400	1.892
+++ files.el	30 Mar 2007 10:19:59 -0400	
@@ -4355,6 +4355,14 @@
 	    (message "No files can be recovered from this session now")))
       (kill-buffer buffer))))
 
+(defun kill-buffer-ask (buffer)
+  "Kill buffer if confirmed."
+  (when (yes-or-no-p
+         (format "Buffer %s %s.  Kill? " (buffer-name buffer)
+                 (if (buffer-modified-p buffer)
+                     "HAS BEEN EDITED" "is unmodified")))
+    (kill-buffer buffer)))
+
 (defun kill-some-buffers (&optional list)
   "Kill some buffers.  Asks the user whether to kill each one of them.
 Non-interactively, if optional argument LIST is non-nil, it
@@ -4369,14 +4377,21 @@
 					; if we killed the base buffer.
 	   (not (string-equal name ""))
 	   (/= (aref name 0) ?\s)
-	   (yes-or-no-p
-	    (format "Buffer %s %s.  Kill? "
-		    name
-		    (if (buffer-modified-p buffer)
-			"HAS BEEN EDITED" "is unmodified")))
-	   (kill-buffer buffer)))
+	   (kill-buffer-ask buffer)))
     (setq list (cdr list))))
 \f
+(defun kill-matching-buffers (regexp &optional internal-too)
+  "Kill buffers whose name matches the specified regexp.
+The optional second argument indicates whether to kill internal buffers too."
+  (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)))))
+
+\f
 (defun auto-save-mode (arg)
   "Toggle auto-saving of contents of current buffer.
 With prefix argument ARG, turn auto-saving on if positive, else off."

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

end of thread, other threads:[~2007-04-02  2:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-30 14:23 kill-matching-buffers sds
2007-03-30 16:14 ` kill-matching-buffers Chong Yidong
2007-04-02  2:15   ` kill-matching-buffers Miles Bader
2007-03-31  7:19 ` kill-matching-buffers Richard Stallman

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.