From eef6626b55e59d4a76e8666108cc68a578fac793 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 22 Nov 2021 20:15:28 +0200 Subject: * 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). --- lisp/tab-bar.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lisp/tab-bar.el') 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 \ \\\\[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) -- cgit v1.2.1