From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: 59862@debbugs.gnu.org
Subject: bug#59862: quit-restore per window buffer
Date: Wed, 09 Oct 2024 19:17:11 +0300 [thread overview]
Message-ID: <864j5ll110.fsf@mail.linkov.net> (raw)
In-Reply-To: <6272a373-1e7c-4df9-b0c2-e535ca3fe49b@gmx.at> (martin rudalics's message of "Wed, 9 Oct 2024 10:46:05 +0200")
>>
>> (defun tab-bar-window-deletable (window single)
>> (if (and single (eq (nth 1 (window-parameter window 'quit-restore)) 'tab))
>> (progn (tab-bar-close-tab) nil)
>> t))
>>
>> (add-hook 'window-deletable-functions 'tab-bar-window-deletable)
>>
>> But 'window-deletable-functions' is not called at all,
>> because 'window-deletable-p' first checks
>>
>> (frame-deletable-p (window-frame window))
>>
>> and a single frame with tabs is not deletable.
>
> Why "with tabs" and not just "a single frame is not deletable"?
Because tabs have priority over frames. The precedence is:
windows -> tabs -> frames. When there are many tabs
then quit-restore-window should close tabs, and only
on the last tab should delete the frame. This is bug#71386,
but first need to finish bug#59862.
>> Also instead of 'frame-root-window-p' in 'window-deletable-p'
>> the tab-bar needs to use another code.
>
> I don't understand the problem yet. 'window-deletable-p' calls
> 'frame-deletable-p' iff WINDOW is the root window of the frame. At this
> time we can only either delete the frame or show another buffer in
> WINDOW; tertium non datur. What am I missing?
The third first-class citizen is the tab-bar.
Here is the test case that will help to understand the requirements.
1.1. 'quit-restore-window' deletes the frame
2.1. 'quit-restore-window' deletes the tab
Both test cases are identical, and already pass correctly.
1.2. 'quit-restore-window' doesn't delete the frame
passes as well, but its counterpart
2.2. 'quit-restore-window' doesn't delete the tab
fails at the line "FAILS HERE":
```
diff --git a/test/lisp/tab-bar-tests.el b/test/lisp/tab-bar-tests.el
index aa8384b24e8..00fd78cf081 100644
--- a/test/lisp/tab-bar-tests.el
+++ b/test/lisp/tab-bar-tests.el
@@ -42,10 +42,104 @@ tab-bar-tests-close-other-tabs
(should (eq (length tab-bar-closed-tabs) 0)))
(ert-deftest tab-bar-tests-close-other-tabs-default ()
- (tab-bar-tests-close-other-tabs nil))
+ (tab-bar-tests-close-other-tabs nil)
+ ;; Clean up tabs afterwards
+ (tab-bar-tabs-set nil))
(ert-deftest tab-bar-tests-close-other-tabs-with-arg ()
- (dotimes (i 5) (tab-bar-tests-close-other-tabs i)))
+ (dotimes (i 5) (tab-bar-tests-close-other-tabs i))
+ ;; Clean up tabs afterwards
+ (tab-bar-tabs-set nil))
+
+(ert-deftest tab-bar-tests-quit-restore-window ()
+ (let* ((frame-params (when noninteractive
+ '((window-system . nil)
+ (tty-type . "linux"))))
+ (pop-up-frame-alist frame-params)
+ (frame-auto-hide-function 'delete-frame))
+
+ ;; 1.1. 'quit-restore-window' deletes the frame
+ (progn
+ (should (eq (length (frame-list)) 1))
+ (other-frame-prefix)
+ (info)
+ (should (eq (length (frame-list)) 2))
+ (should (equal (buffer-name) "*info*"))
+ (view-echo-area-messages)
+ (other-window 1)
+ (should (eq (length (window-list)) 2))
+ (should (equal (buffer-name) "*Messages*"))
+ (quit-window)
+ (should (eq (length (window-list)) 1))
+ (should (equal (buffer-name) "*info*"))
+ (quit-window)
+ (should (eq (length (frame-list)) 1)))
+
+ ;; 1.2. 'quit-restore-window' doesn't delete the frame
+ (progn
+ (should (eq (length (frame-list)) 1))
+ (other-frame-prefix)
+ (info)
+ (should (eq (length (frame-list)) 2))
+ (should (equal (buffer-name) "*info*"))
+ (view-echo-area-messages)
+ (should (eq (length (window-list)) 2))
+ (should (equal (buffer-name) "*info*"))
+ (quit-window)
+ (should (eq (length (window-list)) 1))
+ (should (eq (length (frame-list)) 2))
+ (should (equal (buffer-name) "*Messages*"))
+ (quit-window)
+ (should (eq (length (frame-list)) 2))
+ ;; Clean up the frame afterwards
+ (delete-frame))
+
+ ;; 2.1. 'quit-restore-window' deletes the tab
+ (progn
+ (should (eq (length (tab-bar-tabs)) 1))
+ (other-tab-prefix)
+ (info)
+ (should (eq (length (tab-bar-tabs)) 2))
+ (should (equal (buffer-name) "*info*"))
+ (view-echo-area-messages)
+ (other-window 1)
+ (should (eq (length (window-list)) 2))
+ (should (equal (buffer-name) "*Messages*"))
+ (quit-window)
+ (should (eq (length (window-list)) 1))
+ (should (equal (buffer-name) "*info*"))
+ (quit-window)
+ (should (eq (length (tab-bar-tabs)) 1)))
+
+ ;; 2.2. 'quit-restore-window' doesn't delete the tab
+ (progn
+ (should (eq (length (tab-bar-tabs)) 1))
+ (other-tab-prefix)
+ (info)
+ (should (eq (length (tab-bar-tabs)) 2))
+ (should (equal (buffer-name) "*info*"))
+ (view-echo-area-messages)
+ (should (eq (length (window-list)) 2))
+ (should (equal (buffer-name) "*info*"))
+ (quit-window)
+ (should (eq (length (window-list)) 1))
+ (should (eq (length (tab-bar-tabs)) 2)) ;; FAILS HERE
+ (should (equal (buffer-name) "*Messages*"))
+ (quit-window)
+ (should (eq (length (tab-bar-tabs)) 2))
+ ;; Clean up the tab afterwards
+ (tab-close))
+
+ ;; Clean up tabs afterwards
+ (tab-bar-tabs-set nil)))
(provide 'tab-bar-tests)
;;; tab-bar-tests.el ends here
```
next prev parent reply other threads:[~2024-10-09 16:17 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 17:32 bug#59862: quit-restore per window buffer Juri Linkov
2024-06-02 6:45 ` Juri Linkov
2024-06-03 9:34 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-03 9:53 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-03 16:09 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 6:53 ` Juri Linkov
2024-06-05 16:56 ` Juri Linkov
2024-06-11 6:52 ` Juri Linkov
2024-06-12 8:57 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-13 6:47 ` Juri Linkov
2024-06-13 8:21 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-14 17:35 ` Juri Linkov
2024-06-15 8:41 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-16 16:50 ` Juri Linkov
2024-06-17 14:48 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-08 16:49 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-09 6:58 ` Juri Linkov
2024-07-09 8:52 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-10 6:50 ` Juri Linkov
2024-07-10 9:16 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-11 6:47 ` Juri Linkov
2024-07-11 8:36 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-12 6:54 ` Juri Linkov
2024-07-12 8:20 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-14 7:49 ` Juri Linkov
2024-07-15 7:32 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-16 6:09 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-16 6:09 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <87frs9kgve.fsf@>
2024-07-16 8:22 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-16 22:14 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-16 22:14 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <871q3tc7da.fsf@>
2024-07-17 9:23 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-30 8:20 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-31 17:30 ` Juri Linkov
2024-08-01 6:37 ` Juri Linkov
2024-08-01 7:50 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-01 7:49 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-01 16:01 ` Juri Linkov
2024-10-08 17:53 ` Juri Linkov
2024-10-09 8:46 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-09 16:17 ` Juri Linkov [this message]
2024-10-10 14:54 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-10 18:28 ` Juri Linkov
2024-10-11 7:50 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-13 6:18 ` Juri Linkov
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=864j5ll110.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=59862@debbugs.gnu.org \
--cc=rudalics@gmx.at \
/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).