Q: is there a way to set different scroll margins at the top and bottom of a window?
The variable scroll-margin
(defined in the C source code) sets how many lines of text that Emacs displays, at a minimum, at the top and bottom of a window:
Number of lines of margin at the top and bottom of a window. Recenter the window whenever point gets within this many lines of the top or bottom of the window.
I'd like to use scroll-margin
for the bottom of the window, but don't want it at the top (e.g., a positive value at the bottom, but 0 at the top). Is there a way to do so?
scroll-margin
is not the right tool for the job. You may need some function to put onpost-command-hook
to determine whether to scroll the window. – Harald Hanche-Olsen Jan 19 '15 at 15:29(top . bottom)
forscroll-margin
. – Harald Hanche-Olsen Jan 19 '15 at 17:25window-scroll-functions
hook (which takes two arguments) and putting arecenter
command into a function attached to that hook and then use a setting of(setq scroll-conservatively 101)
-- in essence, you define when recentering occurs and turn off the built-in auto-scroll. Something like(when (and (>= (point) (window-end nil t)) (not (pos-visible-in-window-p (point) (get-buffer-window (current-buffer) (selected-frame))))) (recenter))
– lawlist Jan 19 '15 at 18:41