[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20463: 25.0.50; New deletion commands in buffer-menu [PATCH]
From: |
Filipp Gunbin |
Subject: |
bug#20463: 25.0.50; New deletion commands in buffer-menu [PATCH] |
Date: |
Fri, 08 May 2015 14:18:24 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (darwin) |
On 01/05/2015 13:56 -0400, Stefan Monnier wrote:
> As mentioned by someone else, we'd like to bring Ibuffer and buffer-menu
> closer to each other, in terms of code and behavior.
>
> So I'm not opposed to adding the kind of feature you're requesting, but
> as much as possible it should be done in a way that narrows the gap
> between buffer-menu and Ibuffer. Code reuse would be ideal.
Yes, that should be better than my proposal, I see.
I thought about what I really need once again and I see two cases:
1) kill all log files
2) kill all remote files opened via ssh - they have "/ssh:" in their
names
So I wrote this simple function. What do you think?
Sorry for the noise if no one is interested.
Filipp
diff --git a/lisp/files.el b/lisp/files.el
index ef6ac7b..a7b989f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5827,6 +5827,15 @@ The optional second argument indicates whether to kill
internal buffers too."
(string-match regexp name))
(kill-buffer-ask buffer)))))
+(defun kill-matching-buffers-file-name (regexp)
+ "Kill buffers whose visited file name matches the specified REGEXP."
+ (interactive "sKill buffers visiting files matching this regular expression:
")
+ (dolist (buffer (buffer-list))
+ (let ((file-name (buffer-file-name buffer)))
+ (when (and file-name
+ (string-match regexp file-name))
+ (kill-buffer-ask buffer)))))
+
(defun rename-auto-save-file ()
"Adjust current buffer's auto save file name for current conditions.