Subject: bug#61307: 30.0.50; pixel-scroll-precision-mode: window-scroll-functions?

From: Eli Zaretskii <[email-masked]>
Date: Tue, 14 Feb 2023 15:06:36 +0200

> From: Michael Heerdegen <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 14 Feb 2023 02:30:10 +0100
> 
> > Because you might make scrolling much slower if you call the scroll
> > functions every pixel.
> 
> Sorry that I repeat myself, but I don't understand why that would
> happen.  This is what I tried:
> 
> *** /tmp/ediffnuE8b2	2023-02-14 02:24:24.300444006 +0100
> --- /home/micha/software/emacs/lisp/pixel-scroll.el	2023-02-14 02:20:40.472154353 +0100
> ***************
> *** 725,731 ****
>                       (beginning-of-buffer
>                        (message (error-message-string '(beginning-of-buffer))))
>                       (end-of-buffer
> !                      (message (error-message-string '(end-of-buffer))))))))))
>         (mwheel-scroll event nil))))
> 
>   (defun pixel-scroll-kinetic-state (&optional window)
> --- 725,733 ----
>                       (beginning-of-buffer
>                        (message (error-message-string '(beginning-of-buffer))))
>                       (end-of-buffer
> !                      (message (error-message-string '(end-of-buffer))))))
> !                 (run-hook-with-args 'window-scroll-functions
> !                                     (selected-window) (window-start))))))
>         (mwheel-scroll event nil))))
> 
>   (defun pixel-scroll-kinetic-state (&optional window)
> 
> I don't see the hook called for each pixel.  What do you mean?

Each time you do the smallest possible scroll, by how many pixels, or
by what fraction of the screen-line's height does Emacs scroll the
window?  IOW, by how many pixels is the display scrolled for each call
to window-scroll-functions?

Precision pixel-scrolling supports many different devices (mice and
touch-pads), which can scroll at very different resolutions.  The
possibility that window-scroll-functions be called too frequently
depends on what exactly do your device and your Emacs build support in
this scenario, and I don't yet have a clear idea about that, since you
didn't tell.

> A second thing I wonder about: the docstring of
> `window-scroll-functions' says:
> 
> | These functions are called whenever the `window-start' marker is modified,
> | either to point into another buffer (e.g. via `set-window-buffer') or another
> | place in the same buffer.
> 
> Is this correct and complete?

More or less.  (I don't like how it explains this stuff by using
internal implementation detail, but I cannot think of a better
explanation that is still accurate enough.)

> Is the window-start marker modified in our scenario?

Not in the way that the "usual" scrolling commands do.  This mode uses
non-nil 3rd argument to set-window-start.  So the display engine
doesn't know that the window is scrolled.