Subject: bug#44933: 27.1; Ephemeral frame selection shrinks minibuffer

From: martin rudalics <[email-masked]>
Date: Sun, 29 Nov 2020 09:22:00 +0100

> Selecting a different frame ephmerally (e.g. via `with-selected-frame`
 > in a timer callback) shrinks the minibuffer. This is true whether or not
 > the minibuffer is active.
 >
 > Reproduction steps:
 >
 > 1. Evaluate this form in the scratch buffer:
 >
 >     (run-with-timer nil 13 (lambda () (with-selected-frame
 >     (next-frame))))
 >
 > 2. Evaluate this form in the scratch buffer:
 >
 >     (run-with-timer nil 11 (lambda () (window-resize (minibuffer-window)
 >     10)))
 >
 > 3. Observe that the minibuffer grows and shrinks as the timers fire.

Here I need two frames to observe 3.  With one frame the minibuffer
window grows continuously.

 > You can run some completing read command (e.g. `M-x`) to see that the
 > resizing happens whether or not the minibuffer is active.
 >
 > This is relevant for completing read implementations that resize the
 > minibuffer to display a vertical list of candidates. I noticed the
 > behavior while using selectrum (https://github.com/raxod502/selectrum)
 > while I had a subprocess running under term in another frame. Since the
 > `term-emulate-terminal` function selects windows in the background
 > whenever the subprocess sends output, it was causing the selectrum
 > minibuffer to shrink.
 >
 > I'm not sure what the correct behavior is here, but this was unexpected
 > to me. I think that if the minibuffer is active, ephemeral frame or
 > window selections should not affect its size. (I'm less certain about
 > the inactive minibuffer case, but I think the size should stay the same
 > there as well.)

To my knowledge we have no means to select a frame "ephemerally".
'with-selected-frame', 'with-selected-window' are just as "hard" as
'select-frame' and 'select-window'.  And so the only way to prevent
switching frames from shrinking the previously selected frame's
minibuffer window is to set 'resize-mini-windows' to nil.  OTOH with
'resize-mini-windows' non-nil, re-selecting the previously selected frame
when returning from a 'with-selected-frame' should size its minibuffer
window back to its contents provided it is still active.  But I'm never
sure whether all these work as advertised.

martin