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, 14 Jul 2024 10:49:35 +0300 Organization: LINKOV.NET Message-ID: <86h6csct0w.fsf@mail.linkov.net> References: <86fsds8mlm.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> <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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27877"; 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 Sun Jul 14 09:52:22 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 1sSu1u-00077g-Dr for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Jul 2024 09:52:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSu1a-0001YZ-Bs; Sun, 14 Jul 2024 03:52:02 -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 1sSu1Y-0001TB-Us for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2024 03:52:00 -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 1sSu1Y-0008VV-Lz for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2024 03:52:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sSu1Z-0003pP-PH for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2024 03:52: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: Sun, 14 Jul 2024 07:52: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.172094349114680 (code B ref 59862); Sun, 14 Jul 2024 07:52:01 +0000 Original-Received: (at 59862) by debbugs.gnu.org; 14 Jul 2024 07:51:31 +0000 Original-Received: from localhost ([127.0.0.1]:57107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sSu14-0003oi-WE for submit@debbugs.gnu.org; Sun, 14 Jul 2024 03:51:31 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:56115) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sSu12-0003oU-UK for 59862@debbugs.gnu.org; Sun, 14 Jul 2024 03:51:29 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id A0A2D240003; Sun, 14 Jul 2024 07:50:59 +0000 (UTC) In-Reply-To: <3f399d4f-3dd2-4624-b857-e198f70b5565@gmx.at> (martin rudalics's message of "Fri, 12 Jul 2024 10:20:32 +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:288833 Archived-At: >> Ok, I will try to move it. > > We could replace the > > (or (eq (nth 1 quit-restore) 'frame) > (and (eq (nth 1 quit-restore) 'window) > ;; If the window has been created on an existing > ;; frame and ended up as the sole window on that > ;; frame, do not delete it (Bug#12764). > (not (eq window (frame-root-window window))))) > > clause with > > (or (eq (nth 1 quit-restore) 'frame) > ;; If the window has been created on an existing > ;; frame and ended up as the sole window on that > ;; frame, do not delete it (Bug#12764). > (not (eq window (frame-root-window window)))) > > with the motivation that if a window does not have a previous buffer, > there is no reason to switch to it. This will keep the frame around so > Bu#12764 is not affected and the normal behavior of C-h i followed by > C-h e is not affected either unless a user deleted *scratch* in between. Sorry, I know nothing about the frame case. > Try it and if it works for you I'll add it to the new patch. OTOH, I tried to add the tab case handling to the same places where the frame case is handled, and everything works nicely with this patch applied over your previous patches: diff --git a/lisp/window.el b/lisp/window.el index 58120c919c7..82efb3c40ce 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4120,6 +4120,11 @@ window-deletable-p (let ((frame (window-frame window))) (cond + ((and (eq (nth 1 (window-parameter window 'quit-restore)) 'tab) + (< (seq-count (lambda (w) (window-parameter w 'quit-restore)) + (window-list-1 nil 'nomini)) + 2)) + 'tab) ((frame-root-window-p window) ;; WINDOW's frame can be deleted only if there are other frames ;; on the same terminal, and it does not contain the active @@ -4990,6 +4995,9 @@ window--delete (unless (and dedicated-only (not (window-dedicated-p window))) (let ((deletable (window-deletable-p window))) (cond + ((eq deletable 'tab) + (tab-bar-close-tab) + 'tab) ((eq deletable 'frame) (let ((frame (window-frame window))) (cond @@ -5303,10 +5311,8 @@ quit-restore-window ((and (not prev-buffer) (eq (nth 1 quit-restore) 'tab) (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) + (window--delete + window nil (memq bury-or-kill '(kill killing)))) ;; If the previously selected window is still alive, select it. (window--quit-restore-select-window quit-restore-2)) ((and (not prev-buffer)