Subject: Re: bug#64596: 30.0.50; On FIXME: in src/buffer.c:1481 (force-mode-line-update)

From: Eli Zaretskii <[email-masked]>
Date: Sun, 16 Jul 2023 07:57:07 +0300

> From: Ihor Radchenko <[email-masked]>
> Cc: Stefan Monnier <[email-masked]>, [email-masked]
> Date: Sat, 15 Jul 2023 19:43:17 +0000
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > The actual issue with the above is different: it implies that
> > update_mode_lines _always_ indicates that more than a single mode line
> > should be updated (which is why we need to "consider all windows").
> > But is that actually true, i.e. does every place that assigns non-zero
> > to update_mode_lines indeed perform a change which makes it
> > _necessary_ to consider non-selected windows?
> 
> At least, when the current buffer is only displayed in a single,
> selected window, checking every window should not be necessary.

The code which sets update_mode_lines doesn't know whether the current
buffer will be displayed in a single window by the time redisplay
kicks in.  It doesn't even know whether it will still be the current
buffer by that time.  Because the Lisp program that is running and
making the changes which cause update_mode_lines to be set can change
these things before it finishes.

These global variables come from the time when the Emacs redisplay was
much less selective.  It basically has only two modes: either
redisplay only the selected window, or redisplay all the windows on
all the frames.  (Here "redisplay" means "examine for redisplay and
decide whether and which parts need that", not necessarily "actually
redraw".)  When the various 'redisplay' flags were added, the intent
was to make redisplay more selective, so that it could completely
refrain from examining windows on a certain frame, for example.  The
right way to keep advancing in that direction is to extend these flags
and maybe introduce more flags that will describe the need to
redisplay in more detail.  Global variables such as update_mode_lines
can do that only if they provide specific values to describe each
required aspect of redisplay.  But in any case, the code which sets
the variable cannot make decisions for redisplay, it can only describe
the changes for redisplay to consider.