aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2022-02-23 19:58:33 +0200
committerJuri Linkov2022-02-23 19:58:33 +0200
commit435d5c84ed200b24b0cd5b51fa77026e861eff3f (patch)
tree3de3465831525c89d637f7d798cac43a64f4e29c
parent99ba8c03c8fac65c2497265c54e1bea49f7c6dd3 (diff)
downloademacs-435d5c84ed200b24b0cd5b51fa77026e861eff3f.tar.gz
emacs-435d5c84ed200b24b0cd5b51fa77026e861eff3f.zip
* lisp/tab-bar.el: Create new unique windows with 'C-x t n' (bug#54038).
* 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'.
-rw-r--r--lisp/tab-bar.el29
1 files changed, 18 insertions, 11 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 09105027581..245a55a671f 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -481,7 +481,7 @@ If the value is a string, use it as a buffer name to switch to
481if such buffer exists, or switch to a buffer visiting the file or 481if such buffer exists, or switch to a buffer visiting the file or
482directory that the string specifies. If the value is a function, 482directory that the string specifies. If the value is a function,
483call it with no arguments and switch to the buffer that it returns. 483call it with no arguments and switch to the buffer that it returns.
484If nil, duplicate the contents of the tab that was active 484If `clone', duplicate the contents of the tab that was active
485before calling the command that adds a new tab." 485before calling the command that adds a new tab."
486 :type '(choice (const :tag "Current buffer" t) 486 :type '(choice (const :tag "Current buffer" t)
487 (const :tag "Current window" window) 487 (const :tag "Current window" window)
@@ -489,7 +489,7 @@ before calling the command that adds a new tab."
489 (directory :tag "Directory" :value "~/") 489 (directory :tag "Directory" :value "~/")
490 (file :tag "File" :value "~/.emacs") 490 (file :tag "File" :value "~/.emacs")
491 (function :tag "Function") 491 (function :tag "Function")
492 (const :tag "Duplicate tab" nil)) 492 (const :tag "Duplicate tab" clone))
493 :group 'tab-bar 493 :group 'tab-bar
494 :version "27.1") 494 :version "27.1")
495 495
@@ -1318,7 +1318,8 @@ configuration."
1318 (let ((tab-bar-new-tab-choice 'window)) 1318 (let ((tab-bar-new-tab-choice 'window))
1319 (tab-bar-new-tab)) 1319 (tab-bar-new-tab))
1320 (tab-bar-switch-to-recent-tab) 1320 (tab-bar-switch-to-recent-tab)
1321 (delete-window) 1321 (let ((ignore-window-parameters t))
1322 (delete-window))
1322 (tab-bar-switch-to-recent-tab)) 1323 (tab-bar-switch-to-recent-tab))
1323 1324
1324 1325
@@ -1367,14 +1368,20 @@ After the tab is created, the hooks in
1367 (select-window (minibuffer-selected-window))) 1368 (select-window (minibuffer-selected-window)))
1368 ;; Remove window parameters that can cause problems 1369 ;; Remove window parameters that can cause problems
1369 ;; with `delete-other-windows' and `split-window'. 1370 ;; with `delete-other-windows' and `split-window'.
1370 (set-window-parameter nil 'window-atom nil) 1371 (unless (eq tab-bar-new-tab-choice 'clone)
1371 (set-window-parameter nil 'window-side nil) 1372 (set-window-parameter nil 'window-atom nil)
1373 (set-window-parameter nil 'window-side nil))
1372 (let ((ignore-window-parameters t)) 1374 (let ((ignore-window-parameters t))
1373 (delete-other-windows) 1375 (if (eq tab-bar-new-tab-choice 'clone)
1374 (unless (eq tab-bar-new-tab-choice 'window) 1376 ;; Create new unique windows with the same layout
1375 ;; Create a new window to get rid of old window parameters 1377 (window-state-put (window-state-get))
1376 ;; (e.g. prev/next buffers) of old window. 1378 (delete-other-windows)
1377 (split-window) (delete-window))) 1379 (if (eq tab-bar-new-tab-choice 'window)
1380 ;; Create new unique window from remaining window
1381 (window-state-put (window-state-get))
1382 ;; Create a new window to get rid of old window parameters
1383 ;; (e.g. prev/next buffers) of old window.
1384 (split-window) (delete-window))))
1378 1385
1379 (let ((buffer 1386 (let ((buffer
1380 (if (functionp tab-bar-new-tab-choice) 1387 (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."
1453 "Clone the current tab to ARG positions to the right. 1460 "Clone the current tab to ARG positions to the right.
1454ARG and FROM-NUMBER have the same meaning as in `tab-bar-new-tab'." 1461ARG and FROM-NUMBER have the same meaning as in `tab-bar-new-tab'."
1455 (interactive "P") 1462 (interactive "P")
1456 (let ((tab-bar-new-tab-choice nil) 1463 (let ((tab-bar-new-tab-choice 'clone)
1457 (tab-bar-new-tab-group t)) 1464 (tab-bar-new-tab-group t))
1458 (tab-bar-new-tab arg from-number))) 1465 (tab-bar-new-tab arg from-number)))
1459 1466