[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"Pager" page-up and -down, why not merge?

From: Adrian Robert
Subject: "Pager" page-up and -down, why not merge?
Date: Tue, 3 Jun 2008 16:57:38 -0400


The "pager" commands at:


seem to be an improvement over the existing definitions of scroll-down and scroll-up in emacs. In particular, hitting sequences like [next] or Ctrl-v followed by [previous] or M-v leaves point in the same place, which is very calming. ;-) Is there any reason these could not be incorporated into emacs to replace scroll-up and scroll-down in these bindings?

It was discussed before with no conclusion:


I'm including below an improved version of this lisp that is used in Emacs.app.


;;; page-down,page-up etc. leaves cursor in same place
;;; modified (ABR) from pager.el --- windows-scroll commands
;;; Version 2.0 - 97-10-06
;;; Copyright (C) 1992-1997 Mikael Sjodin (address@hidden)
;;; http://user.it.uu.se/~mic/emacs.shtml

(defvar pager-temporary-goal-column 0
"Similar to temporary-goal-column but used by the pager.el functions")
;(make-variable-buffer-local 'pager-temporary-goal-column)

(defconst pager-keep-column-commands
  '(pager-row-down pager-row-up row-dn row-up
                   pager-page-down pager-page-up pg-dn pg-up)
"Commands which when called without any other intervening command should
keep the `pager-temporary-goal-column'")

(defun pager-page-down ()
"Like scroll-up, but moves a fixed amount of lines (fixed relative the `window-text-height') so that pager-page-up moves back to the same line."
  (if (not (pos-visible-in-window-p (point-max)))
      (pager-scroll-screen (- (window-text-height)

(defun pager-page-up ()
"Like scroll-down, but moves a fixed amount of lines (fixed relative the `window-text-height') so that pager-page-down moves back to the same line."
  (if (not (pos-visible-in-window-p (point-min)))
      (pager-scroll-screen (- next-screen-context-lines

(defun pager-scroll-screen (lines)
  "Scroll screen LINES, but keep the cursors position on screen."
  (if (not (memq last-command pager-keep-column-commands))
      (setq pager-temporary-goal-column (current-column)))
    (goto-char (window-start))
    (vertical-motion lines)
    (set-window-start (selected-window) (point)))
  (vertical-motion lines)
  (move-to-column pager-temporary-goal-column))

(global-set-key "\C-v"     'pager-page-down)
(global-set-key [next]     'pager-page-down)
(global-set-key "\ev"      'pager-page-up)
(global-set-key [prior]    'pager-page-up)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]