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 17:45:18 +0300

> From: Stefan Monnier <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
> Date: Sun, 16 Jul 2023 10:26:10 -0400
> 
> My understanding of the redisplay code is that it's split into 3 part:
> 
> 1- decide which windows may need to be updated.

More accurately:

  1a - decide whether all the windows need to be considered, or just
       the selected window
  1b - if all the windows need to be considered, decide for each frame
       whether it needs to be considered, and if so, consider all of
       that frame's windows

Considering a window can sometimes decide very quickly that the window
doesn't need to be redisplayed, but, as I mentioned elsewhere, when
its frame's redisplay flag is set, we never decide that, and the
frame's redisplay flag is what causes us to consider a frame in the
first place.

> 2- update the glyph matrix of a window.

This update can be partial -- that's one of the redisplay
optimizations.  That is, we update only a very small part of the glyph
matrix, as small as a single glyph row (= screen line).

> 3- update the glass by comparing the old glyph matrix and the new one.
> 
> [ The point between 1 and 2 is made visible to ELisp via
>   `pre-redisplay-function`.  ]
> 
> The `redisplay` bits belong to step (1).
> The `prevent_display_optimizations_p` OTOH belong to step 2, AFAIU.

Yes.

> BTW, I wish those 3 steps were exposed to ELisp, so the top-level of
> redisplay could be moved to ELisp.  This would allow for example
> `follow-mode` to pick a more appropriate order in which to process the
> windows at step 2.

follow-mode needs much more than that.  But if you want to be able to
tell redisplay "update only this window and nothing else", I think it
should be easy to accomplish by adding a single function and no other
changes: all you need is to call 'redisplay' (which is already
exposed) after setting the redisplay flag of a single window.

> > Then, why not use uniform naming scheme and have the buffer/window/frame
> > flags names as maybe_redisplay and must_redisplay instead of different
> > flag name for different object type?
> 
> For that someone first needs to have a clear idea of what these things
> do and how they relate to each other :-)

Right.