emacs-diffs
[Top][All Lists]
Advanced

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

emacs-28 0c341e6 2/2: * lisp/tab-bar.el (tab-bar-detach-tab): Handle fra


From: Juri Linkov
Subject: emacs-28 0c341e6 2/2: * lisp/tab-bar.el (tab-bar-detach-tab): Handle frame selected by make-frame.
Date: Sun, 3 Oct 2021 13:17:01 -0400 (EDT)

branch: emacs-28
commit 0c341e6e84101251c0e40300519869f24415600d
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/tab-bar.el (tab-bar-detach-tab): Handle frame selected by make-frame.
    
    (tab-bar-move-window-to-tab): New command.
    (tab-bar-new-tab-to): Handle the value 'window' of tab-bar-new-tab-choice.
    https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg02197.html
---
 lisp/tab-bar.el | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 634328e..68afb53 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1211,13 +1211,26 @@ Interactively, ARG selects the ARGth different frame to 
move to."
   "Detach tab number FROM-NUMBER to a new frame.
 Interactively or without argument, detach current tab."
   (interactive (list (1+ (tab-bar--current-tab-index))))
-  (let* ((tab (nth (1- (or from-number 1)) (funcall tab-bar-tabs-function)))
-         (tab-name (alist-get 'name tab))
+  (let* ((tabs (funcall tab-bar-tabs-function))
+         (tab-index (1- (or from-number (1+ (tab-bar--current-tab-index 
tabs)))))
+         (tab-name (alist-get 'name (nth tab-index tabs)))
+         ;; On some window managers, `make-frame' selects the new frame,
+         ;; so previously selected frame is saved to `from-frame'.
+         (from-frame (selected-frame))
          (new-frame (make-frame `((name . ,tab-name)))))
-    (tab-bar-move-tab-to-frame nil nil from-number new-frame nil)
+    (tab-bar-move-tab-to-frame nil from-frame from-number new-frame nil)
     (with-selected-frame new-frame
       (tab-bar-close-tab))))
 
+(defun tab-bar-move-window-to-tab ()
+  "Detach the selected window to a new tab."
+  (interactive)
+  (let ((tab-bar-new-tab-choice 'window))
+    (tab-bar-new-tab))
+  (tab-bar-switch-to-recent-tab)
+  (delete-window)
+  (tab-bar-switch-to-recent-tab))
+
 
 (defcustom tab-bar-new-tab-to 'right
   "Defines where to create a new tab.
@@ -1264,9 +1277,10 @@ After the tab is created, the hooks in
         (select-window (minibuffer-selected-window)))
       (let ((ignore-window-parameters t))
         (delete-other-windows))
-      ;; Create a new window to get rid of old window parameters
-      ;; (e.g. prev/next buffers) of old window.
-      (split-window) (delete-window)
+      (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))
       (let ((buffer
              (if (functionp tab-bar-new-tab-choice)
                  (funcall tab-bar-new-tab-choice)



reply via email to

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