Subject: bug#20236: 25.0.50; Feature Request: scroll-other-window does not allow setting of scroll function

From: Juri Linkov <[email-masked]>
Date: Thu, 02 Dec 2021 19:41:20 +0200

>>> the c-code scroll-other-window functions do not allow specification of
>>> the function to be used for scrolling, which means they have problems
>>> with other-window modes like Info and PDF-View.  It would be
>>> tremendously useful if support for dynamic setting of the
>>> scroll-other-window functions would be allowed (based on the mode of
>>> other-window).
>>
>> Agreed.  Patch welcome.
>
> Hm...  I don't think modes explicitly define a scrolling command -- they
> just rebind <next> etc?
>
> So for this to work, we'd have to introduce a scroll-command variable
> that buffers could set locally, and then have scroll_command call that
> instead of doing its thing if it's set?
>
> Anybody have an opinion here?

Looks like this could be useful in e.g. `follow-mode'.
`follow-mode-map' binds only these keys:

    (define-key map "\C-v"	#'follow-scroll-up)
    (define-key map "\M-v"	#'follow-scroll-down)

So users of follow-mode need to add more customization:

  (with-eval-after-load 'follow
    (define-key follow-mode-map [prior] 'follow-scroll-down)
    (define-key follow-mode-map [next]  'follow-scroll-up))

that still doesn't work in view-mode where
the scrolling key SPC is bound to View-scroll-page-forward.

Oh, wait a sec.  Maybe remapping is sufficient.

And indeed, everything is achievable with just:

  (with-eval-after-load 'follow
    (define-key follow-mode-map [remap scroll-up-command] #'follow-scroll-up)
    (define-key follow-mode-map [remap scroll-down-command] #'follow-scroll-down)
    (define-key follow-mode-map [remap View-scroll-page-forward] #'follow-scroll-up)
    (define-key follow-mode-map [remap View-scroll-page-forward-set-page-size] #'follow-scroll-up)
    (define-key follow-mode-map [remap View-scroll-page-backward] #'follow-scroll-down))