Commit 6960a754 authored by Juri Linkov's avatar Juri Linkov

* lisp/tab-bar.el (display-buffer-in-tab): New function (bug#38354)

parent cffa5703
Pipeline #4173 failed with stage
in 66 minutes and 58 seconds
......@@ -1254,6 +1254,36 @@ in the selected frame."
(goto-char (posn-point (event-end event)))
(defun display-buffer-in-tab (buffer alist)
"Display BUFFER in a tab.
ALIST is an association list of action symbols and values. See
Info node `(elisp) Buffer Display Action Alists' for details of
such alists.
If ALIST contains a `name' entry, it creates a new tab with that name and
displays BUFFER in a new tab. If a tab with this name already exists, it
switches to that tab before displaying BUFFER. The `name' entry can be
a function, then it is called with two arguments: BUFFER and ALIST, and
should return the tab name. When a `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."
(let ((name (cdr (assq 'name alist))))
(when (functionp name)
(setq name (funcall name buffer alist)))
(if name
(let ((tab-index (tab-bar--tab-index-by-name name)))
(if tab-index
(tab-bar-select-tab (1+ tab-index))
(let ((tab-bar-new-tab-choice t))
(tab-bar-rename-tab name))))
(defun switch-to-buffer-other-tab (buffer-or-name &optional norecord)
"Switch to buffer BUFFER-OR-NAME in another tab.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment