In Doom Emacs many commands that replace the buffer in the current window with a different buffer will automatically select the most recent buffer that you have had open in a window. But buffers that are not visiting files, such as *Messages*, *Scratch*, *term*, and *shell* will never be considered the most recent.

This is how it seems to work:
All buffers are in a stack. Buffers currently currently being displayed in windows are put on the bottom of the stack because you don't need to select them. When a buffer in a window is replaced by another buffer it is put on the top of the stack. When you execute one of the buffer switching commands, the default selection is whichever buffer is on top of the stack. But for some reason buffers that aren't visiting files are either inserted lower in the stack or skipped over when deciding the default selection even though they are on top of the stack.

These are some of the commands I've found that behave this way: ivy-switch-buffer, counsel-switch-buffer, ido-switch-buffer, mode-line-other-buffer

I've found that helm-buffers-list and helm-mini have a more consistent behavior with all buffers regardless of whether they are visiting a file or not. They will allow, for example, a term buffer to be the default selection when it is the most recently hidden buffer.

I've found that removing the asterisks from the buffer name has no affect and the mode of the buffer does not seem to matter.

  • doom-version is 2.0.9
    – kevincasey
    Mar 20, 2021 at 17:54

1 Answer 1


I found that the behavior is caused by two of the functions in doom-unreal-buffer-functions and can be prevented by redefining the variable without those functions, like this:

(setq doom-unreal-buffer-functions '(minibufferp))

These are the two functions that were removed:

(doom-special-buffer-p BUF)

Returns non-nil if BUF's name starts and ends with an *.

(doom-non-file-visiting-buffer-p BUF)

Returns non-nil if BUF does not have a value for buffer-file-name.

I found the answer in this github issue:

I haven't yet found any documentation about the concepts of real or unreal buffers in Doom Emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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