0

In xemacs, how do I kill buffers matching a certain pattern? I tried "kill-matching-buffers", but my xemacs doesn't appear to have that. What .el/.elc file do I need to load/eval-buffer to get this function?

I'd also settle for a way to sort of filter the buffer list so I can see just the buffers I want to delete, or get them next to each other via sort.

1 Answer 1

0

kill-matching-buffers code is as follows. You should be able to make it work with XEmacs with minimal effort.

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

And if you need definition for dolist (don't know if it is XEmacs), check cl-macs.el

2
  • Awesome! It turns out xemacs doesn't have a kill-buffer-ask function, but I changed that to kill-buffer and it worked fine, even though it didn't prompt me on a per buffer basis (the xemacs documentation suggests it should have asked me, but it didn't)
    – user354134
    Oct 22, 2012 at 17:05
  • 1
    Glad it worked for you. kill-buffer probably asks for confirmation only when invoked interactively. Oct 22, 2012 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.