Subject: bug#18739: 24.3; Request for a hook to be provided when scrolling will move the cursor

From: Stefan Monnier <[email-masked]>
Date: Fri, 17 Oct 2014 09:04:05 -0400

> I'm not sure I get your point.  But if you mean to say something that
> is already said in the doc string, i.e.

>   List of functions to call before redisplaying a window with scrolling.
>   [...] Note that these functions are also called by `set-window-buffer'.

> then I'm okay with that.

No, I'm trying to find a definition that justifies *why*
set-window-buffer runs the hook.  `set-window-buffer' changes the
window-start marker to point into another buffer (except when
set-window-buffer is basically a no-op), so saying "the hook is run
whenever the window-start marker is modified" does explain why
set-window-buffer should run the hook.  It also explains why
split-window should run the hook.

> I don't like this "conclusion", because it can be interpreted as
> meaning that moving the window-start marker _causes_
> window-scroll-functions to be called.

No, it just means that moving the marker creates the need for Emacs to run
the hook.

>> >> Playing with it, I see that this code is triggered very rarely.
>> > As it should be.  It is mainly meant for scrolling commands.
>> By "rarely" I meant, "rarely even while scrolling".  The only "normal"
>> case where it seems to be triggered is if I scroll by moving the
>> scrollbar's thumb.
> That's not my reading of the code.  (Not sure why it matters, though.)

I don't understand the code nearly enough, so instead I asked fprintf,
and she sounded pretty definitive ;-)

> If the window's force_start flag is set when redisplay is entered,
> then my reading of the code is that window-scroll-functions will be
> called even if point doesn't have to move.

I'm not talking about calling window-scroll-functions, I'm talking about
moving point (a bit further down in the redisplay_window function).

> Maybe so, but (a) I again don't understand why the frequency matters,

It doesn't.  I was just pointing out that this is not the main place
where scrolling moves point.

>> I'm not sure I understand.  If I want to catch all (i.e. exhaustively)
>> cases where scrolling moves point, do you think that catching the
>> redisplay_window case plus the window_scroll_pixel/line_based cases is
>> all that's needed?
> Yes, I think so.

OK, thanks,

        Stefan