Last active
November 12, 2020 10:00
-
-
Save ivan4th/ee8f5e4abac13d581d2a037403d3c00b to your computer and use it in GitHub Desktop.
Kill Emacs buffers by path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; based on https://stackoverflow.com/a/32823597 | |
(defun killemall (regexp) | |
(interactive "sKill buffers with paths matching this regexp: ") | |
(dolist (buffer (buffer-list)) | |
(let ((name (or (buffer-file-name buffer) | |
(with-current-buffer buffer | |
(when (boundp 'dired-directory) | |
(if (consp dired-directory) | |
(car dired-directory) | |
dired-directory)))))) | |
(when (and name (not (string-equal name "")) | |
(string-match regexp name)) | |
(kill-buffer buffer))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment