Emacs-27.1 ships with a new
tab-bar-mode minor mode. This puts a tab bar at the top of each Emacs frame. Each tab in the tab bar can display multiple windows.
Emacs (and various packages) has many commands that open a buffer in a new window in the current frame.
How do I take an existing Emacs command that opens a buffer new window in the current frame and instead make it open a buffer in a new tab?
For instance, I often call the Magit function
magit-status. This function opens a new window to show the Magit status buffer. Instead of opening a new window, I'd like to open a new tab to show the Magit status buffer.
What are my options for opening buffers in new tabs instead of new windows?
I can imagine two general approaches:
Change some Emacs variable that makes all new windows open in new tabs. This would be an easy way to have all commands open buffers in new tabs, although quite heavy-handed.
Is there an Emacs variable I can set that will do this?
Create a function like
open-in-new-tabthat modifies any function given as an argument to open a buffer in a new tab instead of a new window.
For instance, if I want
magit-statusto open in a new tab, I would have to call it like
(open-in-new-tab 'magit-status). I could create a command for this, and bind it to some key.
How would I write this
open-in-new-tabfunction? (I'm somewhat new to Elisp.)
I imagine this
open-in-new-tabfunction would be similar to a function for modifying a command to open a buffer in a new frame instead of a new window.