Subject: bug#78835: Wrong pop-to-buffer behavior after one display-buffer-in-side-window call

From: martin rudalics <[email-masked]>
Date: Mon, 14 Jul 2025 16:53:51 +0200

> In that particular scenario 'C-x v =' called in the window.el buffer popped up the diff buffer which increased the width of the left window (not sure why).

You typed C-x v = in a configuration with two side-by-side windows,
right?

 > And then pressing 'q' in it restored that width.

If the width changed after displaying the buffer, this is the expected
behavior.

 > If you could come up with some logging code, I'll be sure to install
 > it. Or not logging but something to be called when the problem does
 > happen (if something in the configuration history can trigger it?)

Try the following - it should size the window back iff you type 'y'.

diff --git a/lisp/window.el b/lisp/window.el
index e229562163b..05c33665a8a 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5457,7 +5457,8 @@ quit-restore-window
        (when (and (integerp (nth 3 quad))
  		 (if (window-combined-p window)
                       (/= (nth 3 quad) (window-total-height window))
-                   (/= (nth 3 quad) (window-total-width window))))
+                   (/= (nth 3 quad) (window-total-width window)))
+		 (y-or-n-p (format "%s ... %s " quit-restore quad)))
  	;; Try to resize WINDOW to its old height but don't signal an
  	;; error.
  	(condition-case nil

Here I can trigger it as follows with emacs -Q: Show window.el in a left
window and a *Help* buffer in the right window.  The ‘quit-restore’
parameter of the *Help* window is

(window window #<window 3 on window.el> #<buffer *Help*>)

Now I do C-x v = in the left window which displays the diff buffer in
the right window but does _not_ change its width.  Next I change the
width of the right window by dragging the mode line divider with the
mouse, type 'q' in the right window and am asked

(window window #<window 3 on window.el> *Help*) ... (*Help* 1 #<marker at 1160 in *Help*> 93) (y or n) y

where the 93 is the previous width which gets restored if I type 'y'.
What do you get?

martin