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

From: Josh <[email-masked]>
Date: Thu, 16 Oct 2014 08:58:25 -0600

On Thu, Oct 16, 2014 at 8:46 AM, Eli Zaretskii wrote:
>> > I meant set the mark as part of the command that is run by the wheel
>> > scroll, or manually just before you scroll.
>>
>> If I configure the scroll wheel to set the mark every time I use it,
>> then imagine how many times I might have to pop the mark to get back
>> where I started if I scrolled down multiple screens.
>
> If repeated use of mouse-wheel scroll is the issue, you can avoid
> multiple settings or the mark by looking at last-command and
> this-command.  There are already Emacs commands that behave
> differently depending on whether they are repeated or not; one
> prominent example is C-n and C-p.  So there are examples you could
> study to see how this technique is applied.

I feel like this conversation is missing the point (no pun intended).
Let me restate the problem: I am looking for a way to maintain cursor
position within a buffer, even when other events cause that position
to be moved beyond the edges of the window.

There are so many ways that this can happen that it is not possible to
advise every function that might do it.  It is possible that
window-scroll-functions will give me everything I need, but I haven't
had time to try it yet.  We can resume this conversation at such a
time, unless there is someone else who already knows that
window-scroll-functions will not work.