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: Tue, 06 Dec 2022 19:32:05 +0200 Organization: LINKOV.NET Message-ID: <86fsds8mlm.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="15667"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) To: 59862@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 06 18:35:35 2022 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 1p2bqw-0003pt-Si for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 06 Dec 2022 18:35:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2bqi-0007xe-EB; Tue, 06 Dec 2022 12:35:22 -0500 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 1p2bqR-0007w5-Ll for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 12:35:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2bqR-0003W7-7m for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 12:35:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2bqQ-000689-NW for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 12:35:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Dec 2022 17:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59862 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167034809723553 (code B ref -1); Tue, 06 Dec 2022 17:35:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Dec 2022 17:34:57 +0000 Original-Received: from localhost ([127.0.0.1]:44161 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2bqL-00067o-4w for submit@debbugs.gnu.org; Tue, 06 Dec 2022 12:34:57 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:49600) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2bqK-00067i-0W for submit@debbugs.gnu.org; Tue, 06 Dec 2022 12:34:56 -0500 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 1p2bqD-0007nv-Kz for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 12:34:55 -0500 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2bqB-0003Tk-3Z for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 12:34:49 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id D78822000A for ; Tue, 6 Dec 2022 17:34:42 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.200; envelope-from=juri@linkov.net; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:250134 Archived-At: 1. C-x 4 d RET C-h C-t q q -- the bottom window is NOT deleted 2. C-x 4 d RET C-h C-t C-x k RET q -- the bottom window is deleted 3. C-x 4 d RET C-h C-n C-x k RET q -- the bottom window is NOT deleted The accidental difference between the last two is that the former uses `switch-to-buffer' whereas the latter uses `pop-to-buffer-same-window'. The root of the problem is that displaying a buffer in an existing window, or quitting a buffer in an existing window overwrites its window parameter `quit-restore', and thus invalidates the history of how the first window was displayed. A partial fix that solves only the first test case above is at least not to overwrite `quit-restore' on quitting other buffers in the same window: ``` diff --git a/lisp/window.el b/lisp/window.el index a11293d372a..e3b057599d5 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5275,14 +5276,14 @@ quit-restore-window (set-window-prev-buffers window (append (window-prev-buffers window) (list entry)))) ;; Reset the quit-restore parameter. - (set-window-parameter window 'quit-restore nil) ;; Select old window. ;; If the previously selected window is still alive, select it. (window--quit-restore-select-window quit-restore-2)) (t ;; Show some other buffer in WINDOW and reset the quit-restore ;; parameter. - (set-window-parameter window 'quit-restore nil) ;; Make sure that WINDOW is no more dedicated. (set-window-dedicated-p window nil) ;; Try to switch to a previous buffer. Delete the window only if ``` But the proper fix for other problems would be to replace the window parameter `quit-restore' currently shared by all buffers in the same window by a stack where every window buffer should keep own quit-restore data. There is already such a stack in `window-prev-buffers', so a possible solution would be to add quit-restore data to each buffer in window-prev-buffers. Alternatively, it would be nice to have an option that would prevent overwriting the initial value of the window parameter `quit-restore', thus `quit-restore-window' could delete the window regardless of how many buffers were displayed in that window, like it does in case of dedicated windows.