[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: undo-kill-buffer

From: Drew Adams
Subject: RE: undo-kill-buffer
Date: Wed, 25 Oct 2006 09:05:08 -0700

    I use this when I'm "done with a project":
    (defun kill-buffers-by-regexp (REG &optional AUTO)
      "Offer to kill each buffer whose name matches REG.
    If AUTO is non-nil, kill all such buffers, prompting only if a
    buffer needs saving." ...)

Along similar lines, with Icicles you can do that easily:

1. Type a regexp to the `C-x k' prompt for a buffer name.
2. Hit `S-TAB' to show all buffers that match, in *Completions*.
3. Pick matching buffers to kill - several ways:

   a. `C-!' to kill all matching buffers.
   b. `C-mouse-2' in *Completions* to kill buffers by clicking
      - kill any number of them.
   c. Cycle among the matching buffers with `next' and `prior',
      and use `C-RET' to kill selected candidates during
      cycling - kill any number of them.
   d. Use `C-next' and `C-prior' to kill selected buffer
      and cycle to the next - kill any number of them.

IOW, `C-x k' is a multi-command: you can kill multiple matching buffers in
the same invocation of `C-x k'. You can change the regexp on the fly to
continue killing buffers with names that match a different pattern.
*Completions* is updated as you type in the minibuffer, so it tracks your
input with the names that match.

The exact same thing applies to files and directories, using command
`icicle-delete-file' instead of `C-x k' (`icicle-kill-buffer').

And the same thing applies to windows showing a buffer, using `C-x 0'
(`icicle-delete-window'). With no prefix arg, it just deletes the current
window. With `C-u', it prompts for a buffer name, to delete all windows
showing the buffer. You treat the buffer name using completion, just like
`C-x k', so you can delete all windows showing any selection of buffers, or
all buffers, that match a regexp.

It is easy to define multi-commands like these, BTW. Here is the definition
of `icicle-delete-file':

 icicle-delete-file              ; Command name
 "Delete a file or directory."   ; Doc string
 icicle-delete-file-or-directory ; Function to perform action
 "Delete file or directory: "    ; `read-file-name' args
 default-directory nil t)

(defun icicle-delete-file-or-directory (file)
  "Delete file (or directory) FILE."
  (if (eq t (car (file-attributes file)))
      (delete-directory file)
    (delete-file file)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]