bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#46904: Non-unique windows produced by window-state-put


From: Juri Linkov
Subject: bug#46904: Non-unique windows produced by window-state-put
Date: Tue, 27 Apr 2021 20:19:21 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> I don't know how severe are the consequences.  The only side-effect I noticed
>> that prev-buffers of restored windows are the same on different tabs because
>> they share the same window.
>
> If that is a problem and the above would help, let's do it.  It couldn't
> possibly harm unless the root window is too small to get split and we
> want to put only one window there; so we should handle that special case.

The original problem was that prev-buffers of restored windows are the
same on different tabs.  This was fixed by always creating a new window.
However, the same problem still exists, but for a different reason.

Most windows have current buffer duplicated in prev-buffers.  So when
set-window-prev-buffers in window--state-put-2 sets prev-buffers to a list
with only current buffer, this means as if there are no prev-buffers.

But when a window has an empty list of prev-buffers, then the window
parameter of prev-buffers is not cleared, and still contains a random
buffer from some previous state.  This patch fixes it:

diff --git a/lisp/window.el b/lisp/window.el
index 036eb271ee..fc4ca303b0 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -6140,7 +6140,8 @@ window--state-put-2
                                        (setq buffer (get-buffer buffer))
                                        (when (buffer-live-p buffer) buffer))
                                      next-buffers))))
-                (when prev-buffers
+                (if (not prev-buffers)
+                    (set-window-prev-buffers window nil)
                   (set-window-prev-buffers
                    window
                    (delq nil (mapcar (lambda (entry)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]