I would like the PgUp and PgDn keys to simply move the contents of the displayed file up or down, but the cursor (the point in Emacs Lingo) should stay where it is (on the screen). Unfortunately, the default behavior of Emacs is different. The default behavior is hard to describe, but if you press PgDn and then PgUp , you wonβt be where you were before (!).
This is not a new problem, and there is a good solution called sfp-page-up and sfp-page-down in EmacsWiki .
(defun sfp-page-up () (interactive) (setq this-command 'previous-line) (previous-line (- (window-text-height) next-screen-context-lines)))
However, there is one problem in combination with cua- mode, which provides (among other things) shift-selection (pressing Shift and the cursor key of type β or PgDn starts selecting the selected area):
cua-mode does not recognize overridden PgUp / PgDn keys, i.e. they do not start the selection. The workaround is to press the β or β key first, and then continue with PgUp / PgDn .
How can I make cua-mode play nicely with sfp-page-up/down ?
source share