annotate lisp/scroll-lock.el @ 70176:92dfa83b08e5 mh-e-doc-7_94

Release MH-E manual version 7.94. * mh-e.texi (VERSION, EDITION, UPDATED, UPDATE-MONTH): Update for release 7.94.
author Bill Wohler <wohler@newt.com>
date Fri, 21 Apr 2006 22:36:37 +0000
parents 3bd95f4f2941
children e3694f1cb928
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
65035
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; scroll-lock.el --- Scroll lock scrolling.
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65125
diff changeset
3 ;; Copyright (C) 2005, 2006 Free Software Foundation, Inc.
65035
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Maintainer: FSF
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Created: 2005-06-18
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with this program; see the file COPYING. If not, write to
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; By activating Scroll Lock mode, keys for moving point by line or
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; paragraph will scroll the buffer by the respective amount of lines
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; instead. Point will be kept vertically fixed relative to window
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; boundaries.
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;; Code:
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 (defvar scroll-lock-mode-map
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (let ((map (make-sparse-keymap)))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 (define-key map [remap next-line] 'scroll-lock-next-line)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (define-key map [remap previous-line] 'scroll-lock-previous-line)
65038
588913d78aaf Fix errors due to incorrect line wrapping.
Kim F. Storm <storm@cua.dk>
parents: 65035
diff changeset
39 (define-key map [remap forward-paragraph] 'scroll-lock-forward-paragraph)
588913d78aaf Fix errors due to incorrect line wrapping.
Kim F. Storm <storm@cua.dk>
parents: 65035
diff changeset
40 (define-key map [remap backward-paragraph] 'scroll-lock-backward-paragraph)
65035
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 map)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 "Keymap for Scroll Lock mode.")
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (defvar scroll-lock-preserve-screen-pos-save scroll-preserve-screen-position
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 "Used for saving the state of `scroll-preserve-screen-position'.")
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (make-variable-buffer-local 'scroll-lock-preserve-screen-pos-save)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (defvar scroll-lock-temporary-goal-column 0
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 "Like `temporary-goal-column' but for scroll-lock-* commands.")
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;;;###autoload
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (define-minor-mode scroll-lock-mode
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 "Minor mode for pager-like scrolling.
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 Keys which normally move point by line or paragraph will scroll
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 the buffer by the respective amount of lines instead and point
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 will be kept vertically fixed relative to window boundaries
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 during scrolling."
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 :lighter " ScrLck"
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 :keymap scroll-lock-mode-map
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (if scroll-lock-mode
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (progn
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (setq scroll-lock-preserve-screen-pos-save
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 scroll-preserve-screen-position)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (set (make-local-variable 'scroll-preserve-screen-position) 'always))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (setq scroll-preserve-screen-position
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 scroll-lock-preserve-screen-pos-save)))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (defun scroll-lock-update-goal-column ()
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 "Update `scroll-lock-temporary-goal-column' if necessary."
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (unless (memq last-command '(scroll-lock-next-line
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 scroll-lock-previous-line
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 scroll-lock-forward-paragraph
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 scroll-lock-backward-paragraph))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (setq scroll-lock-temporary-goal-column (current-column))))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (defun scroll-lock-move-to-column (column)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 "Like `move-to-column' but cater for wrapped lines."
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (if (or (bolp)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;; Start of a screen line.
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (not (zerop (mod (- (point) (line-beginning-position))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (window-width)))))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (move-to-column column)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (forward-char (min column (- (line-end-position) (point))))))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (defun scroll-lock-next-line (&optional arg)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 "Scroll up ARG lines keeping point fixed."
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (interactive "p")
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (or arg (setq arg 1))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (scroll-lock-update-goal-column)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (if (pos-visible-in-window-p (point-max))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (next-line arg)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (scroll-up arg))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (defun scroll-lock-previous-line (&optional arg)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 "Scroll up ARG lines keeping point fixed."
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (interactive "p")
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (or arg (setq arg 1))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (scroll-lock-update-goal-column)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (condition-case nil
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (scroll-down arg)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (beginning-of-buffer (previous-line arg)))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (defun scroll-lock-forward-paragraph (&optional arg)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 "Scroll down ARG paragraphs keeping point fixed."
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (interactive "p")
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (or arg (setq arg 1))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (scroll-lock-update-goal-column)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (scroll-up (count-screen-lines (point) (save-excursion
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (forward-paragraph arg)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (point))))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (defun scroll-lock-backward-paragraph (&optional arg)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 "Scroll up ARG paragraphs keeping point fixed."
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (interactive "p")
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (or arg (setq arg 1))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (scroll-lock-update-goal-column)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (let ((goal (save-excursion (backward-paragraph arg) (point))))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (condition-case nil
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (scroll-down (count-screen-lines goal (point)))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (beginning-of-buffer (goto-char goal))))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (provide 'scroll-lock)
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
65125
bb897fec166c Add arch tagline
Miles Bader <miles@gnu.org>
parents: 65038
diff changeset
128 ;; arch-tag: 148fc8e8-67e0-4638-bb34-3291595ab7e1
65035
126c81827d58 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;;; scroll-lock.el ends here