title: Emacs: Is there a better PgDn/PgUp behaviour with cua-mode?
body: <p>I'd like the <kbd>PgUp</kbd> and <kbd>PgDn</kbd> keys to just move the contents of the shown file upwards or downwards, but the cursor (<em>point</em> in Emacs Lingo) should stay where it is (on the screen). Unfortunately the default Emacs behaviour is different. The default behaviour is difficult to describe, but if you press <kbd>PgDn</kbd> followed by <kbd>PgUp</kbd> you don't end up where you were before (!).</p>
  
  <p>This is not a new problem and there exists a nice solution called <a href="http://www.emacswiki.org/emacs/Scrolling" rel="nofollow">sfp-page-up and sfp-page-down</a> in the <a href="http://www.emacswiki.org/emacs/EmacsWiki" rel="nofollow">EmacsWiki</a>.</p>
  
  <pre><code>(defun sfp-page-up ()
    (interactive)
    (setq this-command 'previous-line)
    (previous-line
     (- (window-text-height)
        next-screen-context-lines)))
  </code></pre>
  
  <p>There is one problem, however, in combination with <a href="http://www.cua.dk/cua.html" rel="nofollow">cua</a>-mode, which provides (among others) shift-selection (pressing <kbd>Shift</kbd> and a Cursor movement key like <kbd>&larr;</kbd> or <kbd>PgDn</kbd> starts highlighting a selected area):</p>
  
  <p><code>cua-mode</code> doesn't recognise the redefined <kbd>PgUp</kbd>/<kbd>PgDn</kbd> keys, i.e. they don't start a selection. The workaround is to press first the <kbd>&uarr;</kbd> or <kbd>&darr;</kbd> key and then continue with <kbd>PgUp</kbd>/<kbd>PgDn</kbd>.</p>
  
  <p>How can I make <code>cua-mode</code> play nicely with <code>sfp-page-up/down</code>?</p>