From: Juri Linkov Date: Mon, 22 Nov 2021 18:15:28 +0000 (+0200) Subject: * lisp/tab-bar.el: 'C-x t RET' creates a new tab for non-existent tab name. X-Git-Tag: emacs-29.0.90~2852^2~99 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=eef6626b55e59d4a76e8666108cc68a578fac793;p=emacs.git * 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). --- diff --git a/etc/NEWS b/etc/NEWS index 09f17d6553b..0bf3d9368b6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -181,6 +181,11 @@ For example, a 'display-buffer-alist' entry of will make the body of the chosen window 40 columns wide. For the height use 'window-height' in combination with 'body-lines'. +** Tab Bars and Tab Lines + +--- +*** 'C-x t RET' creates a new tab when the provided tab name doesn't exist. + ** Better detection of text suspiciously reordered on display. The function 'bidi-find-overridden-directionality' has been extended to detect reordering effects produced by embeddings and isolates 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)