Obviously Emacs never scrolls "above" the first line of the buffer. By contrast, it shows a bunch of empty space after the document if you scroll to the last line:

End-of-buffer whitespace

I want to make the bottom line behave the same way; essentially similar to this question:

Note that I'm not asking for a way to prevent the window moving past the document end entirely

except I am asking for exactly that. Naturally it can't be helped if the document is shorter than the screen, but scrolling doesn't happen in that case anyways.

My scrolling setup:

(setq-default redisplay-dont-pause t
              auto-window-vscroll nil
              scroll-margin 10
              scroll-step 1
              scroll-conservatively 101
              scroll-preserve-screen-position 1)

Am I right in feeling this can controlled by some variable, or do I have to modify the code from the question above?

Edit: It seems I was not clear enough in my original question. Here is a short video demonstration of the behavior I mean. Notice how when getting within the scroll margin at the top of the document, Emacs prevents movement above the document, but at the bottom it just pads the document with empty space.

  • 1
    I deleted my answer, because I misunderstood you. You should pack your demonstration video onto your question.
    – jue
    Mar 5, 2021 at 21:46
  • 1
    If you want a clearer indication of where the buffer ends, (setq-default indicate-empty-lines t) marks unused lines after the end of the buffer with an indicator in the left fringe. Not what you asked for of course, but hopefully useful to someone. Mar 6, 2021 at 19:31


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.