Function: tab-bar-switch-to-tab
tab-bar-switch-to-tab is an interactive and byte-compiled function
defined in tab-bar.el.gz.
Signature
(tab-bar-switch-to-tab NAME)
Documentation
Switch to the tab by NAME.
Default values are tab names sorted by recency, so you can use M-n (next-history-element)
to get the name of the most recently visited tab, the second
most recent, and so on.
When the tab with that NAME doesn't exist, create a new tab
and rename it to NAME.
Key Bindings
Aliases
tab-switch
tab-bar-select-tab-by-name
Source Code
;; Defined in /usr/src/emacs/lisp/tab-bar.el.gz
(defun tab-bar-switch-to-tab (name)
"Switch to the tab by NAME.
Default values are tab names sorted by recency, so you can use \
\\<minibuffer-local-map>\\[next-history-element]
to get the name of the most recently visited tab, the second
most recent, and so on.
When the tab with that NAME doesn't exist, create a new tab
and rename it to NAME."
(interactive
(let* ((recent-tabs (mapcar (lambda (tab)
(alist-get 'name tab))
(tab-bar--tabs-recent))))
(list (completing-read (format-prompt "Switch to tab by name"
(car recent-tabs))
recent-tabs nil nil nil nil recent-tabs))))
(let ((tab-index (tab-bar--tab-index-by-name name)))
(if tab-index
(tab-bar-select-tab (1+ tab-index))
(tab-bar-new-tab)
(tab-bar-rename-tab name))))