annotate lisp/packages/scroll-in-place.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
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,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;;; Inc., 675 Mass Ave., Cambridge, MA 02139, USA.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;; (provide 'scroll-in-place) at the end of this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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 ;;;; Here are the variable declarations, both user options and internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;;;; variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (defvar scroll-in-place t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 "*When this variable is true (i.e., non-`nil'), the standard GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 vertical scrolling commands `scroll-down', `scroll-up', `scroll-other-window-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 down', and `scroll-other-window' will attempt to keep point at its current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 position in the window (window line and column). In other words, point stays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 \"in place\" within the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 When this variable is `nil' the standard GNU Emacs vertical scrolling commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 behave as usual. The \"in place\" equivalents, however, are still available as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 separate commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 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
488 place\" scrolling in particular buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; I have thought about dividing `scroll-in-place' into three variables: a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;; list of commands that always scroll in place, a list of commands that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;; never scroll in place, and a flag that determines the default behavior of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; other scrolling commands. This could make it easier to make "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; scrolling the default because one could single out certain ill-behaved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; 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
495 ;; be worth it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defvar scroll-allow-blank-lines-past-eob nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 "*When this variable is `nil' the \"in place\" scrolling commands will avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 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
501 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
502 \"in place\" scrolling commands try to avoid displaying \"dead space\" past the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 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
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 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
506 a previous scrolling action reversible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 When this variable is non-`nil' the \"in place\" scrolling commands will always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 allow blank lines to be shown past the end of the buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;;;; The following variables are not user options, but are intended to be set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;;;; by code outside this package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (defvar scroll-default-lines nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 "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
518 place\" scrolling commands begins. Of course, when an explicit number of lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 is specified, that explicit number takes precedence. See the documentation for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 the function `scroll-window-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 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
523 the height of the window to be scrolled minus `next-screen-context-lines'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 This variable should not be set globally! Commands that want to specify a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 default scrolling distance should just bind the variable `scroll-default-lines'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 temporarily.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (defvar scroll-command-groups nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 "The explicitly specified \"groups\" of \"in place\" scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 This variable should be set before or immediately after the \"in place\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 scrolling package is loaded, and then not changed after that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 Usually, \"in place\" scrolling commands share state (e.g., the number of lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 to scroll by) with any and all immediately previous \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 commands. Sometimes, however, this is undesirable. In these cases the \"in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 place\" scrolling commands can be divided into groups. A command in a group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 only shares state with members of its group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 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
541 members of a unique command group. For example, if there were only one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 explicit group and that group contained the commands `scroll-down-one-line' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 `scroll-up-one-line', then `scroll-command-groups' would be set to:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ((scroll-down-one-line scroll-up-one-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 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
548 group. That group is stored in the variable `scroll-default-command-group'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 The \"in place\" scrolling functions assume that all of the scrolling command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 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
552 only contain \"in place\" scrolling commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;;;; The variables below this point are internal to this package.
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 (defvar scroll-default-command-group nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 "The set of \"in place\" scrolling commands that are not members of any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 explicitly defined group of commands. This set of commands is an implicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 defined group, constructed as \"in place\" commands are invoked, and members of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 this group share state among themselves. See the documentation for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 variable `scroll-command-groups' for more information.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defvar scroll-initially-displayed-lines 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 "The number of window lines that contained buffer text when the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 sequence of \"in place\" scrolling commands started. Unless the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 `scroll-in-place-allow-blank-lines-past-eob' is true, the \"in place\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 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
570 times.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (defvar scroll-previous-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 "The window that was most recently scrolled by an \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 command.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (defvar scroll-previous-lines 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 "The number of window lines that the previous \"in place\" scrolling command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 attempted to scroll.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (defvar scroll-goal-column 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 "The desired horizontal window position for point, used by the \"in place\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 scrolling commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (defvar scroll-boundary-previous-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 "The value of point before point was moved to a buffer boundary.")
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-lines 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 "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
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (defvar scroll-boundary-error-command nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 "The value of `this-command' when an \"in place\" scrolling command signalled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 a buffer boundary error. This is used to decide how subsequent scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 commands should recover from the error.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (defvar scroll-boundary-error-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 "The value of point when an \"in place\" scrolling command signalled a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 boundary error. This is used to decide how subsequent scrolling commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 should recover from the error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 ;; This variable is used as a flag, indicating whether or not the previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;; "in place" scrolling command signalled an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (defvar scroll-window-debt 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 "The difference between the number of lines an \"in place\" scrolling command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 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
606 scrolled. This difference is the \"debt\" in the window's starting position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 Subsequent \"in place\" scrolling commands try to make up this debt.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (defconst scroll-pos-visible-bug-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;; On September 14, 1993, David Hughes <djh@Harston.CV.COM> told me that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ;; Lucid GNU Emacs 19.8 had inherited the bug from Epoch... sigh.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (let ((old-match-data (match-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (or (and (boundp 'epoch::version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (if (string-match "\\`4\\." emacs-version) t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (and (string-match "Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (if (string-match "\\`19\\.8\\." 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 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (store-match-data old-match-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 "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
623 function `pos-visible-in-window-p' that returns `nil' when given `(point-max)'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 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
625 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
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;;;; Here are the window-choosing auxiliary functions used by the new scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;;;; commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (defun scroll-choose-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 "Choose the window to be scrolled by the commands `scroll-down', `scroll-up',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 `scroll-down-in-place', and `scroll-up-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 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
642 just choose the selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 However, when a minibuffer window is selected, look first for the `minibuffer-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 scroll-window'. The `minibuffer-scroll-window' is usually the window that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 displays completions. If it exists, choose it; otherwise choose the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 window after the selected window in the canonical ordering of windows. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 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
649 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
650 (let ((selected-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (if (window-minibuffer-p selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; A minibuffer window is selected --- scroll some other window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (if (window-live-p minibuffer-scroll-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 minibuffer-scroll-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;; We know that the (selected) minibuffer is active, so `next-window'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 ;; will examine all of the frames that share this minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ;; Should we consider `other-window-scroll-buffer' here? I don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;; believe so.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (next-window selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (defun scroll-choose-other-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 "Choose the window to be scrolled by the commands `scroll-other-window-down',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 `scroll-other-window', `scroll-other-window-down-in-place', and `scroll-other-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 window-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 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
672 choose either:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 + a window that displays the `other-window-scroll-buffer', if that buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 exists. Note, this function will display that buffer if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 + the next window after the selected window in the canonical ordering of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 windows. The next window is generally the one below the selected window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 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
680 of the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 However, when a minibuffer window is selected, look first for the `minibuffer-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 scroll-window'. The `minibuffer-scroll-window' is usually the window that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 displays completions. If it exists, choose it; otherwise choose the window to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 be scrolled as described above (`other-window-scroll-buffer' or next window).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 This function is essentially a Lisp version of the function `other-window-for-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 scrolling' which first appeared in the FSF's GNU Emacs 19.26."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (let* ((no-error nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (selected-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (other-window nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (setq other-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (cond ((and (window-minibuffer-p selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (window-live-p minibuffer-scroll-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; Don't signal an error when `minibuffer-scroll-window' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;; the minibuffer itself --- which would be really weird, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 ;; isn't necessarily erroneous.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (setq no-error t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 minibuffer-scroll-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ((and ;; `other-window-scroll-buffer' is an Emacs 19 invention.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (boundp 'other-window-scroll-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (bufferp other-window-scroll-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 ;; `buffer-name' is `nil' if the buffer has been killed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (buffer-name other-window-scroll-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ;; This is what FSF GNU Emacs 19.26 does, but it occurred to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; me: what if one of these forms returns the selected window?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;; Signalling an error would be bad news, so I added a flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (setq no-error t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (or (get-buffer-window other-window-scroll-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (display-buffer other-window-scroll-buffer t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 ((let ((next-window (next-window selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (if (eq next-window selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 next-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;; In Emacs 19 (FSF, Lucid, and XEmacs), look for a window on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; another visible frame. This could be written for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;; Epoch, too, I suppose...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (let ((this-window (next-window selected-window nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (while (not (or (eq this-window selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (scroll-choose-window-frame-visible-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 this-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (setq this-window (next-window this-window nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 this-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 ;; In older versions of Emacs, `next-window' didn't accept
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 ;; three arguments. Catch this error and then return the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 ;; selected window --- which will cause another error to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;; signalled later on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (wrong-number-of-arguments selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (if (and (not no-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (eq selected-window other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (error "There is no other window."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (defun scroll-choose-window-frame-visible-p (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 "Return a true value if the frame of the given WINDOW is visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (cond ((fboundp 'window-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (eq t (frame-visible-p (window-frame window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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 ;;;; Here are the "in place" scrolling commands (interactive functions) and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;;;; replacements for the standard GNU Emacs vertical scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 ;;;; Here are the new scroll "in place" commands.
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 (defun scroll-down-in-place (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 "Scroll the text of the current window downward by LINES lines, leaving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 as close as possible to its current window position (window line and column).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 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
770 case, when the current window is a minibuffer window, this command scrolls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 `minibuffer-scroll-window' (which is usually the list of completions) if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 exists, or otherwise the next window in the canonical ordering of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 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
775 it was moved by the immediately previous \"in place\" scrolling command, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 the value of the variable `scroll-default-lines' (usually almost a windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 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
778 previous command scrolled some other window, or when other circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 prevent the previous scrolling distance from being used). If LINES is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 symbol `-', then the scrolling distance is determined as if LINES had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 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
784 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
785 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
786 boundary. Any immediately subsequent \"in place\" scrolling commands will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 to restore point to its initial window position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (scroll-window-in-place (scroll-choose-window) lines -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (defun scroll-up-in-place (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 "Scroll the text of the current window upward by LINES lines, leaving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 as close as possible to its current window position (window line and column).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 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
799 case, when the current window is a minibuffer window, this command scrolls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 `minibuffer-scroll-window' (which is usually the list of completions) if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 exists, or otherwise the next window in the canonical ordering of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 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
804 it was moved by the immediately previous \"in place\" scrolling command, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 the value of the variable `scroll-default-lines' (usually almost a windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 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
807 previous command scrolled some other window, or when other circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 prevent the previous scrolling distance from being used). If LINES is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 symbol `-', then the scrolling distance is determined as if LINES had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 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
813 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
814 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
815 boundary. Any immediately subsequent \"in place\" scrolling commands will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 to restore point to its initial window position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (scroll-window-in-place (scroll-choose-window) lines 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 ;;; The command `scroll-other-window-down' first appeared in FSF GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ;;; 19.26.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (defun scroll-other-window-down-in-place (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 "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
827 that window as close as possible to its current window position (window line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 and column). In other words, point is left \"in place\" within the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 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
830 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
831 special circumstances this command will scroll a window other than the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 window. Read the documentation for the function `scroll-choose-other-window'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 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
836 it was moved by the immediately previous \"in place\" scrolling command, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 the value of the variable `scroll-default-lines' (usually almost a windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 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
839 previous command scrolled some other window, or when other circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 prevent the previous scrolling distance from being used). If LINES is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 symbol `-', then the scrolling distance is determined as if LINES had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 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
845 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
846 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
847 boundary. Any immediately subsequent \"in place\" scrolling commands will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 to restore point to its initial window position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 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
851 boundary is already visible), this command signals a buffer boundary error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 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
853 lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (scroll-window-in-place (scroll-choose-other-window) lines -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 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (defun scroll-other-window-in-place (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 "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
863 that window as close as possible to its current window position (window line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 and column). In other words, point is left \"in place\" within the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 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
866 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
867 special circumstances this command will scroll a window other than the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 window. Read the documentation for the function `scroll-choose-other-window'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 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
872 it was moved by the immediately previous \"in place\" scrolling command, or by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 the value of the variable `scroll-default-lines' (usually almost a windowful)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 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
875 previous command scrolled some other window, or when other circumstances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 prevent the previous scrolling distance from being used). If LINES is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 symbol `-', then the scrolling distance is determined as if LINES had been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 `nil' and then that distance is multiplied by -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 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
881 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
882 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
883 boundary. Any immediately subsequent \"in place\" scrolling commands will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 to restore point to its initial window position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 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
887 boundary is already visible), this command signals a buffer boundary error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 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
889 lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (scroll-window-in-place (scroll-choose-other-window) lines 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 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ;;;; Here are the replacements for GNU Emacs' standard vertical scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ;;;; commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (or (fboundp 'original-scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (fset 'original-scroll-down (symbol-function 'scroll-down)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (or (fboundp 'original-scroll-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (fset 'original-scroll-up (symbol-function 'scroll-up)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (or (fboundp 'original-scroll-other-window-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; `scroll-other-window-down' first appeared in FSF GNU Emacs 19.26.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (if (fboundp 'scroll-other-window-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (fset 'original-scroll-other-window-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (symbol-function 'scroll-other-window-down))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (or (fboundp 'original-scroll-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (fset 'original-scroll-other-window (symbol-function 'scroll-other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (defun scroll-down (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 "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
918 case, when the current window is a minibuffer window, this command scrolls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 `minibuffer-scroll-window' (which is usually the list of completions) if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 exists, or otherwise the next window in the canonical ordering of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 The argument LINES is optional. Its meaning depends on the current value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 the variable `scroll-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 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
926 command `scroll-down-in-place', scrolling the current window and leaving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 \"in place\" within the window. See the documentation for the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 `scroll-down-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 When the variable `scroll-in-place' is `nil' this command invokes the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 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
932 current window is scrolled by nearly a complete windowful of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 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
935 buffer-local value in the window to be scrolled. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (scroll-window (scroll-choose-window) lines -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (defun scroll-up (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 "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
945 case, when the current window is a minibuffer window, this command scrolls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 `minibuffer-scroll-window' (which is usually the list of completions) if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 exists, or otherwise the next window in the canonical ordering of windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 The argument LINES is optional. Its meaning depends on the current value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 the variable `scroll-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 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
953 command `scroll-up-in-place', scrolling the current window and leaving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 \"in place\" within the window. See the documentation for the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 `scroll-up-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 When the variable `scroll-in-place' is `nil' this command invokes the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 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
959 current window is scrolled by nearly a complete windowful of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 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
962 buffer-local value in the window to be scrolled. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (scroll-window (scroll-choose-window) lines 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 ;;; 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
968 ;;; 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
969 ;;; like `scroll-other-window'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (defun scroll-other-window-down (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 "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
974 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
975 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
976 this command will scroll a window other than the next window. Read the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 documentation for the function `scroll-choose-other-window' for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 The argument LINES is optional. Its meaning depends on the current value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 the variable `scroll-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 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
983 command `scroll-other-window-down-in-place', scrolling the next window and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 leaving point \"in place\" within that window. See the documentation for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 command `scroll-other-window-down-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 When the variable `scroll-in-place' is `nil' this command invokes the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 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
989 `nil' the next window is scrolled by nearly a complete windowful of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 \(Note that `scroll-other-window-down' first appeared as a standard command in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 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
992 available in the current Emacs system, an equivalent action is invoked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 instead.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 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
996 buffer-local value in the window to be scrolled. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ;; This code is similar to the body of `scroll-window', below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (let* ((other-window (scroll-choose-other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (other-window-buffer (window-buffer other-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (if ;; Allow `scroll-in-place' to be a buffer-local variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (save-excursion (set-buffer other-window-buffer) scroll-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (scroll-window-in-place other-window lines -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 ;; Paranoid, we forcibly break any running sequence of "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 ;; scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (setq scroll-previous-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 ;; For XEmacs and Lucid GNU Emacs, preserve the region's state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (if (boundp 'zmacs-region-stays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (setq zmacs-region-stays t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (if (fboundp 'original-scroll-other-window-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (original-scroll-other-window-down lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 ;; `scroll-other-window-down' first appeared as a builtin in FSF GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 ;; 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
1015 ;; Do the equivalent thing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (original-scroll-other-window (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ((null lines) '-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ((eq lines '-) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (t (- (prefix-numeric-value lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (defun scroll-other-window (&optional lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 "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
1030 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
1031 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
1032 this command will scroll a window other than the next window. Read the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 documentation for the function `scroll-choose-other-window' for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 The argument LINES is optional. Its meaning depends on the current value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 the variable `scroll-in-place'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 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
1039 command `scroll-other-window-in-place', scrolling the next window and leaving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 point \"in place\" within that window. See the documentation for the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 `scroll-other-window-in-place' for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 When the variable `scroll-in-place' is `nil' this command invokes the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 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
1045 the next window is scrolled by nearly a complete windowful of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 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
1048 buffer-local value in the window to be scrolled. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 ;; This code is similar to the body of `scroll-window', below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (let* ((other-window (scroll-choose-other-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (other-window-buffer (window-buffer other-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (if ;; Allow `scroll-in-place' to be a buffer-local variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (save-excursion (set-buffer other-window-buffer) scroll-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (scroll-window-in-place other-window lines 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 ;; Paranoid, we forcibly break any running sequence of "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 ;; scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (setq scroll-previous-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 ;; For XEmacs and Lucid GNU Emacs, preserve the region's state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (if (boundp 'zmacs-region-stays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (setq zmacs-region-stays t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (original-scroll-other-window lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 ;;;; Here are the new functions `scroll-window-in-place', `scroll-window', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 ;;;; `scroll-window-in-place-continue-sequence'. These functions are intended
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 ;;;; to be available to programs outside this package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (defun scroll-window-in-place (window lines direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 "Scroll WINDOW vertically by the given number of window LINES in the given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 DIRECTION, leaving the window's point as close as possible to its original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 window position (window line and column). In other words, the window's point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 is left \"in place\" within the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 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
1084 and that this function does not change which window is selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 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
1087 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
1088 the amount it was moved by the immediately previous \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 command, or by the value of the variable `scroll-default-lines' (by default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 almost a windowful) if the previous command was not an \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 command (or when WINDOW is not the previously scrolled window, or when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 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
1093 command (see the documentation for the variable `scroll-command-groups'), or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 when other circumstances prevent the previous scrolling distance from being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 used). If LINES is the symbol `-', then the scrolling distance is determined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 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
1097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 DIRECTION determines the direction of the scrolling motion. The values -1 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 `down' indicate downward motion; the values 1 and `up' indicate upward motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 Any other value causes an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 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
1103 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
1104 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
1105 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
1106 was already there, in which case a buffer boundary error is signalled instead).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 Any immediately subsequent \"in place\" scrolling commands will try to restore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 point to its initial window position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 Unless the variable `scroll-allow-blank-lines-past-eob' is true, this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 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
1112 make a previous \"in place\" scrolling action reversible. Effectively, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 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
1114 lines than were visible when the current sequence of \"in place\" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 commands started. When the variable `scroll-allow-blank-lines-past-eob' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 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
1117 point \"in place\" in the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 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
1120 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
1121 this function signals a buffer boundary error. The error is signalled even if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 point could otherwise move the full number of lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (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
1124 ;; with our variables out of sync.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (original-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (original-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (window-height (- (window-height window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (if (window-minibuffer-p window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 0 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (this-command-group (scroll-get-command-group this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (continue-scroll-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (and ;; We're scrolling the previously scrolled window...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (windowp scroll-previous-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (eq window scroll-previous-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 ;; ...and the last command was an "in place" scrolling command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 ;; that can be continued by this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (if (eq last-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 ;; If the previous command signalled an error, the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 ;; `last-command' is `t'. Try to see if we signalled the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 ;; error and if point is where we left it. (NOTE that FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 ;; GNU Emacs 19.23+ no longer sets `last-command' to `t'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 ;; when a command signals an error. This is OK because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 ;; else part of this `if' does the appropriate thing.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (and scroll-boundary-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (eq (window-point window) scroll-boundary-error-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (memq scroll-boundary-error-command this-command-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 ;; Otherwise...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (memq last-command this-command-group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (lines-value (prefix-numeric-value lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 ;; For XEmacs and Lucid GNU Emacs, preserve the region's state. Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 ;; these Emacsen will forcibly deactivate the region if we signal an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;; later on. Is this bad?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (if (boundp 'zmacs-region-stays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (setq zmacs-region-stays t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ;; Parse the direction into a unit distance (1 or -1).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (setq direction (scroll-parse-direction direction))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (setq scroll-previous-window window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 ;; `(setq scroll-boundary-error-command nil)' is not necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 scroll-boundary-error-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; `select-window' does an implicit `set-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (if (or ;; The current command is not a continuation of a running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;; sequence of "in place" scrolling commands...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (not continue-scroll-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; ...or we were given an explicit number of lines to scroll,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; and that number has a different magnitude than the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 ;; number of lines we scrolled...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (and (or (numberp lines) (consp lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (/= scroll-previous-lines lines-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (/= scroll-previous-lines (- lines-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 ;; ...or the last successful scrolling command moved to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 ;; buffer boundary, but the buffer is no longer in the state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 ;; we left it. (This can occur if, for example, we signal an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 ;; end-of-buffer error and something catches it and moves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 ;; point or renarrows. VM, for example, does this.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (and scroll-boundary-previous-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (or (not (or (bobp) (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (< scroll-boundary-previous-point (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (> scroll-boundary-previous-point (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (eq scroll-boundary-previous-point (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 ;; We're starting a new sequence of scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (setq lines (if (or (numberp lines) (consp lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 lines-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;; The default number of lines...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (* (if (eq lines '-) -1 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (if (numberp scroll-default-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 scroll-default-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (max (- window-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 next-screen-context-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 scroll-previous-lines lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 scroll-goal-column (scroll-determine-goal-column window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 scroll-boundary-previous-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 ;; `(setq scroll-boundary-previous-lines 0)' is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 ;; necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 scroll-window-debt 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 scroll-initially-displayed-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (if scroll-allow-blank-lines-past-eob
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (goto-char (window-start window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (vertical-motion (1- window-height)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;; Otherwise we want to scroll by the same number of lines (but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 ;; possibly in a different direction) that we scrolled in previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; invocations of this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (cond ((null lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (setq lines scroll-previous-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 ((eq lines '-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (setq lines (- scroll-previous-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 scroll-previous-lines lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (setq lines lines-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 scroll-previous-lines lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (setq lines (* direction lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ;; If point is not in the window, center window around point. We try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 ;; 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
1231 ;; of Emacs (see `scroll-pos-visible-bug-p', above).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (if (pos-visible-in-window-p (let ((point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (if (and scroll-pos-visible-bug-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (= point (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (max (1- point) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (vertical-motion (/ (- window-height) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (set-window-start window (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (cond ((and scroll-boundary-previous-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 ;; `lines' is the same sign as the direction from point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 ;; to the `scroll-boundary-previous-point'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (cond ((> lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (> (- scroll-boundary-previous-point (point)) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 ((< lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (< (- scroll-boundary-previous-point (point)) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ;; We're moving away from the buffer boundary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (goto-char scroll-boundary-previous-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ;; Always move here (i.e., don't reject cases in which the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;; window doesn't move).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (scroll-set-window-start window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (- scroll-boundary-previous-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; (message "Back, window debt is %s." scroll-window-debt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (setq scroll-boundary-previous-point nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ((= lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 ;; We're going nowhere, so save ourselves some work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ;; (message "Scrolled zero lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;; Perform the scrolling motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (let ((initial-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (moved nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 ;; First move point and see how far it goes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (setq moved (vertical-motion lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (if (= moved lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 ;; Point moved the full distance. Move to the desired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ;; column and then try to move the window the full
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 ;; distance, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (move-to-column (+ (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 scroll-goal-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (or (scroll-set-window-start window moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 original-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (scroll-signal-boundary-error initial-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 ;; (message "Normal, window debt is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 ;; scroll-window-debt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 ;; Point couldn't move all the way. Move to the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 ;; boundary if we're not already there, or signal a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ;; boundary error otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (let ((boundary-point (if (< lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (boundary-symbol (if (< lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 'beginning-of-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 'end-of-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (if (= initial-point boundary-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (scroll-signal-boundary-error initial-point lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 ;; Scroll the window by as many lines as point could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 ;; move.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (or (scroll-set-window-start window moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 original-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (scroll-signal-boundary-error initial-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (message "%s" (get boundary-symbol 'error-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ;; (message "Boundary, window debt is %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 ;; scroll-window-debt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (setq scroll-boundary-previous-lines moved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (setq scroll-boundary-previous-point initial-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (goto-char boundary-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 ;; The unwind forms of the `unwind-protect', above. Restore the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 ;; originally selected window and current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (select-window original-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (set-buffer original-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;; The standard GNU Emacs scrolling commands return `nil' so we do, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 ;;;
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 (defun scroll-window (window lines direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 "Scroll WINDOW vertically by the given number of window LINES in the given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 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
1326 selected window, and that this function does not change which window is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 When the variable `scroll-in-place' is true, this function simply invokes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 function `scroll-window-in-place' to scroll the window and leave point \"in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 place\" within that window. See the documentation for `scroll-window-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 When the variable `scroll-in-place' is `nil' this function invokes the original
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 version of the standard GNU Emacs command `scroll-down' or `scroll-up', as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 determined by DIRECTION, to scroll the window. If DIRECTION is -1 or `down',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 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
1338 `scroll-up' is called. Any other DIRECTION is an error. LINES is interpreted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 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
1340 by almost a complete windowful. If LINES is the symbol `-', the window is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 scrolled by almost a complete windowful in the opposite direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 Note that this function correctly handles cases in which `scroll-in-place' has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 a buffer-local value in the WINDOW's buffer. That value is honored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (let ((current-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (selected-window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (window-buffer (window-buffer window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (if ;; Allow `scroll-in-place' to be a buffer-local variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (if (eq current-buffer window-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 scroll-in-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (save-excursion (set-buffer window-buffer) scroll-in-place))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (scroll-window-in-place window lines direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 ;; Paranoid, we forcibly break any running sequence of "in place"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 ;; scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (setq scroll-previous-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 ;; For XEmacs and Lucid GNU Emacs, preserve the region's state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (if (boundp 'zmacs-region-stays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (setq zmacs-region-stays t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (if (= (scroll-parse-direction direction) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (original-scroll-up lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (original-scroll-down lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (select-window selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (set-buffer current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;;; The following function is sometimes useful. For example, I call it from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;;; functions that are invoked by certain mouse button down events in order to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 ;;; preserve any running chain of "in place" scrolling commands. This lets me
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 ;;; continue the sequence from my mouse button up functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 ;;; 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
1377 ;;; "in place" scrolling commands. Such a function would be easy to write,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 ;;; however; just set the variable `scroll-previous-window' to `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (defun scroll-window-in-place-continue-sequence ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 "If the previous command was a \"scroll in place\" command, set the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 `this-command' to the name of that previous command. This ensures that any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 running sequence of \"in place\" scrolling commands will not be broken by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 current command. See the documentation for the commands `scroll-down-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 and `scroll-up-in-place' for more information about \"in place\" scrolling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 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
1389 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
1390 a \"scroll in place\" command but you still want to preserve any running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 sequence of \"in place\" commands. Such situations are rare.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 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
1394 scrolling commands. If something else subsequently sets `this-command', any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 running sequence of scrolling commands will probably be broken anyway."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (if (if (eq last-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 ;; If `last-command' is `t', then the previous command signalled an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 ;; error. See if the last invocation of `scroll-window-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 ;; signalled an error. (NOTE that FSF GNU Emacs 19.23+ no longer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 ;; sets `last-command' to `t' when a command signals an error. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 ;; is OK because the else part of this `if' does the appropriate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 ;; thing.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 scroll-boundary-error-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 ;; Otherwise, the value of `last-command' must belong to some group of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 ;; "in place" scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (or (memq last-command scroll-default-command-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (let ((groups scroll-command-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (while (and groups (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (if (memq last-command (car groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (setq groups (cdr groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 found)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (setq this-command last-command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 ;;;; Here are the various auxiliary functions called by the function `scroll-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 ;;;; window-in-place'. None of the functions are intended to be called from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 ;;;; outside this package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (defun scroll-get-command-group (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 "Return the group of \"in place\" scrolling commands that contains the given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 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
1431 state and form \"chains.\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 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
1434 call this function from other code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 ;; This function assumes that the given command is an "in place" scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;; command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (let ((groups scroll-command-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (found nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (while (and groups (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (if (memq command (car groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (setq found t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (setq groups (cdr groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (if groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (car groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 ;; Otherwise return the default command group. If necessary, add the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 ;; given command to the default command group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (or (memq command scroll-default-command-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (setq scroll-default-command-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (cons command scroll-default-command-group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 scroll-default-command-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (defun scroll-parse-direction (direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 "Return the signed unit distance for the given DIRECTION. If DIRECTION is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 unacceptable, signal an error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (cond ((or (eq direction 1) (eq direction -1)) direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ((eq direction 'up) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ((eq direction 'down) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (t (signal 'args-out-of-range (list 'direction direction)))
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-determine-goal-column (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 "Return the goal column for the \"in place\" vertical scrolling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 This is the horizontal window position at which these commands try to keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 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
1477 call this function from other code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 ;; NOTE that `window' must be the selected window! `scroll-window-in-place'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 ;; ensures that this is so.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (cond ((or truncate-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (and truncate-partial-width-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (< (window-width window) (screen-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (> (window-hscroll window) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 ;; Lines in this window are being truncated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (if (and track-eol (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 9999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 ((and track-eol (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 ;; 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
1490 ;; 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
1491 ;; wrong window line. This is the best we can do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (1- (window-width window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (t (% (current-column) (1- (window-width window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (defun scroll-set-window-start (window lines &optional original-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 "Move the `window-start' of the given window, which must be the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 window. If the window was successfully scrolled, update the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 `scroll-window-debt' and return `t'. Otherwise return `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 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
1506 call this function from other code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (goto-char (window-start window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; Try to move the window start by the specified number of lines. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ;; addition, try to make up any existing debt in the window start's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 ;; 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
1512 ;; buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (let ((moved (+ (vertical-motion (+ lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 scroll-window-debt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 scroll-initially-displayed-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (vertical-motion (- scroll-initially-displayed-lines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 ;; If we're not scrolling the `original-window' (i.e., the originally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 ;; selected window), punt if we didn't move the window start at all.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (if (and original-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (not (eq window original-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (= moved 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 ;; Otherwise update the window start and keep track of the debt in our
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 ;; position. Return `t' to indicate success.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (set-window-start window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (setq scroll-window-debt (- (+ lines scroll-window-debt) moved))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (defun scroll-signal-boundary-error (initial-point lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 "Move point to its initial location and signal an appropriate buffer boundary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 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
1539 call this function from other code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (goto-char initial-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ;; Remember what we were doing and where point was when we signalled the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 ;; error so that subsequent "in place" scrolling commands can decide how to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 ;; recover.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (setq scroll-boundary-error-command this-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 scroll-boundary-error-point initial-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (signal (if (< lines 0) 'beginning-of-buffer 'end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 ;;;; Finally, here is the `provide' statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (provide 'scroll-in-place)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 ;; End of file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561