;;; pager.el --- windows-scroll commands1;;; Version 2.0 - 97-10-062;;; Copyright (C) 1992-1997 Mikael Sj�din ([email protected])3;;;4;;; Author: Mikael Sj�din -- [email protected]5;;;6;;; This file is NOT part of GNU Emacs.7;;; You may however redistribute it and/or modify it under the terms of the GNU8;;; General Public License as published by the Free Software Foundation; either9;;; version 2, or (at your option) any later version.10;;;11;;; pager.el is distributed in the hope that it will be useful,12;;; but WITHOUT ANY WARRANTY; without even the implied warranty of13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14;;; GNU General Public License for more details.1516;;; ----------------------------------------------------------------------17;;; Description:18;;;19;;; pager.el defines alternative commands to the Emacs builtins: scroll-down20;;; and scroll-up. It also contains commands to scroll the screen one row at21;;; the time.22;;;23;;; The Emacs builtins for scrolling are worthless! The commands in pager.el24;;; works the way the builtins should have done from the beginning. For25;;; instance, doing a pg-up followed by a pg-down (when using pager.el) will26;;; return point to the original place.27;;;28;;; This file has been tested under Emacs 19.34 and 20.2 but I belive it should29;;; work on most Emacs versions and Emacs derivatives.30;;;31;;; This file can be obtained from http://www.docs.uu.se/~mic/emacs.html3233;;; ----------------------------------------------------------------------34;;; Installation:35;;;36;;; o Place this file in a directory in your load-path.37;;; o Put the following in your .emacs file:38;;; (require 'pager)39;;; (global-set-key "\C-v" 'pager-page-down)40;;; (global-set-key [next] 'pager-page-down)41;;; (global-set-key "\ev" 'pager-page-up)42;;; (global-set-key [prior] 'pager-page-up)43;;; (global-set-key '[M-up] 'pager-row-up)44;;; (global-set-key '[M-kp-8] 'pager-row-up)45;;; (global-set-key '[M-down] 'pager-row-down)46;;; (global-set-key '[M-kp-2] 'pager-row-down)47;;; o Restart your Emacs.48;;; o pager.el is now installed. Use the normal keys to scroll a full page and49;;; M-up resp. M-down to scroll just one row up or down.5051;;; ----------------------------------------------------------------------52;;; Versions:53;;; 2.0 Renamed interface functions (kept old-ones as aliases)54;;; Complete reimplementation, old version where not working well in Emacs55;;; 20.56;;;57;;; 1.0 Initial Release5859;;; ======================================================================60;;; Internal variables6162(defvar pager-temporary-goal-column 063"Similat to temporary-goal-column byt used by the pager.el functions")64;(make-variable-buffer-local 'pager-temporary-goal-column)6566(defconst pager-keep-column-commands67'(pager-row-down pager-row-up row-dn row-up68pager-page-down pager-page-up pg-dn pg-up)69"Commands which when called without any other intervening command should70keep the `pager-temporary-goal-column'")7172;;; ======================================================================73;;; Commands7475;;; pager 1.0 compatibility76(defalias 'pg-dn 'pager-page-down)77(defalias 'pg-up 'pager-page-up)78(defalias 'row-dn 'pager-row-down)79(defalias 'row-up 'pager-row-up)8081;; ----------------------------------------------------------------------8283(defun pager-page-down ()84"Like scroll-up, but moves a fixed amount of lines (fixed relative the85`window-height') so that pager-page-up moves back to the same line."86(interactive)87(if (not (pos-visible-in-window-p (point-max)))88(pager-scroll-screen (- (1- (window-height))89next-screen-context-lines))))9091(defun pager-page-up ()92"Like scroll-down, but moves a fixed amount of lines (fixed relative the93`window-height') so that pager-page-down moves back to the same line."94(interactive)95(if (not (pos-visible-in-window-p (point-min)))96(pager-scroll-screen (- next-screen-context-lines97(1- (window-height))))))9899;; ------------------------------100101(defun pager-scroll-screen (lines)102"Scroll screen LINES, but keep the cursors position on screen."103(if (not (memq last-command pager-keep-column-commands))104(setq pager-temporary-goal-column (current-column)))105(save-excursion106(goto-char (window-start))107(forward-line lines)108(set-window-start (selected-window) (point)))109(forward-line lines)110(move-to-column pager-temporary-goal-column))111112113;; ----------------------------------------------------------------------114115(defun pager-row-up ()116"Move point to previous line while scrolling screen down one line.117The effect is that the cursor stays in the same position on the screen."118(interactive)119(if (not (memq last-command pager-keep-column-commands))120(setq pager-temporary-goal-column (current-column)))121(if (not (pos-visible-in-window-p (point-min)))122(scroll-down 1))123(forward-line -1)124(move-to-column pager-temporary-goal-column)125)126127(defun pager-row-down ()128"Move point to next line while scrolling screen up one line.129The effect is that the cursor stays in the same position on the screen."130(interactive)131(if (not (memq last-command pager-keep-column-commands))132(setq pager-temporary-goal-column (current-column)))133(if (not (pos-visible-in-window-p (point-max)))134(scroll-up 1))135(if (<= (point) (point-max))136(forward-line 1))137(move-to-column pager-temporary-goal-column)138)139140;; ----------------------------------------------------------------------141142(provide 'pager)143144145146147