diff options
| author | Sam Steingold | 2007-06-03 18:51:42 +0000 |
|---|---|---|
| committer | Sam Steingold | 2007-06-03 18:51:42 +0000 |
| commit | a151f82c4396c7ad8de905ff97c52ff0405d2f8b (patch) | |
| tree | d38f7fbccae554bbcdad94c370075866bb8fc75b | |
| parent | b5d0f8f6d289e63c5f85a0f3a4b422c1f13ddc58 (diff) | |
| download | emacs-a151f82c4396c7ad8de905ff97c52ff0405d2f8b.tar.gz emacs-a151f82c4396c7ad8de905ff97c52ff0405d2f8b.zip | |
New command kill-matching-buffers kills buffers whose name matches a regexp.
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/files.el | 27 |
3 files changed, 29 insertions, 6 deletions
| @@ -28,6 +28,8 @@ with a prefix argument or by typing C-u C-h C-n. | |||
| 28 | 28 | ||
| 29 | * Editing Changes in Emacs 23.1 | 29 | * Editing Changes in Emacs 23.1 |
| 30 | 30 | ||
| 31 | ** New command kill-matching-buffers kills buffers whose name matches a regexp. | ||
| 32 | |||
| 31 | 33 | ||
| 32 | * New Modes and Packages in Emacs 23.1 | 34 | * New Modes and Packages in Emacs 23.1 |
| 33 | 35 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index baf1400232d..3d3bf598a78 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2007-06-03 Sam Steingold <sds@gnu.org> | ||
| 2 | |||
| 3 | * files.el (kill-buffer-ask): New function. | ||
| 4 | (kill-some-buffers): Use it. | ||
| 5 | (kill-matching-buffers): New user command. | ||
| 6 | |||
| 1 | 2007-06-01 David Kastrup <dak@gnu.org> | 7 | 2007-06-01 David Kastrup <dak@gnu.org> |
| 2 | 8 | ||
| 3 | * dired.el (dired-recursive-deletes, dired-recursive-copies): | 9 | * dired.el (dired-recursive-deletes, dired-recursive-copies): |
diff --git a/lisp/files.el b/lisp/files.el index 9ce1f0a0471..fc8256ba36e 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4389,6 +4389,14 @@ This command is used in the special Dired buffer created by | |||
| 4389 | (message "No files can be recovered from this session now"))) | 4389 | (message "No files can be recovered from this session now"))) |
| 4390 | (kill-buffer buffer)))) | 4390 | (kill-buffer buffer)))) |
| 4391 | 4391 | ||
| 4392 | (defun kill-buffer-ask (buffer) | ||
| 4393 | "Kill buffer if confirmed." | ||
| 4394 | (when (yes-or-no-p | ||
| 4395 | (format "Buffer %s %s. Kill? " (buffer-name buffer) | ||
| 4396 | (if (buffer-modified-p buffer) | ||
| 4397 | "HAS BEEN EDITED" "is unmodified"))) | ||
| 4398 | (kill-buffer buffer))) | ||
| 4399 | |||
| 4392 | (defun kill-some-buffers (&optional list) | 4400 | (defun kill-some-buffers (&optional list) |
| 4393 | "Kill some buffers. Asks the user whether to kill each one of them. | 4401 | "Kill some buffers. Asks the user whether to kill each one of them. |
| 4394 | Non-interactively, if optional argument LIST is non-nil, it | 4402 | Non-interactively, if optional argument LIST is non-nil, it |
| @@ -4403,13 +4411,20 @@ specifies the list of buffers to kill, asking for approval for each one." | |||
| 4403 | ; if we killed the base buffer. | 4411 | ; if we killed the base buffer. |
| 4404 | (not (string-equal name "")) | 4412 | (not (string-equal name "")) |
| 4405 | (/= (aref name 0) ?\s) | 4413 | (/= (aref name 0) ?\s) |
| 4406 | (yes-or-no-p | 4414 | (kill-buffer-ask buffer))) |
| 4407 | (format "Buffer %s %s. Kill? " | ||
| 4408 | name | ||
| 4409 | (if (buffer-modified-p buffer) | ||
| 4410 | "HAS BEEN EDITED" "is unmodified"))) | ||
| 4411 | (kill-buffer buffer))) | ||
| 4412 | (setq list (cdr list)))) | 4415 | (setq list (cdr list)))) |
| 4416 | |||
| 4417 | (defun kill-matching-buffers (regexp &optional internal-too) | ||
| 4418 | "Kill buffers whose name matches the specified regexp. | ||
| 4419 | The optional second argument indicates whether to kill internal buffers too." | ||
| 4420 | (interactive "sKill buffers matching this regular expression: \nP") | ||
| 4421 | (dolist (buffer (buffer-list)) | ||
| 4422 | (let ((name (buffer-name buffer))) | ||
| 4423 | (when (and name (not (string-equal name "")) | ||
| 4424 | (or internal-too (/= (aref name 0) ?\s)) | ||
| 4425 | (string-match regexp name)) | ||
| 4426 | (kill-buffer-ask buffer))))) | ||
| 4427 | |||
| 4413 | 4428 | ||
| 4414 | (defun auto-save-mode (arg) | 4429 | (defun auto-save-mode (arg) |
| 4415 | "Toggle auto-saving of contents of current buffer. | 4430 | "Toggle auto-saving of contents of current buffer. |