alphapapa / scrollkeeper.el

Configurable scrolling commands with visual guidelines, for Emacs
GNU General Public License v3.0
28 stars 1 forks source link

indicate when previous-line/next-line scrolls the text? #1

Open emacsomancer opened 5 years ago

emacsomancer commented 5 years ago

Is there any way of getting similar behaviour for previous-line/next-line (C-p/C-n) when moving to the next/previous line triggers movement of the text? It would be nice to have a similar sort of indication as for the page/half-page movement. (I'm not sure what function is called when previous-line/next-line hits a 'scroll boundary'.)

alphapapa commented 5 years ago

Hi,

You're right, that would be a great feature, but with a quick look, I can't find a way to do that, other than possibly rewriting much of Emacs's lisp-based scrolling code.

Looking at the manual section (emacs)Display, under Scrolling, Recentering, and Auto Scrolling, it says that the display is recentered, depending on several variables, when point goes off-screen. But from my testing and looking at the code, the recenter function is not actually called; it all happens in C code from xdisp.c, and those functions don't seem to be exposed to lisp, so there's no way to advise them, and there don't seem to be any relevant hooks.

I'm guessing that, for someone who knows C and Emacs well, it wouldn't be too difficult to add a before-recenter hook here or there that would allow us to do that. One other thing we'd need, ideally, is to be able to know which way the window is scrolling, so we'd know whether to highlight the top or bottom line. If there were such a hook, maybe its functions could be called with an argument that would reveal that information.

If I'm right that this would be relatively simple and harmless to add to the C code, maybe it would be worth proposing on emacs-devel. Of course, I know little about this side of Emacs, so I may be wrong.

What do you think?

emacsomancer commented 5 years ago

Hi,

Yes, I was hoping that there was already some hook or relevant function for scrolling the page that could be easily leveraged. The C code behind Emacs is mysterious to me, but it sounds like it should be simple enough to add the relevant hook for someone with the right knowledge of C.

alphapapa commented 5 years ago

I'll leave this as help-wanted for now. :)