By default, the page up and page down keys in Emacs move the screen up and down, not the point. As a result, if the screen is already at the bottom of the buffer, page down does nothing.
I don’t know about you, but this annoys me. Even if the screen is at the bottom of the buffer, I want page down to move the point to the bottom of the buffer if it’s not already there. So, I set out to make page up and page down move the point up and down a page. The screen should also scroll to follow it, if necessary, but that should be a side effect.
I first looked at pager.el. It’s close - it moves the point, not the screen – but it still errors if the screen is already at the end of the buffer.
I next looked at
which comes with Emacs (in pc-mode.el). It binds page down and page up to
scroll-up-nomark, which do what I want, but they also
disable the mark. Argh!
So, I stole the code and hacked it to leave the mark alone. I ended up with this elisp, which makes page up and page down behave exactly the way I want:
;; Page down/up move the point, not the screen. ;; In practice, this means that they can move the ;; point to the beginning or end of the buffer. (global-set-key [next] (lambda () (interactive) (condition-case nil (scroll-up) (end-of-buffer (goto-char (point-max)))))) (global-set-key [prior] (lambda () (interactive) (condition-case nil (scroll-down) (beginning-of-buffer (goto-char (point-min))))))