Subject: Re: bug#56305: 29.0.50; 'yes-or-no-p' deselects minibuffer frame

From: martin rudalics <[email-masked]>
Date: Mon, 18 Jul 2022 09:37:35 +0200

> In case you intend to fix this apparent blunder of mine: the point of
 > that commit was to set the selected window and frame so that ELisp code
 > run from the `mode-line-format` would see meaningful and consistent
 > values of selected-frame/window (and companions like the
 > frame-selected-window of the selected-frame, ...).

How are display_mode_line or display_mode_lines affected by that commit?

As an aside: 'mode-line-format' claims that it is a

   Template for displaying mode line for current buffer.

which is misleading at least.  A mode line belongs to a window and
reflects the values used for displaying a buffer in that window.
Whatever consistency we want here is necessitated by the fact that
redisplay has to set up the current buffer appropriately ('window-point'
replacing the buffer's point, for example, so line numbers, percentages
or 'which-func-mode' appear correct).  Elisp code hardly cares.

Worse even: People who want to know, for example, whether the mode line
belongs to the selected window have to use 'old-selected-window' for
getting that.  Whether a window is "really" selected is ultimately
hidden by Kim's face trick for displaying selected/non-selected windows'
mode lines.

And by no means I'd ask for changing this.  But a better explanation in
the doc-strings and the manual should be in order.  End of the aside.

 > If calling `Fselect_window` with a non-nil `norecord` argument messes
 > things up somehow then maybe we should fix `Fselect_window` accordingly,
 > or otherwise provide a "more bare bones" function that DTRT.
 >
 > It seems clear to me, for example, that when called with a non-nil
 > `norecord` (like in the mode-line code), `Fselect_window` should never
 > cause any change to the focus redirection (or the focus itself).

NORECORD is not about focus.

 > And neither should it call things like `resize_mini_window`, I think.
 >
 >> In the sequel, obscure bugs began to pile up, all very difficult to
 >> describe and reproduce (Bug#23124, Bug#24285, Bug#34317) and were fixed
 >> with some trickery.  The origin of all that evil remained in place.
 >
 > I can't see the connection between these bugs at the above commit, sorry.

They are a direct result of x/gui_consider_frame_title calling
Fselect_window calling resize_mini_window and were fixed by binding
'inhibit-redisplay' appropriately in x/gui_consider_frame_title.

martin