emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master eef6626: * lisp/tab-bar.el: 'C-x t RET' creates a new tab for non


From: Juri Linkov
Subject: master eef6626: * lisp/tab-bar.el: 'C-x t RET' creates a new tab for non-existent tab name.
Date: Mon, 22 Nov 2021 13:16:39 -0500 (EST)

branch: master
commit eef6626b55e59d4a76e8666108cc68a578fac793
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * 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).
---
 etc/NEWS        |  5 +++++
 lisp/tab-bar.el | 10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 09f17d6..0bf3d93 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 d331f29..656cb87 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)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]