From Newsgroup: gnu.emacs.help
* Matto Fransen <
mattof@sdf.org>
| After such a session I end up with a lot of eww buffers,
| labeled *eww*<2>, *eww*<3>, and so on.
| - Is there a way to prevent the build-up of those buffers?
| - Is there a way to quickly close all of the eww-buffers?
Here is what I use to get rid of unchanged buffers.
It should be easily adapted to kill only *eww* buffers:
;; Kill any unchanged buffers
(defconst kill-unchanged-buffers-dont-kill
(list (regexp-quote "*scratch*")
(regexp-quote "*info*")
(regexp-quote "*Async Shell Command*")
)
"List of buffer names regexps which should NOT be killed by `kill-unchanged-buffers'.
The regexps are anchored against beginning of buffer name.")
;; modified from a suggestion by Ralph Finch
(defun kill-unchanged-buffers ()
"Kill all unchanged buffers."
(interactive)
(let ((list (buffer-list)) (count 0))
(while list
(let* ((buffer (car list))
(name (buffer-name buffer)))
(and (not (string-equal name ""))
(not (delq nil (mapcar (lambda (elt) (string-match (concat "\\`" elt) name))
kill-unchanged-buffers-dont-kill)))
(/= (aref name 0) ? )
(if (buffer-modified-p buffer)
nil (kill-buffer buffer) (setq count (1+ count)))))
(setq list (cdr list)))
(message "Killed %d %s." count (if (/= count 1) "buffers" "buffer"))))
I have bound it on C-x C-k.
(global-set-key "\C-x\C-k" 'kill-unchanged-buffers)
HTH
R'
--- Synchronet 3.21d-Linux NewsLink 1.2