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: Sun, 16 Jun 2024 19:50:29 +0300 Organization: LINKOV.NET Message-ID: <86plsgrfvu.fsf@mail.linkov.net> References: <86fsds8mlm.fsf@mail.linkov.net> <86ttibq1w1.fsf@mail.linkov.net> <8243325e-ed03-4e9e-b64f-c8225fb6dc60@gmx.at> <18173da7-32e1-4f14-bbea-9a8fa66af7dd@gmx.at> <86plsxmc6d.fsf@mail.linkov.net> <86r0d4ezdc.fsf@mail.linkov.net> <0d01a044-d7d6-456a-9ba9-d987faad4332@gmx.at> <86frthjq4y.fsf@mail.linkov.net> <743dc4dd-cf09-4c5e-9209-b63a47480e0b@gmx.at> <86msnne7ut.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39282"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.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 Sun Jun 16 18:54:30 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 1sIt9C-000A8R-8U for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Jun 2024 18:54:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sIt8m-0005tc-0U; Sun, 16 Jun 2024 12:54:04 -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 1sIt8k-0005t9-4n for bug-gnu-emacs@gnu.org; Sun, 16 Jun 2024 12:54:02 -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 1sIt8j-00043W-TC for bug-gnu-emacs@gnu.org; Sun, 16 Jun 2024 12:54:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sIt8k-0002UL-EH for bug-gnu-emacs@gnu.org; Sun, 16 Jun 2024 12:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Jun 2024 16:54:02 +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.17185568329519 (code B ref 59862); Sun, 16 Jun 2024 16:54:02 +0000 Original-Received: (at 59862) by debbugs.gnu.org; 16 Jun 2024 16:53:52 +0000 Original-Received: from localhost ([127.0.0.1]:43625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sIt8a-0002TS-3h for submit@debbugs.gnu.org; Sun, 16 Jun 2024 12:53:52 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:33775) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sIt8Y-0002Su-KN for 59862@debbugs.gnu.org; Sun, 16 Jun 2024 12:53:51 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id A173EFF802; Sun, 16 Jun 2024 16:53:39 +0000 (UTC) In-Reply-To: (martin rudalics's message of "Sat, 15 Jun 2024 10:41:54 +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:287339 Archived-At: > + (< (seq-count (lambda (w) (window-parameter w 'quit-restore)) > > The entire clause in 'quit-restore-window' governed by > > (eq (nth 1 quit-restore) 'tab) > > needs a comment on what it is supposed to restore. So here is a comment: diff --git a/lisp/window.el b/lisp/window.el index b7bd59bc813..5b782c93098 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5241,9 +5246,13 @@ quit-restore-window (window--delete window 'dedicated (eq bury-or-kill 'kill))) ;; If the previously selected window is still alive, select it. (window--quit-restore-select-window quit-restore-2)) + ;; Close the tab if it doesn't contain more explicitly created windows. ((and (not prev-buffer) (eq (nth 1 quit-restore) 'tab) - (eq (nth 3 quit-restore) buffer)) + (eq (nth 3 quit-restore) buffer) + (< (seq-count (lambda (w) (window-parameter w 'quit-restore)) + (window-list-1 nil 'nomini)) + 2)) (tab-bar-close-tab) ;; If the previously selected window is still alive, select it. (window--quit-restore-select-window quit-restore-2)) > Basically, you check > here whether WINDOW is the only window with a 'quit-restore' parameter. > Is it that what you really want? If a window has a 'quit-restore' > parameter whose second element is 'tab' does that mean that all other > windows on the same frame must also have such a parameter? What happens > if there are other windows without a 'quit-restore' parameter? If there are other windows without a 'quit-restore' parameter, this means that they were created implicitly without a direct user action. So the tab can be closed in this case. There are not many commands that create windows without a 'quit-restore' parameter. For example, Gnus creates several windows, and the tab should be closed when the user closes the first window. > As designed, the 'quit-restore' parameter can cause the deletion of its > window only if there are other windows on the same frame. It can cause > the deletion of its frame only if there is no other window on its frame. > Are these principles preserved by your patch? Yes, the patch closes the tab only if there is no other window on the tab explicitly created by user. >> + (window-list-1 nil 'nomini)) > > I suppose that nil is not correct here when WINDOW is not on the > selected frame. I'd rather use that window instead here. The current code doesn't support non-selected frames as 'tab-bar-close-tab' below shows without a frame argument: >> + 2)) >> (tab-bar-close-tab) >> ;; If the previously selected window is still alive, select it. >> (window--quit-restore-select-window quit-restore-2))