GNU bug report logs - #59862
quit-restore per window buffer

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 6 Dec 2022 17:35:02 UTC

Severity: normal

To reply to this bug, email your comments to 59862 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59862; Package emacs. (Tue, 06 Dec 2022 17:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 06 Dec 2022 17:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: quit-restore per window buffer
Date: Tue, 06 Dec 2022 19:32:05 +0200
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.




This bug report was last modified 1 year and 149 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.