Function: kill-matching-buffers
kill-matching-buffers is an interactive and byte-compiled function
defined in files.el.gz.
Signature
(kill-matching-buffers REGEXP &optional INTERNAL-TOO NO-ASK)
Documentation
Kill buffers whose names match the regular expression REGEXP.
Interactively, prompt for REGEXP. Ignores buffers whose names start with a space, unless optional prefix argument INTERNAL-TOO(interactively, the prefix argument) is non-nil. Asks before killing each buffer, unless NO-ASK is non-nil.
Probably introduced at or before Emacs version 23.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun kill-matching-buffers (regexp &optional internal-too no-ask)
"Kill buffers whose names match the regular expression REGEXP.
Interactively, prompt for REGEXP.
Ignores buffers whose names start with a space, unless optional
prefix argument INTERNAL-TOO(interactively, the prefix argument)
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))
(funcall (if no-ask 'kill-buffer 'kill-buffer-ask) buffer)))))