Subject: Re: bug#17678: 24.4.50; Feature Request -- calculate new `window-start` & `window-end` before visual redisplay

From: Eli Zaretskii <[email-masked]>
Date: Wed, 11 Jun 2014 21:45:31 +0300

> From: Stefan Monnier <[email-masked]>
> Date: Wed, 11 Jun 2014 14:00:39 -0400
> Cc: [email-masked]
> 
> > I believe that the solution may be to have a `sneak-preview-redisplay`
> > whereby the *new* `window-start` and *new* `window-end` could be
> > correctly calculated without the visual buffer actually
> > being redisplayed.
> 
> Of course, there's a circularity problem, here: if you need window-start
> (you can already compute window-end without an actual redisplay) in
> order to then install things like text-properties properties and
> overlays that affect the display, then those added properties may end up
> requiring changing window-start again (because they end up pushing point
> outside of the window and require a scroll).

Indeed.  But if there's a hook that is forbidden from making such
changes to buffer text, then this is doable.  Otherwise, it's a waste
of time having such a hook, since it will be unreliable.

> IIUC your particular use case (drawing crosshairs to show where the
> cursor is located) is one where what you really need is to know when
> window-start changes (just like follow-mode).
> 
> So, a good feature might be one that runs a hook when redisplay decides
> that window-start needs to be reset (i.e. that point moved out of the
> window and we need to scroll).

The display engine changes window-start for several reasons, only one
of them being that point moved off screen.

I think follow-mode also needs to know when the window-end changes
(which could happen with no changes in window-start).  This is
normally known only at the end of window redisplay, IIRC.