annotate lisp/packages/scroll-in-place.el @ 189:489f57a838ef r20-3b21

Import from CVS: tag r20-3b21
author cvs
date Mon, 13 Aug 2007 09:57:07 +0200
parents 4be1180a9e89
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;; -*-Emacs-Lisp-*- Improved Vertical Scrolling Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;; Written by Eric Eide, last modified on 1994/11/18 21:23:01.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;;; (C) Copyright 1993, 1994, Eric Eide and the University of Utah
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;;; COPYRIGHT NOTICE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;; This program is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;;; under the terms of the GNU General Public License as published by the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;; Software Foundation; either version 2 of the License, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;; This program is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;;; for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;; You should have received a copy of the GNU General Public License along
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;;; with GNU Emacs. If you did not, write to the Free Software Foundation,
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
20 ;;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;; AUTHORS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;;; This package was written by Eric Eide (eeide@cs.utah.edu) and was based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;; a very similar package ("scroll-fix") by Joe Wells. Almost all of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;;; code in this file is original, but I owe a great debt to Mr. Wells for his
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;; ideas and his original implementation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;; Eric Eide (eeide@cs.utah.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;;; University of Utah
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;;; 3190 Merrill Engineering Building
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;; Salt Lake City, Utah 84112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;;; Joe Wells (jbw@cs.bu.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;;; Joe Wells' "scroll-fix" package is Copyright (C) 1988, 1989, and 1991 by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;;; the Free Software Foundation. It is distributed under the terms of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;;; GNU General Public License.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;;; LISP CODE DIRECTORY INFORMATION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;;; scroll-in-place|Eric Eide|eeide@cs.utah.edu|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;;; Improved vertical scrolling commands|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;;; 1994/11/18 21:23:01|1.3|~/misc/scroll-in-place.el.Z|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;; SUMMARY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;;; This package provides improved vertical scrolling commands for GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;;; These new commands offer the following features:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;;; + When a scrolling command is executed, GNU Emacs tries to keep point as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;;; close as possible to its original window position (window line and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;;; column). This is what "scroll in place" means: point stays "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;;; within the window. (There are times when point must be moved from its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;;; original window position in order to execute the scroll; see below.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;;; The variable `scroll-in-place', which is true by default, determines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;;; whether or not the standard GNU Emacs scrolling commands (`scroll-down',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;;; `scroll-up', `scroll-other-window-down', and `scroll-other-window') use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;;; the "in place" features listed here. When `scroll-in-place' is `nil'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;;; the standard GNU Emacs scrolling commands essentially just call the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;;; original versions of themselves. (Note that even when `scroll-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;;; is `nil' the new versions of `scroll-down' and `scroll-up' have slightly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;;; different behavior when a minibuffer window is the selected window. See
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;;; below.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;;; It is possible to turn off (or turn on) "in place" scrolling for certain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;;; buffers by making buffer-local bindings of the variable `scroll-in-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;;; place' for those buffers. The variable `scroll-in-place' is not usually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;;; buffer-local, but you can make it so if you desire.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;;; + Because the improved scrolling commands keep point at its original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;;; window position, these scrolling commands are "reversible." The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;;; `scroll-up' command undoes the effect of the immediately previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;;; `scroll-down' command (if any) and vice versa. In other words, if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;;; scroll up and then immediately scroll back down, the window config-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;;; uration is restored to its exact original state. This allows you to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;;; browse through a buffer more easily, as you can always get back to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;;; original configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;;; Note, however, that the improved scrolling commands are guaranteed to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;;; reversible only if there are no intervening non-scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;;; Also, if you give a prefix argument to a scrolling command (in order to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;;; specify the number of lines to scroll by), previous scrolling commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;;; may no longer be reversible. More specifically, if the new prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;;; argument has a different magnitude than the previous scrolling distance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;; then any previous scrolling commands are not reversible. The new prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;;; argument takes precedence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;;; You might find it useful to think of the scrolling commands as forming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;;; "chains." A scrolling command either starts or continues a chain. By
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;;; issuing a non-scrolling command or by changing the number of lines to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;;; scrolled, you break the chain. (Note that simply changing the scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;;; direction won't break the chain; changing the absolute number of lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;;; to be scrolled is what breaks the chain.) Scrolling commands are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;;; guaranteed to be reversible only within the current chain. Hopefully
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;;; that's clear enough.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;;; + When a scrolling command is given a prefix argument (which specifies the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;;; number of lines to scroll by), then that argument becomes the default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;;; scrolling distance for all immediately subsequent scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;;; This means that you can easily set the scrolling distance for a chain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;;; of scrolling commands. Note that a new prefix argument or any non-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;;; scrolling command breaks the chain (as described above), and any further
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;;; scrolling commands will use the usual defaults (or the prefix argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;;; you specify at that time, of course).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;;; However, there are cases in which one doesn't want the current scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;;; command to use the default scrolling distance that was set by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;;; previous scrolling command. For example, suppose that you had special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;;; commands that scrolled one line up and one line down. When you invoke
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;;; one of these commands, the "in place" scrolling routines set the default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;;; scrolling distance to be just one line. Now suppose that you use one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;;; your special commands and then immediately invoke `scroll-up' (`C-v'),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;;; expecting it to scroll by a near windowful of text. You would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;;; disappointed --- because the previous command set the default scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;;; distance to be just one line, `scroll-up' just scrolls by one line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;;; To solve this problem, "scroll-in-place" allows you to divide scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;;; commands into separate "groups." Commands in a group can only form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;;; chains with (and therefore, inherit defaults from) commands in the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;;; group. (Note that no command can be in more than one group.) If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;;; invoke a scrolling command that is not in the same group as that of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;;; immediately previous scrolling command, then the previous chain is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;;; broken and you start a new chain --- with a new set of defaults.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;;; So to solve the problem described above, you could put your one-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;;; scrolling commands in their own group. Once that is done, the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;;; scrolling commands will not form chains with your one-line scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;;; commands, and therefore will not use the default scrolling distance set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;;; by those commands. Problem solved!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;;; By default, all "in place" scrolling commands are in a single group. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;;; you want to partition some commands into separate groups, you must do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;;; that yourself *before* any "in place" commands are invoked. For more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;;; information about grouping commands, see the documentation for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;;; variables `scroll-command-groups' and `scroll-default-command-group'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;;; + The improved scrolling commands will avoid displaying empty lines past
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;;; the end of the buffer when possible. In other words, just as you can't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;;; see "dead space" before the beginning of the buffer text, the new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;;; scrolling commands try to avoid displaying "dead space" past the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;;; the buffer text. This behavior is somewhat configurable; see the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;;; documentation for the variable `scroll-allow-blank-lines-past-eob'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;;; Dead space will be displayed if it is necessary in order to make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;;; previous scrolling action reversible, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;;; + If the scrolling commands cannot keep point at its initial window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;;; position (because a buffer boundary is on screen and the window can't be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;;; scrolled as far as necessary to keep point at the right place), point is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;;; allowed to temporarily stray from its initial window position. That is,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;;; point moves the correct number of window lines, even if it means that it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;;; has to stray from its desired window position. This straying is undone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;;; when (and if) the scrolling action is reversed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;;; + If a scrolling command tries to move point past a buffer boundary, point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;;;; is instead moved to the boundary (the beginning or the end of the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;;; as appropriate) and an appropriate message is displayed. This motion is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;;; reversible, of course.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;;; However, if point was already at the buffer boundary when the scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;;; command was invoked, the command signals an appropriate error instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;;; + When a minibuffer window is the selected window, the new versions of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;;; `scroll-up' and `scroll-down' either scroll the window in the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;;; `minibuffer-scroll-window' (which is usually the window of completions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;;; or the `next-window' if there is no `minibuffer-scroll-window'. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;;; usually much more useful than scrolling the minibuffer itself. (Note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;;; that this feature is available even when the variable `scroll-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;;; is `nil'.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;;; + When a scrolling command is scrolling a window other than the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;;; window, it will signal an appropriate buffer boundary error if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;;; window cannot be scrolled (because the appropriate buffer boundary is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;;; already visible). This means that an error is signalled even in cases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;;; that would be allowed (by "straying" point or by moving it to the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;;; boundary) if the window were selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;;; (If an error were not signalled in these cases, then there would be many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;;; cases in which the last scroll in a particular direction would appear to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;;; do nothing because only the point position would change --- the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;;; displayed text would stay the same! To avoid these cases the scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;;; commands signal boundary errors "prematurely" when the window to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;;; scrolled is not selected.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;;; So how is this package different than Joe Wells' "scroll-fix" package?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;;; + This package provides "in place" behavior for the standard GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;;; commands by default; "scroll-fix" does not.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;;; + "scroll-fix" behaves differently when the window is near a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;;; boundary. Instead of allowing point to stray, "scroll-fix" first does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;; an incomplete scroll (i.e., moves point less than the full distance in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;;; order to keep point at the desired window position) and then pops point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;;; to the buffer boundary. I think that the behavior of this package is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;;; somewhat move intuitive, especially for small scrolling distances.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;;; + The scrolling commands in this package will appropriately signal buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;;; boundary errors; the commands in "scroll-fix" never signal boundary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;;; errors. This makes it difficult to allow "scroll-fix" to replace the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;;; standard `scroll-down' and `scroll-up' commands because some other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;;; packages (e.g., VM and GNUS) expect the scrolling commands to signal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;;; these errors as necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;;; + This package handles long lines correctly. (But see PROBLEMS, below.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;;; + "scroll-fix" handles prefix arguments differently. In "scroll-fix", a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;;; number-containing prefix argument always breaks any running chain of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;;;; scrolling commands. The prefix argument `-' (the symbol minus,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;;; generated by `C-u -') causes a temporary change in direction --- a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;;;; change for only the current command. In this package, however, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;;; number-containing prefix argument only breaks a running chain if it has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;;; a different magnitude than the default scrolling distance, and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;;;; prefix argument `-' causes a permanent change in the sign of the default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;;;; scrolling distance --- a change visible to immediately subsequent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;;; scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;;;; + This package keeps track of the set of "in place" scrolling commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;;;; dynamically, in order to detect "chains" of scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;;; "scroll-fix" has a fixed list of scrolling commands, so "scroll-fix"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;;; cannot keep track of some chains. (Again, "scroll-fix" interacts badly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;;; with VM and GNUS.) And because "scroll-fix" keeps a static list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;;; scrolling commands, it is a bad idea to call its "in place" commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;;; from a program. This package, because it maintains the information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;;;; dynamically, has no such problems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;;; + This package allows one to divide the "in place" scrolling commands into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;;; groups; a command in a group only forms chains with the members of its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;;; group. "scroll-fix" has no notion of command groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;;;; + This package provides "in place" versions of the standard GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;;; commands `scroll-other-window-down' and `scroll-other-window'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;;; + This package will refuse to scroll non-selected windows (by signalling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;;;; an error) when the displayed text would not change, as described in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;;;; feature list above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;;; + When a minibuffer window is selected, this package always scrolls a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;;;; window other than the minibuffer. "scroll-fix" will scroll another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;;; window only if the entire minibuffer contents are visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;;; + "scroll-fix" provides a command to toggle the "in place" behavior of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;;;; standard GNU Emacs commands. This package doesn't; you'll have to set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;;;; the option manually with the command `set-variable'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;;;; + This package has gratuitous variable renaming (insert smile here!):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;;; "scroll-fix" user variable Equivalent in this package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;;;; -----------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;;; scroll-in-place (none)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;;; scroll-in-place-replace-original scroll-in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;;; scroll-in-place-eob-blank-allowed scroll-allow-blank-lines-past-eob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;;; + This package allows programmers to specify the default scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;;; distance (i.e., the default distance used when starting a new chain of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;;;; scrolling commands) for custom scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;;;; COMMANDS AND FUNCTIONS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;;; This package provides the following "in place" versions of GNU Emacs'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;;; standard vertical scrolling commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;;;; scroll-down-in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;;;; scroll-up-in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;;; scroll-other-window-down-in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;;;; scroll-other-window-in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;;;; The variable `scroll-in-place', which is true by default, determines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;;;; whether or not the new versions of the standard GNU Emacs scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;;; commands (`scroll-down', `scroll-up', `scroll-other-window-down', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;;;; `scroll-other-window') use the "in place" features listed above. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;;;; `scroll-in-place' is `nil' the standard GNU Emacs scrolling commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;;;; essentially just call the original versions of themselves. (Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;;;; even when `scroll-in-place' is `nil' the new versions of `scroll-down' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;;; `scroll-up' have slightly different behavior when a minibuffer window is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;;;; the selected window. See the feature list above.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;;;; NOTE that this package redefines the standard GNU Emacs commands `scroll-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;;;; down', `scroll-up', `scroll-other-window-down', and `scroll-other-window'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;;;; (in order to check the variable `scroll-in-place', as described above).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;;;; The command `scroll-other-window-down' first appeared as a standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;;;; command in the FSF's GNU Emacs 19.26.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;;;; This package also provides the following functions and variables which are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;;;; of use to programmers:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;;;; scroll-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;;;; scroll-window-in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;;;; scroll-window-in-place-continue-sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;;;; scroll-default-lines (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;;;; scroll-command-groups (variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;;;; The `scroll-window-in-place' function is the heart of the "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;;;; scrolling commands. `scroll-window' is a function that checks the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;;;; variable `scroll-in-place' and calls the appropriate scrolling function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;;;; (either `scroll-window-in-place' or one of the original versions of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;;;; `scroll-down' and `scroll-up'). The function `scroll-window-in-place-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;;;; continue-sequence' is provided in order to preserve running "chains" of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;;;; scrolling commands as described above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;;;; The variable `scroll-default-lines' determines the default scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;;;; distance when a new chain of "in place" scrolling commands begins. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;;;; this variable is not a number, then the default distance is the height of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;;;; the window to be scrolled minus `next-screen-context-lines'. The variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;;;; `scroll-command-groups' contains the explicit groups of "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;;;; scrolling commands; for more information read the variable documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;;;; YOUR .EMACS FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;;;; To use this package, you simply need to load it from within your ".emacs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;;;; file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;;;; (require 'scroll-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;;;; By default, this package provides for the standard GNU Emacs vertical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;;;; scrolling commands (`scroll-down', `scroll-up', `scroll-other-window-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;;;; down', and `scroll-other-window') to use the "in place" features. If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;;;; would rather not have this, set the variable `scroll-in-place' to `nil':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;;;; (setq scroll-in-place nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;;;; When `scroll-in-place' is `nil' you will have to bind keys in order to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;;;; call the "in place" scrolling commands. For example, you might want to do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;;;; the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;;;; (global-set-key "\M-v" 'scroll-down-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;;;; (global-set-key "\C-v" 'scroll-up-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;;;; Sun users should also read the PROBLEMS section, below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;;;; ADVANCED CUSTOMIZATION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;;;; If you want to partition certain "in place" scrolling commands into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;;;; separate groups, you should do something like the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;;; ;; Make one group containing the commands `scroll-down-one-line' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;;;; ;; `scroll-up-one-line'. (These are not standard GNU Emacs commands.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;;;; (setq scroll-command-groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;;;; (list '(scroll-down-one-line scroll-up-one-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;;;; You could write the `scroll-down-one-line' command like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;;;; (defun scroll-down-one-line (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;;;; "Scroll down one line, or number of lines specified by prefix arg."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ;;;; (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;;;; (let ((scroll-default-lines 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;;;; (scroll-down-in-place arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;;;; If you want to disable "in place" scrolling for windows that display a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;;;; particular buffer (while leaving it available in other windows), you can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;;;; make `scroll-in-place' a buffer-local variable for that buffer and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;;;; bind that local copy of `scroll-in-place' to `nil'. This is the kind of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;;;; thing that one generally does in a major mode hook. For example, you can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ;;;; disable "in place" scrolling of GNUS article windows with the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;;;; code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;;;; (setq gnus-article-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;;;; (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;;;; (make-local-variable 'scroll-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ;;;; (setq scroll-in-place nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;;;; ;; Set the variable `gnus-Article-mode-hook' instead if you are using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;;;; ;; an old version of GNUS, say version 3.13 or 3.14.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;;;; The variable `scroll-allow-blank-lines-past-eob' can also be made local to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;;;; particular buffers, if you desire. (But why would you want to do that?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;;;; PROBLEMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;;;; + It is sometimes difficult for one's eyes to follow an incomplete scroll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;;;; (i.e., a scroll in which the text doesn't move as far as one expected),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;;;; especially when the scrolled window is not selected (and therefore that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;;;; window's point is not highlighted). One can lose one's place in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;;;; text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;;;; + The names `scroll-down-in-place' and `scroll-up-in-place' conflict with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;;;; two commands in the GNU Emacs terminal-specific file "term/sun.el".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;;;; This means that in order to load this package correctly, Sunterm users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;;;; will have to use the hook `term-setup-hook'. For example, you might put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;;;; the following form in your ".emacs" file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;;;; (setq term-setup-hook (function (lambda () (require 'scroll-in-place))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;;;; If this is confusing, get help from your local GNU Emacs guru.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;;;; + `scroll-determine-goal-column' tries to honor the variable `track-eol'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;;;; if it is set. But when lines are being wrapped we can't move point past
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;;;; the wrap --- or else it is possible that scrolling won't work correctly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ;;;; In short, this package honors `track-eol' as best it can.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;;;; + `scroll-window-in-place' can become confused when something changes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;;;; window "out from under it." By "confused" I mean that it is possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;;;; for `scroll-window-in-place' to think that it should continue the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;;;; running sequence of "in place" scrolls when it should really probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;;;; start a new sequence. For example, if a process filter inserts text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;;;; into the buffer and moves point, `scroll-window-in-place' loses track of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;;;; where point should be and where the window should start. Commands that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;;;; call a "scroll in place" function and then subsequently move point can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ;;;; also confuse `scroll-window-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;;;; To correct some of this confusion, `scroll-window-in-place' could keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;;;; track of the final positions of `window-start' and `window-point',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;;;; possibly with both markers and character positions. In my experience
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 ;;;; the "in place" scrolling commands are almost never confused (except by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;;;; fancy packages that do their own fancy kinds of scrolling, as described
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;;;; below), so the extra sanity checking isn't worth the effort. If your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;;;; mileage varies let me know.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;;;; + The "in place" scrolling commands can interact poorly with packages that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;;;; provide their own special scrolling commands. For example, there are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;;;; varying degrees of conflict with Rmail, VM, and GNUS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;;;; RMAIL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;;;; In the version of Rmail that is part of the FSF's GNU Emacs 19 (19.25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ;;;; through 19.28 at least), the command `rmail-summary-scroll-msg-down' in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;;;; the file "rmailsum.el" fails to work properly when "in place" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;;;; is enabled for the Rmail message buffer. (The source of the conflict:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;;;; the "in place" scrolling commands and Emacs' standard scrolling commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;;;; interpret the argument '- in different ways.) Fortunately it is easy to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;;;; patch Rmail. Send me mail if you would like to receive a copy of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;;;; patches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;;;; I know of no conflicts between the "in place" scrolling commands and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;;;; older versions of Rmail (i.e., versions that came with GNU Emacs 18).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;;;; VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ;;;; `scroll-window-in-place' is *very* confused by VM 5's message scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;;;; commands, especially because VM 5 rebuilds Emacs' window configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;;;; from scratch so often. I have written an experimental set of patches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;;;; for VM 5.70 that allows VM 5 to use the "scroll-in-place" features; send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;;;; me mail if you would like to receive a copy of these patches. I hope
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;;;; that someday my patches will be incorporated into VM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 ;;;; `scroll-window-in-place' is not confused by VM 4.41's message scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;;;; commands, however.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;;;; GNUS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;;;; `scroll-window-in-place' can be *slightly* confused by GNUS' article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;;;; scrolling commands because they move point to the last line of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;;;; article window and then scroll the text. (This is the case for at least
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;;;; GNUS versions 3.13 through 4.1, inclusive.) The potential conflict is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;;;; so minor, however, that you'll probably never notice it. I never do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;;;; A severe conflict, however, exists between the "in place" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;;;; commands and the add-on "gnus-hide" package. "gnus-hide" can elide
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;;;; signatures at the ends of articles but it does so in a way that causes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;;;; `scroll-window-in-place', as invoked by the GNUS scrolling commands, not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;;;; to signal end-of-buffer conditions at the right times. Someday I may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;;;; write new article scrolling commands for GNUS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ;;;; + Process filters that call scrolling functions can cause confusion. They
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;;;; may break running chains of "in place" scrolling commands and they may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;;;; set up inappropriate defaults for future scrolling commands. Maybe this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;;;; is a moot problem, as I am currently unaware of any process filters that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;;;; invoke scrolling commands (although many filters move point around,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;;;; which will also confuse `scroll-window-in-place').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
464 ;; sb -- Added turn-on and turn-off hook functions to prepare for making this
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
465 ;; a standardly dumped package with XEmacs.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
466
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; (provide 'scroll-in-place) at the end of this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;;;; Here are the variable declarations, both user options and internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;;;; variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (defvar scroll-in-place t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 "*When this variable is true (i.e., non-`nil'), the standard GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 vertical scrolling commands `scroll-down', `scroll-up', `scroll-other-window-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 down', and `scroll-other-window' will attempt to keep point at its current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 position in the window (window line and column). In other words, point stays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 \"in place\" within the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 When this variable is `nil' the standard GNU Emacs vertical scrolling commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 behave as usual. The \"in place\" equivalents, however, are still available as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 separate commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 This variable may be made buffer-local in order to disable (or enable) \"in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 place\" scrolling in particular buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; I have thought about dividing `scroll-in-place' into three variables: a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; list of commands that always scroll in place, a list of commands that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; never scroll in place, and a flag that determines the default behavior of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;; other scrolling commands. This could make it easier to make "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;; scrolling the default because one could single out certain ill-behaved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;; commands. But as of now I'm sure that the added complexity would really
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; be worth it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 4
diff changeset
501 (defvar scroll-allow-blank-lines-past-eob nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 "*When this variable is `nil' the \"in place\" scrolling commands will avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 displaying empty lines past the end of the buffer text. In other words, just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 as you can't see \"dead space\" before the beginning of the buffer text, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 \"in place\" scrolling commands try to avoid displaying \"dead space\" past the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 end of the buffer text. This helps make the most of window real estate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 Note that sometimes it is necessary to display \"dead space\" in order to make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 a previous scrolling action reversible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 When this variable is non-`nil' the \"in place\" scrolling commands will always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 allow blank lines to be shown past the end of the buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;;;; The following variables are not user options, but are intended to be set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;;;; by code outside this package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (defvar scroll-default-lines nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 "The default number of lines to be scrolled by when a new sequence of \"in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 place\" scrolling commands begins. Of course, when an explicit number of lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 is specified, that explicit number takes precedence. See the documentation for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 the function `scroll-window-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 If this variable is not bound to a number, then the default number of lines is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 the height of the window to be scrolled minus `next-screen-context-lines'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 This variable should not be set globally! Commands that want to specify a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 default scrolling distance should just bind the variable `scroll-default-lines'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 temporarily.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defvar scroll-command-groups nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 "The explicitly specified \"groups\" of \"in place\" scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 This variable should be set before or immediately after the \"in place\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 scrolling package is loaded, and then not changed after that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 Usually, \"in place\" scrolling commands share state (e.g., the number of lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 to scroll by) with any and all immediately previous \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 commands. Sometimes, however, this is undesirable. In these cases the \"in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 place\" scrolling commands can be divided into groups. A command in a group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 only shares state with members of its group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 Each element of `scroll-command-groups' is a list that contains all of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 members of a unique command group. For example, if there were only one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 explicit group and that group contained the commands `scroll-down-one-line' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 `scroll-up-one-line', then `scroll-command-groups' would be set to:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ((scroll-down-one-line scroll-up-one-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 Commands that are not in any explicitly specified group are added to a default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 group. That group is stored in the variable `scroll-default-command-group'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 The \"in place\" scrolling functions assume that all of the scrolling command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 groups are nonintersecting (i.e., no command is in more than one group) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 only contain \"in place\" scrolling commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;;;; The variables below this point are internal to this package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (defvar scroll-default-command-group nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 "The set of \"in place\" scrolling commands that are not members of any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 explicitly defined group of commands. This set of commands is an implicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 defined group, constructed as \"in place\" commands are invoked, and members of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 this group share state among themselves. See the documentation for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 variable `scroll-command-groups' for more information.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (defvar scroll-initially-displayed-lines 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 "The number of window lines that contained buffer text when the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 sequence of \"in place\" scrolling commands started. Unless the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 `scroll-in-place-allow-blank-lines-past-eob' is true, the \"in place\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 scrolling commands ensure that at least this many text lines are visible at all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 times.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (defvar scroll-previous-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 "The window that was most recently scrolled by an \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 command.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (defvar scroll-previous-lines 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 "The number of window lines that the previous \"in place\" scrolling command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 attempted to scroll.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (defvar scroll-goal-column 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 "The desired horizontal window position for point, used by the \"in place\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 scrolling commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (defvar scroll-boundary-previous-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 "The value of point before point was moved to a buffer boundary.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (defvar scroll-boundary-previous-lines 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 "The number of lines that point moved when it moved to a buffer boundary.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (defvar scroll-boundary-error-command nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 "The value of `this-command' when an \"in place\" scrolling command signalled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 a buffer boundary error. This is used to decide how subsequent scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 commands should recover from the error.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (defvar scroll-boundary-error-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 "The value of point when an \"in place\" scrolling command signalled a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 boundary error. This is used to decide how subsequent scrolling commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 should recover from the error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;; This variable is used as a flag, indicating whether or not the previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;; "in place" scrolling command signalled an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (defvar scroll-window-debt 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 "The difference between the number of lines an \"in place\" scrolling command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 tried to scroll a window and the number of lines that the window actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 scrolled. This difference is the \"debt\" in the window's starting position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 Subsequent \"in place\" scrolling commands try to make up this debt.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (defconst scroll-pos-visible-bug-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; On September 14, 1993, David Hughes <djh@Harston.CV.COM> told me that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;; Lucid GNU Emacs 19.8 had inherited the bug from Epoch... sigh.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (let ((old-match-data (match-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (or (and (boundp 'epoch::version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (if (string-match "\\`4\\." emacs-version) t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (and (string-match "Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (if (string-match "\\`19\\.8\\." emacs-version) t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (store-match-data old-match-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 "A flag, set when this version of GNU Emacs has a buggy version of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 function `pos-visible-in-window-p' that returns `nil' when given `(point-max)'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 and `(point-max)' is on the last line of the window. Currently, this flag is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 set for all versions of Epoch 4 and for Lucid GNU Emacs 19.8.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
631 ;; Hook functions to make turning the mode on and off easier.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
632 (defun turn-on-scroll-in-place ()
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
633 "Unconditionally turn on scroll-in-place mode."
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
634 (set (make-local-variable 'scroll-in-place) t))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
635
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
636 (defun turn-off-scroll-in-place ()
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
637 "Unconditionally turn on scroll-in-place mode."
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
638 (set (make-local-variable 'scroll-in-place) nil))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
639
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
640
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ;;;; Here are the window-choosing auxiliary functions used by the new scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;;;; commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (defun scroll-choose-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 "Choose the window to be scrolled by the commands `scroll-down', `scroll-up',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 `scroll-down-in-place', and `scroll-up-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 The rules are simple. If the selected window is not a minibuffer window, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 just choose the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 However, when a minibuffer window is selected, look first for the `minibuffer-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 scroll-window'. The `minibuffer-scroll-window' is usually the window that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 displays completions. If it exists, choose it; otherwise choose the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 window after the selected window in the canonical ordering of windows. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 next window is generally the one below the selected window, or the one at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 top of the screen if the selected window is at the bottom of the screen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (let ((selected-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if (window-minibuffer-p selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ;; A minibuffer window is selected --- scroll some other window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (if (window-live-p minibuffer-scroll-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 minibuffer-scroll-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;; We know that the (selected) minibuffer is active, so `next-window'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;; will examine all of the frames that share this minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 ;; Should we consider `other-window-scroll-buffer' here? I don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ;; believe so.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (next-window selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (defun scroll-choose-other-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 "Choose the window to be scrolled by the commands `scroll-other-window-down',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 `scroll-other-window', `scroll-other-window-down-in-place', and `scroll-other-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 window-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 The rules are these. If the selected window is not a minibuffer window, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 choose either:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 + a window that displays the `other-window-scroll-buffer', if that buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 exists. Note, this function will display that buffer if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 + the next window after the selected window in the canonical ordering of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 windows. The next window is generally the one below the selected window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 or the one at the top of the screen if the selected window is at the bottom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 of the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 However, when a minibuffer window is selected, look first for the `minibuffer-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 scroll-window'. The `minibuffer-scroll-window' is usually the window that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 displays completions. If it exists, choose it; otherwise choose the window to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 be scrolled as described above (`other-window-scroll-buffer' or next window).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 This function is essentially a Lisp version of the function `other-window-for-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 scrolling' which first appeared in the FSF's GNU Emacs 19.26."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (let* ((no-error nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (selected-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (other-window nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (setq other-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (cond ((and (window-minibuffer-p selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (window-live-p minibuffer-scroll-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;; Don't signal an error when `minibuffer-scroll-window' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;; the minibuffer itself --- which would be really weird, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ;; isn't necessarily erroneous.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (setq no-error t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 minibuffer-scroll-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 ((and ;; `other-window-scroll-buffer' is an Emacs 19 invention.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (boundp 'other-window-scroll-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (bufferp other-window-scroll-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 ;; `buffer-name' is `nil' if the buffer has been killed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (buffer-name other-window-scroll-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;; This is what FSF GNU Emacs 19.26 does, but it occurred to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; me: what if one of these forms returns the selected window?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;; Signalling an error would be bad news, so I added a flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (setq no-error t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (or (get-buffer-window other-window-scroll-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (display-buffer other-window-scroll-buffer t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 ((let ((next-window (next-window selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (if (eq next-window selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 next-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;; In Emacs 19 (FSF, Lucid, and XEmacs), look for a window on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 ;; another visible frame. This could be written for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; Epoch, too, I suppose...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (let ((this-window (next-window selected-window nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (while (not (or (eq this-window selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (scroll-choose-window-frame-visible-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 this-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (setq this-window (next-window this-window nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 this-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ;; In older versions of Emacs, `next-window' didn't accept
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ;; three arguments. Catch this error and then return the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;; selected window --- which will cause another error to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 ;; signalled later on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (wrong-number-of-arguments selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (if (and (not no-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (eq selected-window other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (error "There is no other window."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (defun scroll-choose-window-frame-visible-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 "Return a true value if the frame of the given WINDOW is visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (cond ((fboundp 'window-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (eq t (frame-visible-p (window-frame window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 ;;;; Here are the "in place" scrolling commands (interactive functions) and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 ;;;; replacements for the standard GNU Emacs vertical scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ;;;; Here are the new scroll "in place" commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (defun scroll-down-in-place (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 "Scroll the text of the current window downward by LINES lines, leaving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 as close as possible to its current window position (window line and column).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 In other words, point is left \"in place\" within the window. As a special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 case, when the current window is a minibuffer window, this command scrolls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 `minibuffer-scroll-window' (which is usually the list of completions) if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 exists, or otherwise the next window in the canonical ordering of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 If the optional argument LINES is `nil', scroll the window by the same amount
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 it was moved by the immediately previous \"in place\" scrolling command, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 the value of the variable `scroll-default-lines' (usually almost a windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 if the previous command was not an \"in place\" scrolling command (or when that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 previous command scrolled some other window, or when other circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 prevent the previous scrolling distance from being used). If LINES is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 symbol `-', then the scrolling distance is determined as if LINES had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 If the window cannot be scrolled by the full distance, point is allowed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 stray from its initial position so that it can move the full number of lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 If point cannot move the full number of lines, point is moved to the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 boundary. Any immediately subsequent \"in place\" scrolling commands will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 to restore point to its initial window position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (scroll-window-in-place (scroll-choose-window) lines -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (defun scroll-up-in-place (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 "Scroll the text of the current window upward by LINES lines, leaving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 as close as possible to its current window position (window line and column).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 In other words, point is left \"in place\" within the window. As a special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 case, when the current window is a minibuffer window, this command scrolls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 `minibuffer-scroll-window' (which is usually the list of completions) if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 exists, or otherwise the next window in the canonical ordering of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 If the optional argument LINES is `nil', scroll the window by the same amount
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 it was moved by the immediately previous \"in place\" scrolling command, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 the value of the variable `scroll-default-lines' (usually almost a windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 if the previous command was not an \"in place\" scrolling command (or when that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 previous command scrolled some other window, or when other circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 prevent the previous scrolling distance from being used). If LINES is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 symbol `-', then the scrolling distance is determined as if LINES had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 If the window cannot be scrolled by the full distance, point is allowed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 stray from its initial position so that it can move the full number of lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 If point cannot move the full number of lines, point is moved to the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 boundary. Any immediately subsequent \"in place\" scrolling commands will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 to restore point to its initial window position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (scroll-window-in-place (scroll-choose-window) lines 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;;; The command `scroll-other-window-down' first appeared in FSF GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;;; 19.26.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (defun scroll-other-window-down-in-place (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 "Scroll the text of the next window downward by LINES lines, leaving point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 that window as close as possible to its current window position (window line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 and column). In other words, point is left \"in place\" within the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 The next window is generally the one below the current one, or the one at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 top of the screen if the current window is at the bottom of the screen. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 special circumstances this command will scroll a window other than the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 window. Read the documentation for the function `scroll-choose-other-window'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 If the optional argument LINES is `nil', scroll the window by the same amount
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 it was moved by the immediately previous \"in place\" scrolling command, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 the value of the variable `scroll-default-lines' (usually almost a windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 if the previous command was not an \"in place\" scrolling command (or when that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 previous command scrolled some other window, or when other circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 prevent the previous scrolling distance from being used). If LINES is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 symbol `-', then the scrolling distance is determined as if LINES had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 If the window cannot be scrolled by the full distance, point is allowed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 stray from its initial position so that it can move the full number of lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 If point cannot move the full number of lines, point is moved to the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 boundary. Any immediately subsequent \"in place\" scrolling commands will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 to restore point to its initial window position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 If it is impossible to scroll the text of the window at all (because a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 boundary is already visible), this command signals a buffer boundary error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 The error is signalled even if point could otherwise move the full number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (scroll-window-in-place (scroll-choose-other-window) lines -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (defun scroll-other-window-in-place (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 "Scroll the text of the next window upward by LINES lines, leaving point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 that window as close as possible to its current window position (window line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 and column). In other words, point is left \"in place\" within the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 The next window is generally the one below the current one, or the one at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 top of the screen if the current window is at the bottom of the screen. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 special circumstances this command will scroll a window other than the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 window. Read the documentation for the function `scroll-choose-other-window'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 If the optional argument LINES is `nil', scroll the window by the same amount
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 it was moved by the immediately previous \"in place\" scrolling command, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 the value of the variable `scroll-default-lines' (usually almost a windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 if the previous command was not an \"in place\" scrolling command (or when that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 previous command scrolled some other window, or when other circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 prevent the previous scrolling distance from being used). If LINES is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 symbol `-', then the scrolling distance is determined as if LINES had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 If the window cannot be scrolled by the full distance, point is allowed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 stray from its initial position so that it can move the full number of lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 If point cannot move the full number of lines, point is moved to the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 boundary. Any immediately subsequent \"in place\" scrolling commands will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 to restore point to its initial window position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 If it is impossible to scroll the text of the window at all (because a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 boundary is already visible), this command signals a buffer boundary error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 The error is signalled even if point could otherwise move the full number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (scroll-window-in-place (scroll-choose-other-window) lines 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 ;;;; Here are the replacements for GNU Emacs' standard vertical scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;;;; commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (or (fboundp 'original-scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (fset 'original-scroll-down (symbol-function 'scroll-down)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (or (fboundp 'original-scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (fset 'original-scroll-up (symbol-function 'scroll-up)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (or (fboundp 'original-scroll-other-window-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ;; `scroll-other-window-down' first appeared in FSF GNU Emacs 19.26.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (if (fboundp 'scroll-other-window-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (fset 'original-scroll-other-window-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (symbol-function 'scroll-other-window-down))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (or (fboundp 'original-scroll-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (fset 'original-scroll-other-window (symbol-function 'scroll-other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (defun scroll-down (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 "Scroll the text of the current window downward by LINES lines. As a special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 case, when the current window is a minibuffer window, this command scrolls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 `minibuffer-scroll-window' (which is usually the list of completions) if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 exists, or otherwise the next window in the canonical ordering of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 The argument LINES is optional. Its meaning depends on the current value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 the variable `scroll-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 When the variable `scroll-in-place' is true, this command works just like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 command `scroll-down-in-place', scrolling the current window and leaving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 \"in place\" within the window. See the documentation for the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 `scroll-down-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 When the variable `scroll-in-place' is `nil' this command invokes the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 GNU Emacs version of `scroll-down'. In that case, when LINES is `nil' the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 current window is scrolled by nearly a complete windowful of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 Note that this command correctly handles cases in which `scroll-in-place' has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 buffer-local value in the window to be scrolled. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (scroll-window (scroll-choose-window) lines -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (defun scroll-up (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 "Scroll the text of the current window upward by LINES lines. As a special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 case, when the current window is a minibuffer window, this command scrolls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 `minibuffer-scroll-window' (which is usually the list of completions) if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 exists, or otherwise the next window in the canonical ordering of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 The argument LINES is optional. Its meaning depends on the current value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 the variable `scroll-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 When the variable `scroll-in-place' is true, this command works just like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 command `scroll-up-in-place', scrolling the current window and leaving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 \"in place\" within the window. See the documentation for the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 `scroll-up-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 When the variable `scroll-in-place' is `nil' this command invokes the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 GNU Emacs version of `scroll-up'. In that case, when LINES is `nil' the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 current window is scrolled by nearly a complete windowful of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 Note that this command correctly handles cases in which `scroll-in-place' has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 buffer-local value in the window to be scrolled. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (scroll-window (scroll-choose-window) lines 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 ;;; NOTE that in the FSF GNU Emacs 19.26 version of `scroll-other-window-down',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ;;; the `lines' argument is required. I've left it optional in order to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;;; like `scroll-other-window'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (defun scroll-other-window-down (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 "Scroll the text of the next window downward by LINES lines. The next window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 is generally the one below the current one, or the one at the top of the screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 if the current window is at the bottom of the screen. In special circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 this command will scroll a window other than the next window. Read the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 documentation for the function `scroll-choose-other-window' for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 The argument LINES is optional. Its meaning depends on the current value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 the variable `scroll-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 When the variable `scroll-in-place' is true, this command works just like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 command `scroll-other-window-down-in-place', scrolling the next window and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 leaving point \"in place\" within that window. See the documentation for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 command `scroll-other-window-down-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 When the variable `scroll-in-place' is `nil' this command invokes the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 GNU Emacs version of `scroll-other-window-down'. In that case, when LINES is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 `nil' the next window is scrolled by nearly a complete windowful of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 \(Note that `scroll-other-window-down' first appeared as a standard command in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 the FSF's GNU Emacs 19.26. If the builtin version of that command is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 available in the current Emacs system, an equivalent action is invoked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 instead.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 Note that this command correctly handles cases in which `scroll-in-place' has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 buffer-local value in the window to be scrolled. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;; This code is similar to the body of `scroll-window', below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (let* ((other-window (scroll-choose-other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (other-window-buffer (window-buffer other-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (if ;; Allow `scroll-in-place' to be a buffer-local variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (save-excursion (set-buffer other-window-buffer) scroll-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (scroll-window-in-place other-window lines -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ;; Paranoid, we forcibly break any running sequence of "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;; scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (setq scroll-previous-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;; For XEmacs and Lucid GNU Emacs, preserve the region's state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (if (boundp 'zmacs-region-stays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (setq zmacs-region-stays t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (if (fboundp 'original-scroll-other-window-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (original-scroll-other-window-down lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 ;; `scroll-other-window-down' first appeared as a builtin in FSF GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;; Emacs 19.26, so it may not be available in the current Emacs system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ;; Do the equivalent thing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (original-scroll-other-window (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ((null lines) '-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 ((eq lines '-) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (t (- (prefix-numeric-value lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (defun scroll-other-window (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 "Scroll the text of the next window upward by LINES lines. The next window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 is generally the one below the current one, or the one at the top of the screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 if the current window is at the bottom of the screen. In special circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 this command will scroll a window other than the next window. Read the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 documentation for the function `scroll-choose-other-window' for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 The argument LINES is optional. Its meaning depends on the current value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 the variable `scroll-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 When the variable `scroll-in-place' is true, this command works just like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 command `scroll-other-window-in-place', scrolling the next window and leaving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 point \"in place\" within that window. See the documentation for the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 `scroll-other-window-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 When the variable `scroll-in-place' is `nil' this command invokes the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 GNU Emacs version of `scroll-other-window'. In that case, when LINES is `nil'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 the next window is scrolled by nearly a complete windowful of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 Note that this command correctly handles cases in which `scroll-in-place' has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 buffer-local value in the window to be scrolled. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 ;; This code is similar to the body of `scroll-window', below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (let* ((other-window (scroll-choose-other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (other-window-buffer (window-buffer other-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (if ;; Allow `scroll-in-place' to be a buffer-local variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (save-excursion (set-buffer other-window-buffer) scroll-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (scroll-window-in-place other-window lines 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 ;; Paranoid, we forcibly break any running sequence of "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 ;; scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (setq scroll-previous-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 ;; For XEmacs and Lucid GNU Emacs, preserve the region's state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (if (boundp 'zmacs-region-stays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (setq zmacs-region-stays t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (original-scroll-other-window lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 ;;;; Here are the new functions `scroll-window-in-place', `scroll-window', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 ;;;; `scroll-window-in-place-continue-sequence'. These functions are intended
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 ;;;; to be available to programs outside this package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (defun scroll-window-in-place (window lines direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 "Scroll WINDOW vertically by the given number of window LINES in the given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 DIRECTION, leaving the window's point as close as possible to its original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 window position (window line and column). In other words, the window's point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 is left \"in place\" within the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 Note that the window to be scrolled does not have to be the selected window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 and that this function does not change which window is selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 LINES specifies the number of window lines to scroll and is interpreted as if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 it were a raw prefix argument. If LINES is `nil', the window is scrolled by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 the amount it was moved by the immediately previous \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 command, or by the value of the variable `scroll-default-lines' (by default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 almost a windowful) if the previous command was not an \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 command (or when WINDOW is not the previously scrolled window, or when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 value of `this-command' is not in the same group as the previous scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 command (see the documentation for the variable `scroll-command-groups'), or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 when other circumstances prevent the previous scrolling distance from being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 used). If LINES is the symbol `-', then the scrolling distance is determined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 as if LINES had been `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 DIRECTION determines the direction of the scrolling motion. The values -1 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 `down' indicate downward motion; the values 1 and `up' indicate upward motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 Any other value causes an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 If the window cannot be scrolled by the full distance (because the window hits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 the boundary of its buffer), the window's point is allowed to stray from its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 initial position so that it can move the full number of lines. If point cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 move the full number of lines, point is moved to the buffer boundary (unless it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 was already there, in which case a buffer boundary error is signalled instead).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 Any immediately subsequent \"in place\" scrolling commands will try to restore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 point to its initial window position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 Unless the variable `scroll-allow-blank-lines-past-eob' is true, this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 avoids displaying blank lines past the end of the buffer except as necessary to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 make a previous \"in place\" scrolling action reversible. Effectively, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 means that this function will not display any more past-end-of-buffer blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 lines than were visible when the current sequence of \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 commands started. When the variable `scroll-allow-blank-lines-past-eob' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 true, this function will display as many blank lines as is necessary to keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 point \"in place\" in the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 Note that if WINDOW is not the selected window and it is impossible to scroll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 the text of WINDOW at all (because a buffer boundary is already visible), then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 this function signals a buffer boundary error. The error is signalled even if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 point could otherwise move the full number of lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (let* (;; Make sure that the user doesn't quit in the middle and leave us
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 ;; with our variables out of sync.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (original-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (original-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (window-height (- (window-height window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (if (window-minibuffer-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 0 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (this-command-group (scroll-get-command-group this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (continue-scroll-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (and ;; We're scrolling the previously scrolled window...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (windowp scroll-previous-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (eq window scroll-previous-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 ;; ...and the last command was an "in place" scrolling command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 ;; that can be continued by this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (if (eq last-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 ;; If the previous command signalled an error, the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 ;; `last-command' is `t'. Try to see if we signalled the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;; error and if point is where we left it. (NOTE that FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 ;; GNU Emacs 19.23+ no longer sets `last-command' to `t'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 ;; when a command signals an error. This is OK because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;; else part of this `if' does the appropriate thing.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (and scroll-boundary-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (eq (window-point window) scroll-boundary-error-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (memq scroll-boundary-error-command this-command-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 ;; Otherwise...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (memq last-command this-command-group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (lines-value (prefix-numeric-value lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; For XEmacs and Lucid GNU Emacs, preserve the region's state. Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;; these Emacsen will forcibly deactivate the region if we signal an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;; later on. Is this bad?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (if (boundp 'zmacs-region-stays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (setq zmacs-region-stays t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 ;; Parse the direction into a unit distance (1 or -1).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (setq direction (scroll-parse-direction direction))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (setq scroll-previous-window window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 ;; `(setq scroll-boundary-error-command nil)' is not necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 scroll-boundary-error-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 ;; `select-window' does an implicit `set-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (if (or ;; The current command is not a continuation of a running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;; sequence of "in place" scrolling commands...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (not continue-scroll-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 ;; ...or we were given an explicit number of lines to scroll,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 ;; and that number has a different magnitude than the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 ;; number of lines we scrolled...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (and (or (numberp lines) (consp lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (/= scroll-previous-lines lines-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (/= scroll-previous-lines (- lines-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 ;; ...or the last successful scrolling command moved to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;; buffer boundary, but the buffer is no longer in the state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; we left it. (This can occur if, for example, we signal an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;; end-of-buffer error and something catches it and moves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ;; point or renarrows. VM, for example, does this.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (and scroll-boundary-previous-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (or (not (or (bobp) (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (< scroll-boundary-previous-point (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (> scroll-boundary-previous-point (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (eq scroll-boundary-previous-point (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 ;; We're starting a new sequence of scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (setq lines (if (or (numberp lines) (consp lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 lines-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ;; The default number of lines...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (* (if (eq lines '-) -1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (if (numberp scroll-default-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 scroll-default-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (max (- window-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 next-screen-context-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 scroll-previous-lines lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 scroll-goal-column (scroll-determine-goal-column window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 scroll-boundary-previous-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ;; `(setq scroll-boundary-previous-lines 0)' is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 ;; necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 scroll-window-debt 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 scroll-initially-displayed-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (if scroll-allow-blank-lines-past-eob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (goto-char (window-start window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (vertical-motion (1- window-height)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 ;; Otherwise we want to scroll by the same number of lines (but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ;; possibly in a different direction) that we scrolled in previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ;; invocations of this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (cond ((null lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (setq lines scroll-previous-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ((eq lines '-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (setq lines (- scroll-previous-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 scroll-previous-lines lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (setq lines lines-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 scroll-previous-lines lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (setq lines (* direction lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 ;; If point is not in the window, center window around point. We try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 ;; to account for a bug in `pos-visible-in-window-p' in some versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 ;; of Emacs (see `scroll-pos-visible-bug-p', above).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (if (pos-visible-in-window-p (let ((point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (if (and scroll-pos-visible-bug-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (= point (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (max (1- point) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (vertical-motion (/ (- window-height) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (set-window-start window (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (cond ((and scroll-boundary-previous-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; `lines' is the same sign as the direction from point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ;; to the `scroll-boundary-previous-point'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (cond ((> lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (> (- scroll-boundary-previous-point (point)) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 ((< lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (< (- scroll-boundary-previous-point (point)) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; We're moving away from the buffer boundary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (goto-char scroll-boundary-previous-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;; Always move here (i.e., don't reject cases in which the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; window doesn't move).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (scroll-set-window-start window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (- scroll-boundary-previous-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ;; (message "Back, window debt is %s." scroll-window-debt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (setq scroll-boundary-previous-point nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 ((= lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ;; We're going nowhere, so save ourselves some work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 ;; (message "Scrolled zero lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ;; Perform the scrolling motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (let ((initial-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (moved nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 ;; First move point and see how far it goes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (setq moved (vertical-motion lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (if (= moved lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 ;; Point moved the full distance. Move to the desired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ;; column and then try to move the window the full
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 ;; distance, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (move-to-column (+ (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 scroll-goal-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (or (scroll-set-window-start window moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 original-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (scroll-signal-boundary-error initial-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 ;; (message "Normal, window debt is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 ;; scroll-window-debt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 ;; Point couldn't move all the way. Move to the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 ;; boundary if we're not already there, or signal a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 ;; boundary error otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (let ((boundary-point (if (< lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (boundary-symbol (if (< lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 'beginning-of-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 'end-of-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (if (= initial-point boundary-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (scroll-signal-boundary-error initial-point lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 ;; Scroll the window by as many lines as point could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ;; move.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (or (scroll-set-window-start window moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 original-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (scroll-signal-boundary-error initial-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (message "%s" (get boundary-symbol 'error-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;; (message "Boundary, window debt is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 ;; scroll-window-debt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (setq scroll-boundary-previous-lines moved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (setq scroll-boundary-previous-point initial-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (goto-char boundary-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 ;; The unwind forms of the `unwind-protect', above. Restore the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 ;; originally selected window and current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (select-window original-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (set-buffer original-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 ;; The standard GNU Emacs scrolling commands return `nil' so we do, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (defun scroll-window (window lines direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 "Scroll WINDOW vertically by the given number of window LINES in the given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 DIRECTION. Note that the window to be scrolled does not have to be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 selected window, and that this function does not change which window is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 When the variable `scroll-in-place' is true, this function simply invokes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 function `scroll-window-in-place' to scroll the window and leave point \"in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 place\" within that window. See the documentation for `scroll-window-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 When the variable `scroll-in-place' is `nil' this function invokes the original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 version of the standard GNU Emacs command `scroll-down' or `scroll-up', as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 determined by DIRECTION, to scroll the window. If DIRECTION is -1 or `down',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 the original `scroll-down' is called; if DIRECTION is 1 or `up', the original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 `scroll-up' is called. Any other DIRECTION is an error. LINES is interpreted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 as if it were a raw prefix argument. If LINES is `nil', the window is scrolled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 by almost a complete windowful. If LINES is the symbol `-', the window is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 scrolled by almost a complete windowful in the opposite direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 Note that this function correctly handles cases in which `scroll-in-place' has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 a buffer-local value in the WINDOW's buffer. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (let ((current-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (selected-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (window-buffer (window-buffer window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (if ;; Allow `scroll-in-place' to be a buffer-local variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (if (eq current-buffer window-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 scroll-in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (save-excursion (set-buffer window-buffer) scroll-in-place))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (scroll-window-in-place window lines direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 ;; Paranoid, we forcibly break any running sequence of "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;; scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (setq scroll-previous-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;; For XEmacs and Lucid GNU Emacs, preserve the region's state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (if (boundp 'zmacs-region-stays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (setq zmacs-region-stays t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (if (= (scroll-parse-direction direction) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (original-scroll-up lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (original-scroll-down lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (select-window selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (set-buffer current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 ;;; The following function is sometimes useful. For example, I call it from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 ;;; functions that are invoked by certain mouse button down events in order to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 ;;; preserve any running chain of "in place" scrolling commands. This lets me
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 ;;; continue the sequence from my mouse button up functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 ;;; I haven't yet needed a function to purposely break a running sequence of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 ;;; "in place" scrolling commands. Such a function would be easy to write,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 ;;; however; just set the variable `scroll-previous-window' to `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (defun scroll-window-in-place-continue-sequence ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 "If the previous command was a \"scroll in place\" command, set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 `this-command' to the name of that previous command. This ensures that any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 running sequence of \"in place\" scrolling commands will not be broken by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 current command. See the documentation for the commands `scroll-down-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 and `scroll-up-in-place' for more information about \"in place\" scrolling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 NOTE that you don't need to call this function if the current command scrolls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 in place! You only need to call this function when the current command is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 a \"scroll in place\" command but you still want to preserve any running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 sequence of \"in place\" commands. Such situations are rare.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 NOTE that this function sets `this-command' in order to trick the \"in place\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 scrolling commands. If something else subsequently sets `this-command', any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 running sequence of scrolling commands will probably be broken anyway."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (if (if (eq last-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 ;; If `last-command' is `t', then the previous command signalled an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 ;; error. See if the last invocation of `scroll-window-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;; signalled an error. (NOTE that FSF GNU Emacs 19.23+ no longer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 ;; sets `last-command' to `t' when a command signals an error. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 ;; is OK because the else part of this `if' does the appropriate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 ;; thing.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 scroll-boundary-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 ;; Otherwise, the value of `last-command' must belong to some group of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 ;; "in place" scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (or (memq last-command scroll-default-command-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (let ((groups scroll-command-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (while (and groups (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (if (memq last-command (car groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (setq groups (cdr groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 found)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (setq this-command last-command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 ;;;; Here are the various auxiliary functions called by the function `scroll-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 ;;;; window-in-place'. None of the functions are intended to be called from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;;;; outside this package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (defun scroll-get-command-group (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 "Return the group of \"in place\" scrolling commands that contains the given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 COMMAND. This is the list of commands with which the given command may share
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 state and form \"chains.\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 This function is an auxiliary for the function `scroll-window-in-place'. Don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 call this function from other code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 ;; This function assumes that the given command is an "in place" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 ;; command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (let ((groups scroll-command-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (while (and groups (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (if (memq command (car groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (setq groups (cdr groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (if groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (car groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 ;; Otherwise return the default command group. If necessary, add the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 ;; given command to the default command group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (or (memq command scroll-default-command-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (setq scroll-default-command-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (cons command scroll-default-command-group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 scroll-default-command-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (defun scroll-parse-direction (direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 "Return the signed unit distance for the given DIRECTION. If DIRECTION is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 unacceptable, signal an error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (cond ((or (eq direction 1) (eq direction -1)) direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 ((eq direction 'up) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 ((eq direction 'down) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (t (signal 'args-out-of-range (list 'direction direction)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (defun scroll-determine-goal-column (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 "Return the goal column for the \"in place\" vertical scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 This is the horizontal window position at which these commands try to keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 This function is an auxiliary for the function `scroll-window-in-place'. Don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 call this function from other code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ;; NOTE that `window' must be the selected window! `scroll-window-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 ;; ensures that this is so.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (cond ((or truncate-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (and truncate-partial-width-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (< (window-width window) (screen-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (> (window-hscroll window) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;; Lines in this window are being truncated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (if (and track-eol (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 9999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ((and track-eol (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 ;; In some ways this isn't quite right, as point doesn't track the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 ;; ends of wrapped lines. But if it did so, point would be on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ;; wrong window line. This is the best we can do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (1- (window-width window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (t (% (current-column) (1- (window-width window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (defun scroll-set-window-start (window lines &optional original-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 "Move the `window-start' of the given window, which must be the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 window. If the window was successfully scrolled, update the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 `scroll-window-debt' and return `t'. Otherwise return `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 This function is an auxiliary for the function `scroll-window-in-place'. Don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 call this function from other code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (goto-char (window-start window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 ;; Try to move the window start by the specified number of lines. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 ;; addition, try to make up any existing debt in the window start's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 ;; position and make sure that we don't move too close to the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 ;; buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (let ((moved (+ (vertical-motion (+ lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 scroll-window-debt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 scroll-initially-displayed-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (vertical-motion (- scroll-initially-displayed-lines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 ;; If we're not scrolling the `original-window' (i.e., the originally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 ;; selected window), punt if we didn't move the window start at all.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (if (and original-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (not (eq window original-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (= moved 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ;; Otherwise update the window start and keep track of the debt in our
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 ;; position. Return `t' to indicate success.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (set-window-start window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (setq scroll-window-debt (- (+ lines scroll-window-debt) moved))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (defun scroll-signal-boundary-error (initial-point lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 "Move point to its initial location and signal an appropriate buffer boundary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 This function is an auxiliary for the function `scroll-window-in-place'. Don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 call this function from other code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (goto-char initial-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 ;; Remember what we were doing and where point was when we signalled the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ;; error so that subsequent "in place" scrolling commands can decide how to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ;; recover.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (setq scroll-boundary-error-command this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 scroll-boundary-error-point initial-point)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 76
diff changeset
1559 (when signal-error-on-buffer-boundary
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 76
diff changeset
1560 (signal (if (< lines 0) 'beginning-of-buffer 'end-of-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 76
diff changeset
1561 nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1564 ;;; Some convenience redefinitions for modes that don't like scroll-in-place
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1565 (add-hook 'vm-mode-hook 'turn-off-scroll-in-place)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1566 (add-hook 'vm-select-message-hook 'turn-off-scroll-in-place)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1567 (add-hook 'vm-summary-mode-hook 'turn-off-scroll-in-place)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1568
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1569 (add-hook 'list-mode-hook 'turn-off-scroll-in-place)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1570
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1571 ;; This doesn't work with Red Gnus
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1572 ;; (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1573
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 ;;;; Finally, here is the `provide' statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (provide 'scroll-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
1584 ;;; scroll-in-place.el ends here