From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Porter Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] New tab-bar-detach-tab command Date: Wed, 29 Sep 2021 02:59:57 -0500 Message-ID: <875yujizgi.fsf@alphapapa.net> References: <87h7e4ikkz.fsf@alphapapa.net> <87pmsrrh7y.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18171"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 29 10:03:00 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVUYO-0004Xi-9p for ged-emacs-devel@m.gmane-mx.org; Wed, 29 Sep 2021 10:03:00 +0200 Original-Received: from localhost ([::1]:36122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVUYN-0000lv-3V for ged-emacs-devel@m.gmane-mx.org; Wed, 29 Sep 2021 04:02:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVUVn-00084S-7D for emacs-devel@gnu.org; Wed, 29 Sep 2021 04:00:20 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:41452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVUVf-0006by-39 for emacs-devel@gnu.org; Wed, 29 Sep 2021 04:00:18 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mVUVc-00019G-Bb for emacs-devel@gnu.org; Wed, 29 Sep 2021 10:00:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:275773 Archived-At: --=-=-= Content-Type: text/plain Hi Juri, Juri Linkov writes: > Thanks. The command 'tab-bar-move-tab-to-frame' was intended > to do exactly this. If it doesn't, then it would be better > to fix it, for example, by improving its 'interactive' spec, etc. > Then you can add an alias 'tab-bar-detach-tab' to it. Looking at that command, I'm not sure how to change its interactive spec to move a tab to a new frame without changing the command's documented behavior. But using it to do the work of moving a tab to a new frame created by another command is straightforward and easy for me to understand. :) I've attached a new patch for your consideration. It seems to work correctly (correcting the issue Matt noted), and it also adds the new command to the tab bar context menu. If you'd still prefer to change 'tab-bar-move-tab-to-frame' to accomodate this functionality, I'm not sure what you have in mind. >> It might be worth binding it to something like "C-x t D" as well, >> assuming the command is worth merging. :) > > Currently I'm developing a command that will detach a window > to a new tab, i.e. it will delete the selected window > from the current tab after moving it to the new tab. > And I'd like to add a keybinding to it with the same mnemonics "D" :-) Hm, what if the new window-detaching command were on "C-x t d", and the new tab-detaching command were on "C-x t D"? Of course, "C-x t d" is currently bound to 'dired-other-tab', but it seems like that should be covered by 'other-tab-prefix', i.e. "C-x t t C-x d". --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-tab-bar.el-tab-bar-detach-tab-New-command.patch Content-Description: New patch >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 --=-=-=--