Take the 2-minute tour ×

Several emacs extensions create "junk" buffers, and I have to manually remove them from various buffer lists.

Emacs has a concept of "hidden buffers", which is used for instance for the minibuffer.

How can I make an arbitrary buffer a hidden buffer?

share|improve this question
Wrong place to ask ... –  Ahmed Masud Jan 12 '12 at 21:15
@Ahmed Right place to ask, just really poorly written. –  Trey Jackson Jan 12 '12 at 21:20
@Trey Jackson Why? I thought it was pretty clear –  sabof Jan 12 '12 at 21:22
It's unclear what you consider to be junk buffers and why you need/want to remove them from lists. In other words, you describe a problem (w/out much detail) and then propose a solution, and ask how to implement the solution. That's why I consider it poorly written - you have two questions. 1) to fix the problem you want fixed, 2) how to make arbitrary buffers hidden. –  Trey Jackson Jan 12 '12 at 21:28
@TreyJackson: I think it's reasonable to assume that sabof knows which buffers he wants to make hidden, although he should specify if he wants to refer to them by name... Or to use some sort of trigger or hook to determine which one he wants to hide automatically. –  Arafangion Jan 13 '12 at 2:43
show 1 more comment

2 Answers

up vote 8 down vote accepted

Emacs does have a concept of uninteresting/hidden buffers - and designates them as such by making their names begin with a space. See the documentation for buffer names. You can make a buffer "uninteresting" by changing its name to begin with a space.

Try M-x make-buffer-uninteresting:

(defun make-buffer-uninteresting ()
  "rename the current buffer to begin with a space"
  (unless (string-match-p "^ " (buffer-name))
    (rename-buffer (concat " " (buffer-name)))))
share|improve this answer
One question: if you rename a buffer like this, how will the original extension know that you changed it. Or, equivalently, is there some easy way of hiding a buffer without confusing whatever extension is using it? –  Tikhon Jelvis Jan 12 '12 at 21:29
Presumably it will keep a reference to the buffer object somewhere, and will find it this way. Since the name changes if you open a second buffer that would have been named identically, the practice should be quite common –  sabof Jan 12 '12 at 21:37
@Tikhon - that's why I was saying the question was poorly written, this routine could break the extensions (whatever they are) if they're looking for buffers by name. If they keep track of the buffers by value, they're ok b/c only the name changed... –  Trey Jackson Jan 12 '12 at 21:44
add comment

If you enable ido (which you should because i don't know why you would use emacs without it), then you can configured which buffers are ignored using the ido-ignore-buffers list, which is a list of regex's specifying buffers to ignore for normal buffer switching. (really, you should be using ido if you aren't already).

share|improve this answer
add comment

Your Answer


