From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#59862: quit-restore per window buffer Date: Wed, 09 Oct 2024 19:17:11 +0300 Organization: LINKOV.NET Message-ID: <864j5ll110.fsf@mail.linkov.net> References: <86fsds8mlm.fsf@mail.linkov.net> <743dc4dd-cf09-4c5e-9209-b63a47480e0b@gmx.at> <86msnne7ut.fsf@mail.linkov.net> <86plsgrfvu.fsf@mail.linkov.net> <86le2b12ni.fsf@mail.linkov.net> <86y169kafb.fsf@mail.linkov.net> <61c4f245-3dd8-4e24-9c84-7ddd4cfe3c49@gmx.at> <86a5ioo269.fsf@mail.linkov.net> <867cdr3xs7.fsf@mail.linkov.net> <3f399d4f-3dd2-4624-b857-e198f70b5565@gmx.at> <86h6csct0w.fsf@mail.linkov.net> <38aedd8d-8966-44eb-afc0-79b4db412483@gmx.at> <86r0b9tqo3.fsf@mail.linkov.net> <22c18c89-b288-4c2e-83ae-11fd7cb1ec24@gmx.at> <86ed78w7t4.fsf@mail.linkov.net> <86msjefqfa.fsf@mail.linkov.net> <6272a373-1e7c-4df9-b0c2-e535ca3fe49b@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15900"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 59862@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 09 18:24:24 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1syZU8-0003x1-EV for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Oct 2024 18:24:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1syZTq-0007vd-5y; Wed, 09 Oct 2024 12:24:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1syZTc-0007mL-QW for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2024 12:23:53 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1syZTc-0000aG-I3 for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2024 12:23:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=sTyqC26n3DX4GSp7QWddw/67zaDeI3PZns7XcAHCh3Q=; b=TNCkMMNbKBx38DZOpV7GOWBXQ3l/2UCMAtBEd8B3nG15JFO8yB1Ffv6TPVBqxr+TrxiXA8OCeXcqLhjIG/0vL4xgG/uP0Wyxm9JuQ3Tslnko+jfRS9rA7tAUr1m+7Voa6dPQp/zb7157MVN05MK8zgp3a555GuU2rMaGngnaxQgcQV9mLA30UB3yNTFklUQeLlA9PnxfHYV+nVXPtelXCfM4qWg3F+svDriwp/MRGAkkxJaosBvPa+SRtj/bS5IU9M6sCKRxzYKNSH24O3riF2QbjAp6SGy/iXmV1WWXXZIS7bSKzdfd9r/Y/sTxlWhBozvs5aNX3hWOGTveuCNjcA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1syZTl-0000fy-M8 for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2024 12:24:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Oct 2024 16:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59862 X-GNU-PR-Package: emacs Original-Received: via spool by 59862-submit@debbugs.gnu.org id=B59862.17284910282577 (code B ref 59862); Wed, 09 Oct 2024 16:24:01 +0000 Original-Received: (at 59862) by debbugs.gnu.org; 9 Oct 2024 16:23:48 +0000 Original-Received: from localhost ([127.0.0.1]:57444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1syZTX-0000fV-JV for submit@debbugs.gnu.org; Wed, 09 Oct 2024 12:23:48 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:40217) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1syZTV-0000f1-6G for 59862@debbugs.gnu.org; Wed, 09 Oct 2024 12:23:45 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 0DCB820003; Wed, 9 Oct 2024 16:23:27 +0000 (UTC) In-Reply-To: <6272a373-1e7c-4df9-b0c2-e535ca3fe49b@gmx.at> (martin rudalics's message of "Wed, 9 Oct 2024 10:46:05 +0200") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:293220 Archived-At: >> >> (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 ```