Reputation: 3821
Normally I want ido
to ignore all non-user buffers, i.e. all buffers which start with a *
. I have achieved this using the following setting:
(setq ido-ignore-buffers '("\\` " "^\*"))
However, this poses a problem when working with a shell or an interpreter, e.g. ielm
, where the interaction buffer is named *ielm*
. Obviously adding all buffers to be ignored manually is not really an option because the list can get quite long with a lot of different emacs packages loaded. I know about C-a
which disabled the ignore pattern from within ido
, however, I don't want to hit C-a
every time I switch to an ielm
buffer.
My question is:
Is there some variable which allows to specify buffers which ido should not ignore (although they match the normal ignore list)? Or is there some other approach for solving this?
Upvotes: 4
Views: 1260
Reputation: 2518
The list that the ido-ignore-buffers
variable points to may contain not only regular expressions but also functions (any mix of them, actually). It's easy to provide a function to filter out all non-user buffers except *ielm*
:
(defun ido-ignore-non-user-except-ielm (name)
"Ignore all non-user (a.k.a. *starred*) buffers except *ielm*."
(and (string-match "^\*" name)
(not (string= name "*ielm*"))))
(setq ido-ignore-buffers '("\\` " ido-ignore-non-user-except-ielm))
Here's an example of having multiple unignored buffer names:
(setq my-unignored-buffers '("*ielm*" "*scratch*" "*foo*" "*bar*"))
(defun my-ido-ignore-func (name)
"Ignore all non-user (a.k.a. *starred*) buffers except those listed in `my-unignored-buffers'."
(and (string-match "^\*" name)
(not (member name my-unignored-buffers))))
(setq ido-ignore-buffers '("\\` " my-ido-ignore-func))
An interesting example of using ignore functions can be found among comments in the ido.el
source code (I've removed ;;
at the beginning of each line):
(defun ido-ignore-c-mode (name)
"Ignore all c mode buffers -- example function for ido."
(with-current-buffer name
(derived-mode-p 'c-mode)))
Basically, once you've got buffer name, you can do any checking/ignoring you want.
Upvotes: 5