I like a scroll margin of around 8 or so. This means the buffer will start scrolling when the cursor gets within 8 lines of the top or bottom. However, this scheme does not work well with eshell and ansi-term buffers, isql buffers, or any REPL buffers that one might use with emacs. In any of those buffers, when one does anything, it immediately scrolls the buffer up so that there are 8 lines between the bottom of the buffer and the input line, making it awkward at best, unusable at worst, to use any terminal-like buffer in emacs, depending on the situation.
No buffer seems to recognize the scroll-margin variable unless it is global. So while I can set the variable to different values with hooks in different modes, it affects all of my open buffers.
So lets say I'm editing some code. I decide to do some stuff in a shell. My shell-mode-hooks set the scroll-margin to 0 (so that they may be usable). Then the scroll-margin is set to 0 for all buffers, making it awkward to scroll in my coding buffers. But then if I open a new coding buffer, it will set my scroll-margin back to 8. Then my shell buffers are awkward or unusable because it immediately scrolls up 8 spaces whenever they get focus or display output from a command.
Is there any solution to this problem, other than to keep a scroll-margin of 0, globally, for all buffers?