2

I set value of `ido-ignore-buffers' this way:

(defvar uki-ido-ignored-buffer-names '("*grep*" "*Messages*"))

(defun uki-ido-ignore-most-star-buffers (buffer)
    (member (buffer-name) uki-ido-ignored-buffer-names))


(eval-after-load 'ido
  '(setq ido-ignore-buffers
         (list "\\` " "^[ *\t]" "^\\*Org Src" "^\\*info" "^\\*magit:"
               #'uki-ido-ignore-most-star-buffers)))

But when I run (ido-switch-buffer), I see buffers beginning with "*Org Src" (visible in the following screenshot).

What my buffer selection looks like

Why does my regexp fail to "catch" it?

  • Your ignore function will ignore everything except *grep* and *Messages*. I assume you don't actually want that? Shouldn't uki-ido-ignore-most-star-buffers also check if the name begins with a *? You also shouldn't need the regexp ^[ *\t] since that already ignores everything starting with a *. In my quick testing both that regexp and your function ignore *Org Src ... * buffers. – glucas Dec 17 '14 at 19:16
  • fixed ignore function – Łukasz Gruner Dec 17 '14 at 19:18
  • The with-current-buffer shouldn't be necessary if the only thing you are testing is the name. – glucas Dec 17 '14 at 19:23
4

The way ido-ignore-buffers works is that each buffer is evaluated against each regexp or function in the list until one of them returns true, in which case the buffer is ignored. In your sample code you ignore everything that starts with a * using regexp. Buffers that do not start with * will be evaluated against your function, which ignores everything except *Messages* and *grep*. This combination means you are effectively ignoring every buffer name.

The reason you are seeing those *Org buffers is that ido will show ignored buffers if there are no matches against non-ignored buffers.

If you want to filter all buffers with names starting with a space or *, except for a few specific ones, this works for me:

(defvar ido-dont-ignore-buffer-names '("*grep*" "*Messages*"))

(defun ido-ignore-most-star-buffers (name)
  (and
   (string-match-p "^*" name)
   (not (member name ido-dont-ignore-buffer-names))))

(setq ido-ignore-buffers (list "\\` " #'ido-ignore-most-star-buffers))
  • I'm sorry but this doesn't work at all in my case (emacs 24.4.1 on OSX). I've tried with the most simple simple init.el possible ((ido-mode t) and your lines) – Paul Pichaureau Jan 27 '15 at 14:28
  • How does it behave for you? I'm running the same environment. – glucas Jan 27 '15 at 14:47
  • I tested with emacs -Q; pasted the above code in to *scratch* with one additional line at the end (ido-mode t). Then I did eval-buffer and created a bunch of test buffers like foo and *bar*. In this test ido-switch-buffer ignores all *xxx* buffers except for *Messages*, as expected. – glucas Jan 27 '15 at 14:53
  • Ok, if I do exactly as you in your last comment, the code works. I have to check that! Thanks for your time! – Paul Pichaureau Jan 27 '15 at 15:38
  • Sure. If emacs -Q works then perhaps you have some init / site init file being loaded with additional Ido settings. – glucas Jan 27 '15 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.