unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: emacs-devel@gnu.org
Subject: Re: [PATCH] New tab-bar-detach-tab command
Date: Wed, 29 Sep 2021 02:59:57 -0500	[thread overview]
Message-ID: <875yujizgi.fsf@alphapapa.net> (raw)
In-Reply-To: 87pmsrrh7y.fsf@mail.linkov.net

[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]

Hi Juri,

Juri Linkov <juri@linkov.net> 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".

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: New patch --]
[-- Type: text/x-diff, Size: 1831 bytes --]

From 9deb82def15669d7cd520ec33caf345af0e4ce79 Mon Sep 17 00:00:00 2001
From: Adam Porter <adam@alphapapa.net>
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 <m@mfa.pw> 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))))
+
 \f
 (defcustom tab-bar-new-tab-to 'right
   "Defines where to create a new tab.
-- 
2.7.4


  reply	other threads:[~2021-09-29  7:59 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 19:09 [PATCH] New tab-bar-detach-tab command Adam Porter
2021-09-29  1:05 ` Matt Beshara
2021-09-29  7:11   ` Juri Linkov
2021-09-29  7:43   ` Adam Porter
2021-09-29  7:09 ` Juri Linkov
2021-09-29  7:59   ` Adam Porter [this message]
2021-09-29 19:43     ` Juri Linkov
2021-09-29 19:54       ` Adam Porter
2021-10-03 17:19         ` Juri Linkov
2021-10-04 10:34           ` Adam Porter
2021-10-04 17:33             ` Juri Linkov
2021-10-04 19:53               ` Adam Porter
2021-10-05  6:49                 ` Juri Linkov
2021-10-05  7:17                   ` Adam Porter
2021-10-05 15:27                     ` [External] : " Drew Adams
2021-10-05 16:38                     ` Juri Linkov
2021-10-06 11:23                       ` Adam Porter
2021-10-06 16:38                         ` Juri Linkov
2021-10-07 18:02                           ` Juri Linkov
2021-10-07 18:23                             ` [External] : " Drew Adams
2021-10-05 15:18                   ` Drew Adams
2021-10-05 16:40                     ` Juri Linkov
2021-10-05 17:27                       ` Drew Adams
2021-10-06 16:39                         ` Juri Linkov
2021-10-06 20:20                           ` [External] : " Drew Adams
2021-10-07  7:29                             ` Juri Linkov
2021-10-07  7:43                               ` Eli Zaretskii
2021-10-07 17:58                                 ` Juri Linkov
2021-10-07 18:19                                   ` Drew Adams
2021-10-07 18:28                                   ` Eli Zaretskii
2021-10-07 15:56                               ` Drew Adams
2021-10-05 16:35                 ` Juri Linkov
2021-10-05 15:15               ` [External] : " Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yujizgi.fsf@alphapapa.net \
    --to=adam@alphapapa.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).