[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: delete unneeded buffers
From: |
weber |
Subject: |
Re: delete unneeded buffers |
Date: |
Tue, 19 Aug 2008 13:14:57 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Aug 19, 5:03 pm, "Drew Adams" <drew.ad...@oracle.com> wrote:
> > does anyone know of a good way to kill unneeded buffers?
> > I think of something which kills all unvisible dired
> > buffers. Would be nice, if anyone has a suggestion.
>
> Some possibilities:
>
> * `C-x C-b', then mark the buffers you want to delete, then `x'.
>
> * Use `ibuffer', then mark buffers by regexp or in other ways, then `x'. You
> can
> mark by matching a regexp against buffer name, mode (e.g. Dired), or filename.
>
> * In Icicles, `C-x k', then filter buffers (e.g. by regexp), then `C-!' (act
> on
> all).
>
> * Define your own Icicles multi-command that kills invisible Dired buffers -
> they are the only possible completion candidates:
>
> (icicle-define-command kill-invisible-dired-buffer
> "Kill invisible Dired buffer(s)."
> kill-buffer "Kill buffer: "
> (mapcar (lambda (b) (list (buffer-name b)))
> (buffer-list))
> (lambda (b)
> (let ((buf (get-buffer (car b))))
> (and (bufferp buf)
> (not (get-buffer-window buf 'visible))
> (with-current-buffer buf
> (eq major-mode 'dired-mode)))))
> t)
>
> Or, better, to be sure *Completions* is updated properly after killing one or
> more buffers, use this in the definition, in place of `kill-buffer':
>
> (lambda (b) (kill-buffer b) (icicle-complete-again-update))
>
> With this command, completion candidates are the invisible Dired buffers. Your
> minibuffer input at the prompt matches some of the buffers - it can be a
> regexp.
> (Empty input matches all candidates.)
>
> Use `C-!' to kill all buffers that match. Or click `C-mouse-2' in *Completions
> to kill individual buffers (or cycle with the arrow keys and use `C-RET').
>
> You can also select a bunch of candidates with the mouse and then act on them.
> There are lots of possibilities
> -http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Candidate_Sets.
>
> The real point is that such a command is easy for *you* to define. You just
> supply:
>
> * the command name
>
> * the action function: what `C-mouse-2' or `C-RET' does to a single candidate,
> and what `C-!' does to each matching candidate
>
> * the usual arguments to `completing-read':
>
> - prompt string
> - collection of possible candidates
> - predicate to filter those candidates
> - flag saying whether input must match (strict vs lax completion)
Another option if you are just bothered with a bunch of *name* buffers
is to customize emacs so they are hidden. I use ido, so i customize
ido-ignore-buffers to achieve that.