summaryrefslogtreecommitdiff
path: root/lisp/tab-bar.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2021-11-22 20:15:28 +0200
committerJuri Linkov <juri@linkov.net>2021-11-22 20:15:58 +0200
commiteef6626b55e59d4a76e8666108cc68a578fac793 (patch)
tree76743564282872391e738640abf244d7d713f633 /lisp/tab-bar.el
parentd096e12f447c1c67fe6fb6baa44212781d27ef53 (diff)
downloademacs-eef6626b55e59d4a76e8666108cc68a578fac793.tar.gz
* lisp/tab-bar.el: 'C-x t RET' creates a new tab for non-existent tab name.
* lisp/tab-bar.el (tab-bar-switch-to-tab): Create a new tab and rename it to NAME when can't find the tab with the given NAME (bug#51935).
Diffstat (limited to 'lisp/tab-bar.el')
-rw-r--r--lisp/tab-bar.el10
1 files changed, 8 insertions, 2 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index d331f29194d..656cb878e3e 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1196,7 +1196,9 @@ Interactively, ARG is the prefix numeric argument and defaults to 1."
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."
+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))
@@ -1204,7 +1206,11 @@ most recent, and so on."
(list (completing-read (format-prompt "Switch to tab by name"
(car recent-tabs))
recent-tabs nil nil nil nil recent-tabs))))
- (tab-bar-select-tab (1+ (or (tab-bar--tab-index-by-name name) 0))))
+ (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))))
(defalias 'tab-bar-select-tab-by-name 'tab-bar-switch-to-tab)