From: Adam Porter Date: Wed, 29 Sep 2021 19:37:38 +0000 (+0300) Subject: * lisp/tab-bar.el: (tab-bar-detach-tab) New command X-Git-Tag: emacs-28.0.90~515 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ab1e11fe796c404cad2d73dafd81da8b4329ca90;p=emacs.git * 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. https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg02141.html --- diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index abf0e814c41..9f64e2d1eeb 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -312,6 +312,11 @@ that closes only when clicked on the close button." (tab-bar-duplicate-tab nil ,tab-number)) :help "Duplicate the tab")) + (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 [close] `(menu-item "Close" (lambda () (interactive) (tab-bar-close-tab ,tab-number)) @@ -1201,6 +1206,17 @@ Interactively, ARG selects the ARGth different frame to move to." (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 (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)) + (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.