]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-bar.el: Create new unique windows with 'C-x t n' (bug#54038).
authorJuri Linkov <juri@linkov.net>
Wed, 23 Feb 2022 17:58:33 +0000 (19:58 +0200)
committerJuri Linkov <juri@linkov.net>
Wed, 23 Feb 2022 17:58:33 +0000 (19:58 +0200)
* lisp/tab-bar.el (tab-bar-new-tab-choice): Replace the value 'nil'
with explicit 'clone'.
(tab-bar-move-window-to-tab): Ignore possible side/atom window
parameters with ignore-window-parameters while deleting window.
(tab-bar-new-tab-to): When 'tab-bar-new-tab-choice' is 'clone',
create new unique windows with the same layout using window-state-get
and window-state-put.  Do the same after deleting other windows
when 'tab-bar-new-tab-choice' is 'window'.
(tab-bar-duplicate-tab): Replace the value 'nil' with 'clone' for
'tab-bar-new-tab-choice'.

lisp/tab-bar.el

index 09105027581d7fad324ebb1235ec49816e3f9027..245a55a671fecc02f32417d1af8f3f7d005a9259 100644 (file)
@@ -481,7 +481,7 @@ If the value is a string, use it as a buffer name to switch to
 if such buffer exists, or switch to a buffer visiting the file or
 directory that the string specifies.  If the value is a function,
 call it with no arguments and switch to the buffer that it returns.
-If nil, duplicate the contents of the tab that was active
+If `clone', duplicate the contents of the tab that was active
 before calling the command that adds a new tab."
   :type '(choice (const     :tag "Current buffer" t)
                  (const     :tag "Current window" window)
@@ -489,7 +489,7 @@ before calling the command that adds a new tab."
                  (directory :tag "Directory" :value "~/")
                  (file      :tag "File" :value "~/.emacs")
                  (function  :tag "Function")
-                 (const     :tag "Duplicate tab" nil))
+                 (const     :tag "Duplicate tab" clone))
   :group 'tab-bar
   :version "27.1")
 
@@ -1318,7 +1318,8 @@ configuration."
   (let ((tab-bar-new-tab-choice 'window))
     (tab-bar-new-tab))
   (tab-bar-switch-to-recent-tab)
-  (delete-window)
+  (let ((ignore-window-parameters t))
+    (delete-window))
   (tab-bar-switch-to-recent-tab))
 
 \f
@@ -1367,14 +1368,20 @@ After the tab is created, the hooks in
         (select-window (minibuffer-selected-window)))
       ;; Remove window parameters that can cause problems
       ;; with `delete-other-windows' and `split-window'.
-      (set-window-parameter nil 'window-atom nil)
-      (set-window-parameter nil 'window-side nil)
+      (unless (eq tab-bar-new-tab-choice 'clone)
+        (set-window-parameter nil 'window-atom nil)
+        (set-window-parameter nil 'window-side nil))
       (let ((ignore-window-parameters t))
-        (delete-other-windows)
-        (unless (eq tab-bar-new-tab-choice 'window)
-          ;; Create a new window to get rid of old window parameters
-          ;; (e.g. prev/next buffers) of old window.
-          (split-window) (delete-window)))
+        (if (eq tab-bar-new-tab-choice 'clone)
+            ;; Create new unique windows with the same layout
+            (window-state-put (window-state-get))
+          (delete-other-windows)
+          (if (eq tab-bar-new-tab-choice 'window)
+              ;; Create new unique window from remaining window
+              (window-state-put (window-state-get))
+            ;; Create a new window to get rid of old window parameters
+            ;; (e.g. prev/next buffers) of old window.
+            (split-window) (delete-window))))
 
       (let ((buffer
              (if (functionp tab-bar-new-tab-choice)
@@ -1453,7 +1460,7 @@ If FROM-NUMBER is a tab number, a new tab is created from that tab."
   "Clone the current tab to ARG positions to the right.
 ARG and FROM-NUMBER have the same meaning as in `tab-bar-new-tab'."
   (interactive "P")
-  (let ((tab-bar-new-tab-choice nil)
+  (let ((tab-bar-new-tab-choice 'clone)
         (tab-bar-new-tab-group t))
     (tab-bar-new-tab arg from-number)))