annotate lisp/emulators/scroll-lock.el @ 152:4c132ee2d62b

Added tag r20-3b2 for changeset 59463afc5666
author cvs
date Mon, 13 Aug 2007 09:37:21 +0200
parents b9518feda344
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
1 ;; @(#) scroll-lock.el -- scroll-locking minor mode
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
2
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
3 ;; Authors:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
4 ;; Gary D. Foster <Gary.Foster@corp.sun.com>
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
5 ;; with contributions/suggestions/ideas from:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
6 ;; Rick Macdonald <rickm@vsl.com>
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
7 ;; Anders Lindgren <andersl@csd.uu.se>
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
8 ;; $Revision: 1.1.1.1 $
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
9 ;; Keywords: scroll crisp brief lock
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
10
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
12
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
16 ;; any later version.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
17
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
22
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
27
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
28 ;; Commentary
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
29 ;; This mode allows multiple buffers to be 'locked' so that scrolling
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
30 ;; up or down lines in any buffer causes all the buffers to mirror
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
31 ;; the scrolling. It hooks into the post-command-hook to check for
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
32 ;; potential scrolling commands and if we're locked, mirrors them in all
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
33 ;; windows. This allows us to grab line-at-a-time scrolling as well as
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
34 ;; screen-at-a-time scrolling, and doesn't remap any of the keyboard
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
35 ;; commands to do it.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
36
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
37 ;; This minor mode is normally autoloaded from the scroll-lock package.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
38 ;; You can disable autoloading of this package by placing
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
39 ;; (setq crisp-load-scroll-lock nil) in your .emacs before loading
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
40 ;; the crisp package. If you want to use this package by itself,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
41 ;; you can enable it by placing the following in your .emacs:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
42
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
43 ;; (require 'scroll-lock)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
44
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
45 ;; In the first (autoloaded) case, meta-f1 is bound to the command to
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
46 ;; toggle the scroll-lock mode. In the second (non-autoloaded) case,
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
47 ;; you can enable and disable it with the 'scroll-lock-mode' command.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
48
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
49 (defvar scroll-lock-running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
50
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
51 (defvar scroll-lock-modeline-string " *SL*"
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
52 "String to display in the modeline when Scroll Lock mode is enabled.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
53
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
54 (defvar scroll-lock-is-locked nil
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
55 "Track status of scroll locking.")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
56 (if scroll-lock-running-xemacs
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
57 (add-minor-mode 'scroll-lock-is-locked scroll-lock-modeline-string)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
58 (or (assq 'scroll-lock-is-locked minor-mode-alist)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
59 (setq minor-mode-alist
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
60 (cons '(scroll-lock-is-locked scroll-lock-modeline-string) minor-mode-alist))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
61
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
62 (defun scroll-lock-scroll-down-all (arg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
63 "Scroll-down all visible windows."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
64 (interactive "P")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
65 (let ((num-windows (count-windows))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
66 (count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
67 (if (> num-windows 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
68 ( progn (other-window 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
69 (while (< count num-windows)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
70 (if (not (eq (point) (point-max)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
71 (progn (call-interactively 'next-line)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
72 (other-window 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
73 (setq count (1+ count)))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
74
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
75 (defun scroll-lock-scroll-up-all (arg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
76 "Scroll-up all visible windows."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
77 (interactive "P")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
78 (let ((num-windows (count-windows))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
79 (count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
80 (if (> num-windows 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
81 ( progn (other-window 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
82 (while (< count num-windows)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
83 (if (not (eq (point) (point-min)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
84 (progn (call-interactively 'previous-line)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
85 (other-window 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
86 (setq count (1+ count)))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
87
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
88 (defun scroll-lock-page-down-all (arg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
89 "Page-down all visible windows."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
90 (interactive "P")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
91 (let ((num-windows (count-windows))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
92 (count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
93 (if (> num-windows 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
94 (progn (other-window 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
95 (while (< count num-windows)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
96 (call-interactively 'fkey-scroll-up)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
97 (other-window 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
98 (setq count (1+ count)))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
99
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
100 (defun scroll-lock-page-up-all (arg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
101 "Page-up all visible windows."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
102 (interactive "P")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
103 (let ((num-windows (count-windows))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
104 (count 1))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
105 (if (> num-windows 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
106 (progn (other-window 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
107 (while (< count num-windows)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
108 (call-interactively 'fkey-scroll-down)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
109 (other-window 1)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
110 (setq count (1+ count)))))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
111
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
112
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
113 (defun scroll-lock-check-to-scroll ()
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
114 "Check last-command to see if a scroll was done."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
115 (if (eq this-command 'next-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
116 (call-interactively 'scroll-lock-scroll-down-all))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
117 (if (eq this-command 'previous-line)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
118 (call-interactively 'scroll-lock-scroll-up-all))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
119 (if (eq this-command 'fkey-scroll-up)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
120 (call-interactively 'scroll-lock-page-down-all))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
121 (if (eq this-command 'fkey-scroll-down)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
122 (call-interactively 'scroll-lock-page-up-all)))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
123
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
124
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
125 (defun scroll-lock-mode (arg)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
126 "Toggle scroll-lock minor mode."
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
127 (interactive "P")
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
128 (setq scroll-lock-is-locked (not scroll-lock-is-locked))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
129 (cond
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
130 ((eq scroll-lock-is-locked 't)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
131 (add-hook 'post-command-hook 'scroll-lock-check-to-scroll))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
132 ((eq scroll-lock-is-locked 'nil)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
133 (remove-hook 'post-command-hook 'scroll-lock-check-to-scroll))))
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
134
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
135 (provide 'scroll-lock)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
136
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents:
diff changeset
137 ;;; scroll-lock.el ends here