From 9deb82def15669d7cd520ec33caf345af0e4ce79 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 28 Sep 2021 14:03:01 -0500 Subject: [PATCH] * lisp/tab-bar.el: (tab-bar-detach-tab) New command (tab-bar-detach-tab): New command. (tab-bar-mouse-context-menu): Add menu entry. With thanks to Matt Beshara for his feedback. --- lisp/tab-bar.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index abf0e81..44b89c8 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -307,6 +307,11 @@ tab-bar-mouse-context-menu :help "Undo closing the tab")))) (t + (define-key-after menu [detach-tab] + `(menu-item "Detach" (lambda () (interactive) + (tab-bar-detach-tab + ,tab-number)) + :help "Detach the tab to new frame")) (define-key-after menu [duplicate-tab] `(menu-item "Duplicate" (lambda () (interactive) (tab-bar-duplicate-tab @@ -1201,6 +1206,17 @@ tab-bar-move-tab-to-frame (tab-bar-tabs-set to-tabs to-frame) (force-mode-line-update t)))) +(defun tab-bar-detach-tab (&optional from-number) + "Detach tab number FROM-NUMBER to a new frame. +Interactively or without argument, detach current tab." + (interactive (list (tab-bar--current-tab-index))) + (let* ((tab (nth (or from-number 1) (funcall tab-bar-tabs-function))) + (tab-name (alist-get 'name tab)) + (new-frame (make-frame `((name . ,tab-name))))) + (tab-bar-move-tab-to-frame nil nil from-number new-frame nil) + (with-selected-frame new-frame + (tab-bar-close-tab)))) + (defcustom tab-bar-new-tab-to 'right "Defines where to create a new tab. -- 2.7.4