GNU bug report logs -
#39446
28.0.50; Use quit-restore-window to close tab
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Wed, 5 Feb 2020 22:42:01 UTC
Severity: normal
Tags: fixed, patch
Fixed in version 28.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39446 in the body.
You can then email your comments to 39446 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39446
; Package
emacs
.
(Wed, 05 Feb 2020 22:42:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Juri Linkov <juri <at> linkov.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 05 Feb 2020 22:42:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Version: 28.0.50
Tags: patch
The same way as quit-window deletes the frame
when quitting the last window on the frame with e.g.
C-x 5 d RET q
this patch implements the same behavior for tabs:
C-x t d RET q
closes the tab.
This is for master since it will take time to tweak.
For example, it works fine everywhere except Gnus
that doesn't call quit-window when exiting a summary buffer
typing `q' (gnus-summary-exit) in a summary buffer
that was automatically displayed in a new tab,
so needed to customize Gnus by
(add-hook 'gnus-summary-exit-hook 'quit-window)
[close-tab-quit-restore-window.patch (text/x-diff, inline)]
diff --git a/lisp/window.el b/lisp/window.el
index 40c4bf5ad4..bd825c09e1 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5008,6 +5008,13 @@ quit-restore-window
prev-buffer)))
quad entry)
(cond
+ ((and (not prev-buffer)
+ (eq (nth 1 quit-restore) 'tab)
+ (eq (nth 3 quit-restore) buffer))
+ (tab-bar-close-tab)
+ ;; If the previously selected window is still alive, select it.
+ (when (window-live-p (nth 2 quit-restore))
+ (select-window (nth 2 quit-restore))))
((and (not prev-buffer)
(or (eq (nth 1 quit-restore) 'frame)
(and (eq (nth 1 quit-restore) 'window)
@@ -6367,7 +6374,12 @@ display-buffer-record-window
;; WINDOW has been created on a new frame.
(set-window-parameter
window 'quit-restore
- (list 'frame 'frame (selected-window) buffer)))))
+ (list 'frame 'frame (selected-window) buffer)))
+ ((eq type 'tab)
+ ;; WINDOW has been created on a new tab.
+ (set-window-parameter
+ window 'quit-restore
+ (list 'tab 'tab (selected-window) buffer)))))
(defcustom display-buffer-function nil
"If non-nil, function to call to handle `display-buffer'.
@@ -7034,7 +7046,7 @@ window--display-buffer
;; use that.
(display-buffer-mark-dedicated
(set-window-dedicated-p window display-buffer-mark-dedicated))))
- (when (memq type '(window frame))
+ (when (memq type '(window frame tab))
(set-window-prev-buffers window nil))
(let ((quit-restore (window-parameter window 'quit-restore))
(height (cdr (assq 'window-height alist)))
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index ebb0c566ad..d761000993 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -1480,26 +1479,55 @@ display-buffer-in-tab
(tab-bar-select-tab (1+ index)))
(when (get-buffer-window buffer frame)
(select-window (get-buffer-window buffer frame))))
+ (let ((tab-name (alist-get 'tab-name alist)))
+ (when (functionp tab-name)
+ (setq tab-name (funcall tab-name buffer alist)))
+ (if tab-name
+ (let ((tab-index (tab-bar--tab-index-by-name tab-name)))
+ (if tab-index
+ (progn
+ (tab-bar-select-tab (1+ tab-index))
+ (when (get-buffer-window buffer)
+ (select-window (get-buffer-window buffer))))
+ (display-buffer-in-new-tab buffer alist)))
+ (display-buffer-in-new-tab buffer alist))))))
+
+(defun display-buffer-in-new-tab (buffer alist)
+ "Display BUFFER in a new tab.
+ALIST is an association list of action symbols and values. See
+Info node `(elisp) Buffer Display Action Alists' for details of
+such alists.
+
+Like `display-buffer-in-tab', but always creates a new tab unconditionally,
+without checking if a suitable tab already exists.
+
+If ALIST contains a `tab-name' entry, it creates a new tab with that name
+and displays BUFFER in a new tab. The `tab-name' entry can be a function,
+then it is called with two arguments: BUFFER and ALIST, and should return
+the tab name. When a `tab-name' entry is omitted, create a new tab without
+an explicit name.
+
+This is an action function for buffer display, see Info
+node `(elisp) Buffer Display Action Functions'. It should be
+called only by `display-buffer' or a function directly or
+indirectly called by the latter."
+ (let ((tab-bar-new-tab-choice t))
+ (tab-bar-new-tab)
+ (let ((tab-name (alist-get 'tab-name alist)))
(when (functionp tab-name)
(setq tab-name (funcall tab-name buffer alist)))
- (if tab-name
- (let ((tab-index (tab-bar--tab-index-by-name tab-name)))
- (if tab-index
- (tab-bar-select-tab (1+ tab-index))
- (let ((tab-bar-new-tab-choice t))
- (tab-bar-new-tab)
- (tab-bar-rename-tab tab-name))))
- (let ((tab-bar-new-tab-choice t))
- (tab-bar-new-tab))))))
+ (when tab-name
+ (tab-bar-rename-tab tab-name)))
+ (window--display-buffer buffer (selected-window) 'tab alist)))
(defun switch-to-buffer-other-tab (buffer-or-name &optional norecord)
"Switch to buffer BUFFER-OR-NAME in another tab.
Like \\[switch-to-buffer-other-frame] (which see), but creates a new tab."
(interactive
(list (read-buffer-to-switch "Switch to buffer in other tab: ")))
- (display-buffer buffer-or-name '((display-buffer-in-tab
- display-buffer-same-window)
- (inhibit-same-window . nil))
+ (display-buffer buffer-or-name '((display-buffer-in-tab)
+ (inhibit-same-window . nil)
+ (reusable-frames . t))
norecord))
(defun find-file-other-tab (filename &optional wildcards)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39446
; Package
emacs
.
(Thu, 06 Feb 2020 03:33:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 39446 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Date: Wed, 05 Feb 2020 23:53:13 +0200
>
> The same way as quit-window deletes the frame
> when quitting the last window on the frame with e.g.
>
> C-x 5 d RET q
This doesn't delete the frame here. Is the key sequence above
correct? If so, can you show a detailed use case where such
deletion-on-quit happens?
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39446
; Package
emacs
.
(Fri, 07 Feb 2020 00:43:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 39446 <at> debbugs.gnu.org (full text, mbox):
>> The same way as quit-window deletes the frame
>> when quitting the last window on the frame with e.g.
>>
>> C-x 5 d RET q
>
> This doesn't delete the frame here. Is the key sequence above
> correct? If so, can you show a detailed use case where such
> deletion-on-quit happens?
Indeed. I thought that it deletes the frame, but it only
minimizes/buries/hides the frame.
The frame is deleted only when quit-window is called
with a prefix arg, e.g.
C-x 5 d RET C-u q
Since there is no such thing as tab minimizing,
it should be fine to just close the tab.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39446
; Package
emacs
.
(Fri, 07 Feb 2020 08:09:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 39446 <at> debbugs.gnu.org (full text, mbox):
> From: Juri Linkov <juri <at> linkov.net>
> Cc: 39446 <at> debbugs.gnu.org
> Date: Fri, 07 Feb 2020 02:17:45 +0200
>
> The frame is deleted only when quit-window is called
> with a prefix arg, e.g.
>
> C-x 5 d RET C-u q
>
> Since there is no such thing as tab minimizing,
> it should be fine to just close the tab.
But I think 'q' here is not the important part, because in most major
modes it just inserts 'q'. You are saying that quit-window, when
called with KILL argument non-nil, will close the tab if this is the
last window in that tab's window-configuration, is that right?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39446
; Package
emacs
.
(Sun, 09 Feb 2020 00:44:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 39446 <at> debbugs.gnu.org (full text, mbox):
>> The frame is deleted only when quit-window is called
>> with a prefix arg, e.g.
>>
>> C-x 5 d RET C-u q
>>
>> Since there is no such thing as tab minimizing,
>> it should be fine to just close the tab.
>
> But I think 'q' here is not the important part, because in most major
> modes it just inserts 'q'. You are saying that quit-window, when
> called with KILL argument non-nil, will close the tab if this is the
> last window in that tab's window-configuration, is that right?
Right, this is what I meant.
Added tag(s) fixed.
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Mon, 10 Feb 2020 00:52:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 28.0.50, send any further explanations to
39446 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net>
Request was from
Juri Linkov <juri <at> linkov.net>
to
control <at> debbugs.gnu.org
.
(Mon, 10 Feb 2020 00:52:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 09 Mar 2020 11:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 5 years and 186 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.