The display-buffer function seems to be used quite heavily within Emacs. It has a lot of options to determine where to open a new buffer (a new window, a new frame, an existing window, etc).

Emacs introduced a concept of tabs in 27.1. However, there doesn't appear to be an easy way to tell display-buffer that you want new buffers to open in a tab, instead of just a new window.

Is there some way to configure display-buffer to open all buffers in a new (or existing?) tab?

The solution from NickD suggests using a function like display-buffer-in-tab.

I was able to get this working by setting display-buffer-base-action like the following:

(setq display-buffer-base-action '(display-buffer-in-tab))

However, this doesn't seem to play nicely with functions like help and magit-status. They tend to open up too many tabs every time they are run.

More specific settings may be necessary per command or per new buffer.

1 Answer 1


There is display-buffer-in-new-tab. Its doc string says:

display-buffer-in-new-tab is a compiled Lisp function in ‘tab-bar.el’.

(display-buffer-in-new-tab BUFFER ALIST)

Display BUFFER in a new tab.
ALIST is an association list of action symbols and values.  See
Info node ‘(elisp) Buffer Display Action Alists’ for details of
such alists.

Like ‘display-buffer-in-tab’, but always creates a new tab unconditionally,
without checking if a suitable tab already exists.

If ALIST contains a ‘tab-name’ entry, it creates a new tab with that name
and displays BUFFER in a new tab.  The ‘tab-name’ entry can be a function,
then it is called with two arguments: BUFFER and ALIST, and should return
the tab name.  When a ‘tab-name’ entry is omitted, create a new tab without
an explicit name.

This is an action function for buffer display, see Info
node ‘(elisp) Buffer Display Action Functions’.  It should be
called only by ‘display-buffer’ or a function directly or
indirectly called by the latter.


EDIT: I found this by using the Emacs help system. I don't use tab-bar-mode and I didn't know about this beforehand, but doing C-h f display-buffer-TAB shows me a completion buffer. Quickly scanning that, I found display-buffer-in-tab and display-buffer-in-new-tab. I chose the latter and got the doc string that I pasted above.

If the completion buffer is too long to scan easily by eye, you can switch to the buffer with C-x o and then just search e.g. for tab in the buffer using C-s.

Learning to use Help and also learning to search through the manuals with Info is an excellent investment of your time.

  • 1
    Could you add an explanation on how you figured this out? I would ideally like to be able to figure out this sort of thing for myself without having to ask every time, but I'm not sure how to go about this. Did you just guess that there would be a tab-related display-buffer-XXX command?
    – illabout
    Commented Nov 11, 2020 at 13:53
  • 2
    Edited the answer with the requested info
    – NickD
    Commented Nov 11, 2020 at 14:41

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.