Mercurial > emacs
annotate lisp/follow.el @ 78876:6824f67c5a37
(file-name-sans-versions): Also allow `A-Z'.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sat, 22 Sep 2007 17:52:17 +0000 |
parents | a4cabf2eaad3 |
children | d771a0b43ed5 |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36904
diff
changeset
|
1 ;;; follow.el --- synchronize windows showing the same buffer |
14578 | 2 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 1997, 1999, 2001, 2002, 2003, 2004, |
75347 | 4 ;; 2005, 2006, 2007 Free Software Foundation, Inc. |
14578 | 5 |
26523
c06aa85fd1ad
Use modern backquote syntax. Minor comment update.
Gerd Moellmann <gerd@gnu.org>
parents:
22250
diff
changeset
|
6 ;; Author: Anders Lindgren <andersl@andersl.com> |
65538
84cee1f8c06a
Change Maintainer field.
Richard M. Stallman <rms@gnu.org>
parents:
64762
diff
changeset
|
7 ;; Maintainer: FSF (Anders' email bounces, Sep 2005) |
26523
c06aa85fd1ad
Use modern backquote syntax. Minor comment update.
Gerd Moellmann <gerd@gnu.org>
parents:
22250
diff
changeset
|
8 ;; Created: 1995-05-25 |
22250
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21937
diff
changeset
|
9 ;; Keywords: display, window, minor-mode, convenience |
14578 | 10 |
14992 | 11 ;; This file is part of GNU Emacs. |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14578 | 14 ;; it under the terms of the GNU General Public License as published by |
78236
9355f9b7bbff
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
78162
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
14578 | 16 ;; any later version. |
17 | |
14992 | 18 ;; GNU Emacs is distributed in the hope that it will be useful, |
14578 | 19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
14992 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64091 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
14578 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;;{{{ Documentation | |
31 | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
32 ;; `Follow mode' is a minor mode for Emacs and XEmacs that |
14578 | 33 ;; combines windows into one tall virtual window. |
34 ;; | |
35 ;; The feeling of a "virtual window" has been accomplished by the use | |
36 ;; of two major techniques: | |
37 ;; | |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
38 ;; * The windows always display adjacent sections of the buffer. |
14578 | 39 ;; This means that whenever one window is moved, all the |
40 ;; others will follow. (Hence the name Follow Mode.) | |
41 ;; | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
42 ;; * Should the point (cursor) end up outside a window, another |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
43 ;; window displaying that point is selected, if possible. This |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
44 ;; makes it possible to walk between windows using normal cursor |
14578 | 45 ;; movement commands. |
46 ;; | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
47 ;; Follow mode comes to its prime when a large screen and two |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
48 ;; side-by-side window are used. The user can, with the help of Follow |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
49 ;; mode, use two full-height windows as though they are one. |
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
50 ;; Imagine yourself editing a large function, or section of text, |
18028
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
51 ;; and being able to use 144 lines instead of the normal 72... (your |
14578 | 52 ;; mileage may vary). |
53 | |
54 ;; To test this package, make sure `follow' is loaded, or will be | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
55 ;; autoloaded when activated (see below). Then do the following: |
14578 | 56 ;; |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
57 ;; * Find your favorite file (preferably a long one). |
14578 | 58 ;; |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
59 ;; * Resize Emacs so that it will be wide enough for two full size |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
60 ;; columns. Delete the other windows and split the window with |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
61 ;; the commands `C-x 1 C-x 3'. |
14578 | 62 ;; |
63 ;; * Give the command: | |
64 ;; M-x follow-mode <RETURN> | |
65 ;; | |
66 ;; * Now the display should look something like (assuming the text "71" | |
67 ;; is on line 71): | |
68 ;; | |
69 ;; +----------+----------+ | |
70 ;; |1 |73 | | |
71 ;; |2 |74 | | |
72 ;; |3 |75 | | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
73 ;; ... ... |
14578 | 74 ;; |71 |143 | |
75 ;; |72 |144 | | |
76 ;; +----------+----------+ | |
77 ;; | |
78 ;; As you can see, the right-hand window starts at line 73, the line | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
79 ;; immediately below the end of the left-hand window. As long as |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
80 ;; `follow-mode' is active, the two windows will follow each other! |
14578 | 81 ;; |
82 ;; * Play around and enjoy! Scroll one window and watch the other. | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
83 ;; Jump to the beginning or end. Press `Cursor down' at the last |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
84 ;; line of the left-hand window. Enter new lines into the |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
85 ;; text. Enter long lines spanning several lines, or several |
14578 | 86 ;; windows. |
87 ;; | |
88 ;; * Should you find `Follow' mode annoying, just type | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
89 ;; M-x follow-mode <RETURN> |
14578 | 90 ;; to turn it off. |
91 | |
92 | |
93 ;; The command `follow-delete-other-windows-and-split' maximises the | |
94 ;; visible area of the current buffer. | |
95 ;; | |
96 ;; I recommend adding it, and `follow-mode', to hotkeys in the global | |
97 ;; key map. To do so, add the following lines (replacing `[f7]' and | |
98 ;; `[f8]' with your favorite keys) to the init file: | |
99 ;; | |
100 ;; (global-set-key [f8] 'follow-mode) | |
101 ;; (global-set-key [f7] 'follow-delete-other-windows-and-split) | |
102 | |
103 | |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
104 ;; There exist two system variables that control the appearence of |
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
105 ;; lines wider than the window containing them. The default is to |
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
106 ;; truncate long lines whenever a window isn't as wide as the frame. |
14578 | 107 ;; |
108 ;; To make sure lines are never truncated, please place the following | |
109 ;; lines in your init file: | |
110 ;; | |
111 ;; (setq truncate-lines nil) | |
112 ;; (setq truncate-partial-width-windows nil) | |
113 | |
114 | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
115 ;; Since the display of XEmacs is pixel-oriented, a line could be |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
116 ;; clipped in half at the bottom of the window. |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
117 ;; |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
118 ;; To make XEmacs avoid clipping (normal) lines, please place the |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
119 ;; following line in your init-file: |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
120 ;; |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
121 ;; (setq pixel-vertical-clip-threshold 30) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
122 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
123 |
14578 | 124 ;; The correct way to cofigurate Follow mode, or any other mode for |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
125 ;; that matter, is to create one or more functions that do |
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
126 ;; whatever you would like to do. These functions are then added to |
14578 | 127 ;; a hook. |
128 ;; | |
129 ;; When `Follow' mode is activated, functions stored in the hook | |
130 ;; `follow-mode-hook' are called. When it is deactivated | |
48409 | 131 ;; `follow-mode-off-hook' is run. |
14578 | 132 ;; |
133 ;; The keymap `follow-key-map' contains key bindings activated by | |
134 ;; `follow-mode'. | |
135 ;; | |
136 ;; Example: | |
137 ;; (add-hook 'follow-mode-hook 'my-follow-mode-hook) | |
138 ;; | |
139 ;; (defun my-follow-mode-hook () | |
140 ;; (define-key follow-mode-map "\C-ca" 'your-favorite-function) | |
141 ;; (define-key follow-mode-map "\C-cb" 'another-function)) | |
142 | |
143 | |
144 ;; Usage: | |
145 ;; | |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
146 ;; To activate, issue the command "M-x follow-mode" |
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
147 ;; and press Return. To deactivate, do it again. |
14578 | 148 ;; |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
149 ;; The following is a list of commands useful when follow-mode is active. |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
150 ;; |
14578 | 151 ;; follow-scroll-up C-c . C-v |
152 ;; Scroll text in a Follow Mode window chain up. | |
153 ;; | |
154 ;; follow-scroll-down C-c . v | |
155 ;; Like `follow-scroll-up', but in the other direction. | |
156 ;; | |
157 ;; follow-delete-other-windows-and-split C-c . 1 | |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
158 ;; Maximize the visible area of the current buffer, |
14578 | 159 ;; and enter Follow Mode. This is a very convenient |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
160 ;; way to start Follow Mode, hence we recomend that |
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
161 ;; this command be added to the global keymap. |
14578 | 162 ;; |
163 ;; follow-recenter C-c . C-l | |
164 ;; Place the point in the center of the middle window, | |
165 ;; or a specified number of lines from either top or bottom. | |
166 ;; | |
167 ;; follow-switch-to-buffer C-c . b | |
168 ;; Switch buffer in all windows displaying the current buffer | |
169 ;; in this frame. | |
170 ;; | |
171 ;; follow-switch-to-buffer-all C-c . C-b | |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
172 ;; Switch buffer in all windows in the selected frame. |
14578 | 173 ;; |
174 ;; follow-switch-to-current-buffer-all | |
175 ;; Show the current buffer in all windows on the current | |
176 ;; frame and turn on `follow-mode'. | |
177 ;; | |
178 ;; follow-first-window C-c . < | |
179 ;; Select the first window in the frame showing the same buffer. | |
180 ;; | |
181 ;; follow-last-window C-c . > | |
182 ;; Select the last window in the frame showing the same buffer. | |
183 ;; | |
184 ;; follow-next-window C-c . n | |
185 ;; Select the next window in the frame showing the same buffer. | |
186 ;; | |
187 ;; follow-previous-window C-c . p | |
188 ;; Select the previous window showing the same buffer. | |
189 | |
190 | |
191 ;; Well, it seems ok, but what if I really want to look at two different | |
192 ;; positions in the text? Here are two simple methods to use: | |
193 ;; | |
194 ;; 1) Use multiple frames; `follow' mode only affects windows displayed | |
195 ;; in the same frame. (My apoligies to you who can't use frames.) | |
196 ;; | |
197 ;; 2) Bind `follow-mode' to key so you can turn it off whenever | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
198 ;; you want to view two locations. Of course, `follow' mode can |
14578 | 199 ;; be reactivated by hitting the same key again. |
200 ;; | |
201 ;; Example from my ~/.emacs: | |
202 ;; (global-set-key [f8] 'follow-mode) | |
203 | |
204 | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
205 ;; Implementation: |
14578 | 206 ;; |
207 ;; In an ideal world, follow mode would have been implemented in the | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
208 ;; kernel of the display routines, making sure that the windows (using |
78774
a4cabf2eaad3
Fix typos in file header commentary.
Eli Zaretskii <eliz@gnu.org>
parents:
78772
diff
changeset
|
209 ;; follow mode) ALWAYS are aligned. On planet Earth, however, we must |
14578 | 210 ;; accept a solution where we ALMOST ALWAYS can make sure that the |
211 ;; windows are aligned. | |
212 ;; | |
213 ;; Follow mode does this in three places: | |
214 ;; 1) After each user command. | |
215 ;; 2) After a process output has been perfomed. | |
216 ;; 3) When a scrollbar has been moved. | |
217 ;; | |
218 ;; This will cover most situations. (Let me know if there are other | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
219 ;; situations that should be covered.) |
14578 | 220 ;; |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
221 ;; Note that only the selected window is checked, for the reason of |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
222 ;; efficiency and code complexity. (I.e. it is possible to make a |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
223 ;; non-selected windows unaligned. It will, however, pop right back |
14578 | 224 ;; when it is selected.) |
225 | |
226 ;;}}} | |
227 | |
228 ;;; Code: | |
229 | |
230 ;;{{{ Preliminaries | |
231 | |
232 ;; Make the compiler shut up! | |
233 ;; There are two strategies: | |
234 ;; 1) Shut warnings off completely. | |
235 ;; 2) Handle each warning separately. | |
236 ;; | |
237 ;; Since I would like to see real errors, I've selected the latter | |
238 ;; method. | |
239 ;; | |
240 ;; The problem with undefined variables and functions has been solved | |
241 ;; by using `set', `symbol-value' and `symbol-function' rather than | |
242 ;; `setq' and direct references to variables and functions. | |
243 ;; | |
244 ;; For example: | |
245 ;; (if (boundp 'foo) ... (symbol-value 'foo) ) | |
246 ;; (set 'foo ...) <-- XEmacs doesn't fall for this one. | |
247 ;; (funcall (symbol-function 'set) 'bar ...) | |
248 ;; | |
249 ;; Note: When this file is interpreted, `eval-when-compile' is | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
250 ;; evaluted. Since it doesn't hurt to evaluate it, but it is a bit |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
251 ;; annoying, we test if the byte-compiler has been loaded. This can, |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
252 ;; of course, lead to some occasional unintended evaluation... |
14578 | 253 ;; |
254 ;; Should someone come up with a better solution, please let me | |
255 ;; know. | |
256 | |
257 (eval-when-compile | |
258 (if (or (featurep 'bytecomp) | |
259 (featurep 'byte-compile)) | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
260 (cond ((featurep 'xemacs) |
14578 | 261 ;; Make XEmacs shut up! I'm using standard Emacs |
262 ;; functions, they are NOT obsolete! | |
263 (if (eq (get 'force-mode-line-update 'byte-compile) | |
264 'byte-compile-obsolete) | |
265 (put 'force-mode-line-update 'byte-compile 'nil)) | |
266 (if (eq (get 'frame-first-window 'byte-compile) | |
267 'byte-compile-obsolete) | |
268 (put 'frame-first-window 'byte-compile 'nil)))))) | |
269 | |
270 ;;}}} | |
271 ;;{{{ Variables | |
272 | |
21088 | 273 (defgroup follow nil |
274 "Synchronize windows showing the same buffer." | |
275 :prefix "follow-" | |
22250
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21937
diff
changeset
|
276 :group 'windows |
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21937
diff
changeset
|
277 :group 'convenience) |
21088 | 278 |
279 (defcustom follow-mode-hook nil | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
280 "Hooks to run when Follow mode is turned on." |
21088 | 281 :type 'hook |
282 :group 'follow) | |
14578 | 283 |
21088 | 284 (defcustom follow-mode-off-hook nil |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
285 "Hooks to run when Follow mode is turned off." |
21088 | 286 :type 'hook |
287 :group 'follow) | |
14578 | 288 |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
289 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
290 ;;{{{ Keymap/Menu |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
291 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
292 ;; Define keys for the follow-mode minor mode map and replace some |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
293 ;; functions in the global map. All `follow' mode special functions |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
294 ;; can be found on (the somewhat cumbersome) "C-c . <key>" |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
295 ;; (Control-C dot <key>). (As of Emacs 19.29 the keys |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
296 ;; C-c <punctuation character> are reserved for minor modes.) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
297 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
298 ;; To change the prefix, redefine `follow-mode-prefix' before |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
299 ;; `follow' is loaded, or see the section on `follow-mode-hook' |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
300 ;; above for an example of how to bind the keys the way you like. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
301 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
302 ;; Please note that the keymap is defined the first time this file is |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
303 ;; loaded. Also note that the only legal way to manipulate the |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
304 ;; keymap is to use `define-key'. Don't change it using `setq' or |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
305 ;; similar! |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
306 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
307 (defcustom follow-mode-prefix "\C-c." |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
308 "Prefix key to use for follow commands in Follow mode. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
309 The value of this variable is checked as part of loading Follow mode. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
310 After that, changing the prefix key requires manipulating keymaps." |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
311 :type 'string |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
312 :group 'follow) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
313 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
314 (defvar follow-mode-map |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
315 (let ((mainmap (make-sparse-keymap)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
316 (map (make-sparse-keymap))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
317 (define-key map "\C-v" 'follow-scroll-up) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
318 (define-key map "\M-v" 'follow-scroll-down) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
319 (define-key map "v" 'follow-scroll-down) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
320 (define-key map "1" 'follow-delete-other-windows-and-split) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
321 (define-key map "b" 'follow-switch-to-buffer) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
322 (define-key map "\C-b" 'follow-switch-to-buffer-all) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
323 (define-key map "\C-l" 'follow-recenter) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
324 (define-key map "<" 'follow-first-window) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
325 (define-key map ">" 'follow-last-window) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
326 (define-key map "n" 'follow-next-window) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
327 (define-key map "p" 'follow-previous-window) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
328 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
329 (define-key mainmap follow-mode-prefix map) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
330 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
331 ;; Replace the standard `end-of-buffer', when in Follow Mode. (I |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
332 ;; don't see the point in trying to replace every function that |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
333 ;; could be enhanced in Follow mode. End-of-buffer is a special |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
334 ;; case since it is very simple to define and it greatly enhances |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
335 ;; the look and feel of Follow mode.) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
336 (define-key mainmap [remap end-of-buffer] 'follow-end-of-buffer) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
337 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
338 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
339 ;; The menu. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
340 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
341 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
342 (if (not (featurep 'xemacs)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
343 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
344 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
345 ;; Emacs |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
346 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
347 (let ((menumap (funcall (symbol-function 'make-sparse-keymap) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
348 "Follow")) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
349 (count 0) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
350 id) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
351 (mapcar |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
352 (function |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
353 (lambda (item) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
354 (setq id |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
355 (or (cdr item) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
356 (progn |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
357 (setq count (+ count 1)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
358 (intern (format "separator-%d" count))))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
359 (define-key menumap (vector id) item) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
360 (or (eq id 'follow-mode) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
361 (put id 'menu-enable 'follow-mode)))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
362 ;; In reverse order: |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
363 '(("Toggle Follow mode" . follow-mode) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
364 ("--") |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
365 ("Recenter" . follow-recenter) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
366 ("--") |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
367 ("Previous Window" . follow-previous-window) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
368 ("Next Windows" . follow-next-window) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
369 ("Last Window" . follow-last-window) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
370 ("First Window" . follow-first-window) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
371 ("--") |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
372 ("Switch To Buffer (all windows)" |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
373 . follow-switch-to-buffer-all) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
374 ("Switch To Buffer" . follow-switch-to-buffer) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
375 ("--") |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
376 ("Delete Other Windows and Split" |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
377 . follow-delete-other-windows-and-split) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
378 ("--") |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
379 ("Scroll Down" . follow-scroll-down) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
380 ("Scroll Up" . follow-scroll-up))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
381 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
382 ;; If there is a `tools' menu, we use it. However, we can't add a |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
383 ;; minor-mode specific item to it (it's broken), so we make the |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
384 ;; contents ghosted when not in use, and add ourselves to the |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
385 ;; global map. If no `tools' menu is present, just make a |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
386 ;; top-level menu visible when the mode is activated. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
387 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
388 (let ((tools-map (lookup-key (current-global-map) [menu-bar tools])) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
389 (last nil)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
390 (if (sequencep tools-map) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
391 (progn |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
392 ;; Find the last entry in the menu and store it in `last'. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
393 (mapcar (function |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
394 (lambda (x) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
395 (setq last (or (cdr-safe |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
396 (cdr-safe |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
397 (cdr-safe x))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
398 last)))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
399 tools-map) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
400 (if last |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
401 (progn |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
402 (funcall (symbol-function 'define-key-after) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
403 tools-map [separator-follow] '("--") last) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
404 (funcall (symbol-function 'define-key-after) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
405 tools-map [follow] (cons "Follow" menumap) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
406 'separator-follow)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
407 ;; Didn't find the last item, Adding to the top of |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
408 ;; tools. (This will probably never happend...) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
409 (define-key (current-global-map) [menu-bar tools follow] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
410 (cons "Follow" menumap)))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
411 ;; No tools menu, add "Follow" to the menubar. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
412 (define-key mainmap [menu-bar follow] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
413 (cons "Follow" menumap))))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
414 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
415 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
416 ;; XEmacs. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
417 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
418 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
419 ;; place the menu in the `Tools' menu. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
420 (let ((menu '("Follow" |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
421 :filter follow-menu-filter |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
422 ["Scroll Up" follow-scroll-up t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
423 ["Scroll Down" follow-scroll-down t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
424 ["Delete Other Windows and Split" |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
425 follow-delete-other-windows-and-split t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
426 ["Switch To Buffer" follow-switch-to-buffer t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
427 ["Switch To Buffer (all windows)" |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
428 follow-switch-to-buffer-all t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
429 ["First Window" follow-first-window t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
430 ["Last Window" follow-last-window t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
431 ["Next Windows" follow-next-window t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
432 ["Previous Window" follow-previous-window t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
433 ["Recenter" follow-recenter t] |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
434 ["Deactivate" follow-mode t]))) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
435 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
436 ;; Why not just `(set-buffer-menubar current-menubar)'? The |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
437 ;; question is a very good question. The reason is that under |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
438 ;; Emacs, neither `set-buffer-menubar' nor |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
439 ;; `current-menubar' is defined, hence the byte-compiler will |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
440 ;; warn. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
441 (funcall (symbol-function 'set-buffer-menubar) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
442 (symbol-value 'current-menubar)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
443 (funcall (symbol-function 'add-submenu) '("Tools") menu)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
444 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
445 ;; When the mode is not activated, only one item is visible: |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
446 ;; "Activate". |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
447 (defun follow-menu-filter (menu) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
448 (if follow-mode |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
449 menu |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
450 '(["Activate " follow-mode t])))) |
73760
6165f9a35bd8
(follow-avoid-tail-recenter-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
70226
diff
changeset
|
451 |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
452 mainmap) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
453 "Minor mode keymap for Follow mode.") |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
454 |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
455 ;;}}} |
14578 | 456 |
21088 | 457 (defcustom follow-mode-line-text " Follow" |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
458 "Text shown in the mode line when Follow mode is active. |
14578 | 459 Defaults to \" Follow\". Examples of other values |
21088 | 460 are \" Fw\", or simply \"\"." |
461 :type 'string | |
462 :group 'follow) | |
14578 | 463 |
21088 | 464 (defcustom follow-auto nil |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
465 "Non-nil activates Follow mode whenever a file is loaded." |
21088 | 466 :type 'boolean |
467 :group 'follow) | |
14578 | 468 |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
469 (defcustom follow-intercept-processes (fboundp 'start-process) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
470 "When non-nil, Follow Mode will monitor process output." |
21088 | 471 :type 'boolean |
472 :group 'follow) | |
14578 | 473 |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
474 (defvar follow-avoid-tail-recenter-p (not (featurep 'xemacs)) |
73760
6165f9a35bd8
(follow-avoid-tail-recenter-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
70226
diff
changeset
|
475 "*When non-nil, patch Emacs so that tail windows won't be recentered. |
14578 | 476 |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
477 A \"tail window\" is a window that displays only the end of |
14578 | 478 the buffer. Normally it is practical for the user that empty |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
479 windows are recentered automatically. However, when using |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
480 Follow Mode it breaks the display when the end is displayed |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
481 in a window \"above\" the last window. This is for |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
482 example the case when displaying a short page in info. |
14578 | 483 |
484 Must be set before Follow Mode is loaded. | |
485 | |
486 Please note that it is not possible to fully prevent Emacs from | |
487 recentering empty windows. Please report if you find a repeatable | |
488 situation in which Emacs recenters empty windows. | |
489 | |
490 XEmacs, as of 19.12, does not recenter windows, good!") | |
491 | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
492 (defvar follow-cache-command-list |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
493 '(next-line previous-line forward-char backward-char) |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
494 "List of commands that don't require recalculation. |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
495 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
496 In order to be able to use the cache, a command should not change the |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
497 contents of the buffer, nor should it change selected window or current |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
498 buffer. |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
499 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
500 The commands in this list are checked at load time. |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
501 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
502 To mark other commands as suitable for caching, set the symbol |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
503 property `follow-mode-use-cache' to non-nil.") |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
504 |
14578 | 505 (defvar follow-debug nil |
506 "*Non-nil when debugging Follow mode.") | |
507 | |
508 | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
509 ;; Internal variables: |
14578 | 510 |
511 (defvar follow-internal-force-redisplay nil | |
512 "True when Follow mode should redisplay the windows.") | |
513 | |
514 (defvar follow-process-filter-alist '() | |
515 "The original filters for processes intercepted by Follow mode.") | |
516 | |
517 (defvar follow-active-menu nil | |
518 "The menu visible when Follow mode is active.") | |
519 | |
520 (defvar follow-deactive-menu nil | |
521 "The menu visible when Follow mode is deactivated.") | |
522 | |
523 (defvar follow-inside-post-command-hook nil | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
524 "Non-nil when inside Follow modes `post-command-hook'. |
14578 | 525 Used by `follow-window-size-change'.") |
526 | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
527 (defvar follow-windows-start-end-cache nil |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
528 "Cache used by `follow-window-start-end'.") |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
529 |
14578 | 530 ;;}}} |
531 ;;{{{ Debug messages | |
532 | |
533 ;; This inline function must be as small as possible! | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
534 ;; Maybe we should define a macro that expands to nil if |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
535 ;; the variable is not set. |
14578 | 536 |
537 (defsubst follow-debug-message (&rest args) | |
538 "Like message, but only active when `follow-debug' is non-nil." | |
539 (if (and (boundp 'follow-debug) follow-debug) | |
540 (apply 'message args))) | |
541 | |
542 ;;}}} | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
543 ;;{{{ Cache |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
544 |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
545 (dolist (cmd follow-cache-command-list) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
546 (put cmd 'follow-mode-use-cache t)) |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
547 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
548 ;;}}} |
14578 | 549 |
550 ;;{{{ The mode | |
551 | |
552 ;;;###autoload | |
553 (defun turn-on-follow-mode () | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
554 "Turn on Follow mode. Please see the function `follow-mode'." |
14578 | 555 (interactive) |
556 (follow-mode 1)) | |
557 | |
558 | |
559 ;;;###autoload | |
560 (defun turn-off-follow-mode () | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
561 "Turn off Follow mode. Please see the function `follow-mode'." |
14578 | 562 (interactive) |
563 (follow-mode -1)) | |
564 | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
565 (put 'follow-mode 'permanent-local t) |
14578 | 566 ;;;###autoload |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
567 (define-minor-mode follow-mode |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
568 "Minor mode that combines windows into one tall virtual window. |
14578 | 569 |
570 The feeling of a \"virtual window\" has been accomplished by the use | |
571 of two major techniques: | |
572 | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
573 * The windows always displays adjacent sections of the buffer. |
14578 | 574 This means that whenever one window is moved, all the |
575 others will follow. (Hence the name Follow Mode.) | |
576 | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
577 * Should the point (cursor) end up outside a window, another |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
578 window displaying that point is selected, if possible. This |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
579 makes it possible to walk between windows using normal cursor |
14578 | 580 movement commands. |
581 | |
582 Follow mode comes to its prime when used on a large screen and two | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
583 side-by-side windows are used. The user can, with the help of Follow |
14578 | 584 mode, use two full-height windows as though they would have been |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
585 one. Imagine yourself editing a large function, or section of text, |
18028
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
586 and being able to use 144 lines instead of the normal 72... (your |
14578 | 587 mileage may vary). |
588 | |
589 To split one large window into two side-by-side windows, the commands | |
590 `\\[split-window-horizontally]' or \ | |
591 `M-x follow-delete-other-windows-and-split' can be used. | |
592 | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
593 Only windows displayed in the same frame follow each other. |
14578 | 594 |
595 If the variable `follow-intercept-processes' is non-nil, Follow mode | |
596 will listen to the output of processes and redisplay accordingly. | |
597 \(This is the default.) | |
598 | |
599 When Follow mode is switched on, the hook `follow-mode-hook' | |
600 is called. When turned off, `follow-mode-off-hook' is called. | |
601 | |
602 Keys specific to Follow mode: | |
603 \\{follow-mode-map}" | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
604 :keymap follow-mode-map |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
605 (if (and follow-mode follow-intercept-processes) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
606 (follow-intercept-process-output)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
607 (cond (follow-mode ; On |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
608 ;; XEmacs: If this is non-nil, the window will scroll before |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
609 ;; the point will have a chance to get into the next window. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
610 (if (boundp 'scroll-on-clipped-lines) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
611 (setq scroll-on-clipped-lines nil)) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
612 (force-mode-line-update) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
613 (add-hook 'post-command-hook 'follow-post-command-hook t) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
614 (run-hooks 'follow-mode-hook)) |
14578 | 615 |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
616 ((not follow-mode) ; Off |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
617 (force-mode-line-update) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
618 (run-hooks 'follow-mode-off-hook)))) |
14578 | 619 |
620 ;;}}} | |
621 ;;{{{ Find file hook | |
622 | |
623 ;; This will start follow-mode whenever a new file is loaded, if | |
624 ;; the variable `follow-auto' is non-nil. | |
625 | |
60902
7160fe3a7ef1
find-file-hooks -> find-file-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55257
diff
changeset
|
626 (add-hook 'find-file-hook 'follow-find-file-hook t) |
14578 | 627 |
628 (defun follow-find-file-hook () | |
629 "Find-file hook for Follow Mode. See the variable `follow-auto'." | |
630 (if follow-auto (follow-mode t))) | |
631 | |
632 ;;}}} | |
633 | |
634 ;;{{{ User functions | |
635 | |
636 ;;; | |
637 ;;; User functions usable when in Follow mode. | |
638 ;;; | |
639 | |
640 ;;{{{ Scroll | |
641 | |
642 ;; `scroll-up' and `-down', but for windows in Follow Mode. | |
643 ;; | |
644 ;; Almost like the real thing, excpet when the cursor ends up outside | |
645 ;; the top or bottom... In our case however, we end up outside the | |
646 ;; window and hence we are recenterd. Should we let `recenter' handle | |
647 ;; the point position we would never leave the selected window. To do | |
648 ;; it ourselves we would need to do our own redisplay, which is easier | |
649 ;; said than done. (Why didn't I do a real display abstraction from | |
650 ;; the beginning?) | |
651 ;; | |
652 ;; We must sometimes set `follow-internal-force-redisplay', otherwise | |
653 ;; our post-command-hook will move our windows back into the old | |
654 ;; position... (This would also be corrected if we would have had a | |
655 ;; good redisplay abstraction.) | |
656 | |
657 (defun follow-scroll-up (&optional arg) | |
658 "Scroll text in a Follow Mode window chain up. | |
659 | |
660 If called with no ARG, the `next-screen-context-lines' last lines of | |
661 the bottom window in the chain will be visible in the top window. | |
662 | |
663 If called with an argument, scroll ARG lines up. | |
664 Negative ARG means scroll downward. | |
665 | |
666 Works like `scroll-up' when not in Follow Mode." | |
667 (interactive "P") | |
668 (cond ((not (and (boundp 'follow-mode) follow-mode)) | |
669 (scroll-up arg)) | |
670 (arg | |
671 (save-excursion (scroll-up arg)) | |
672 (setq follow-internal-force-redisplay t)) | |
673 (t | |
674 (let* ((windows (follow-all-followers)) | |
675 (end (window-end (car (reverse windows))))) | |
676 (if (eq end (point-max)) | |
677 (signal 'end-of-buffer nil) | |
678 (select-window (car windows)) | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
679 ;; `window-end' might return nil. |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
680 (if end |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
681 (goto-char end)) |
14578 | 682 (vertical-motion (- next-screen-context-lines)) |
683 (set-window-start (car windows) (point))))))) | |
684 | |
685 | |
686 (defun follow-scroll-down (&optional arg) | |
687 "Scroll text in a Follow Mode window chain down. | |
688 | |
689 If called with no ARG, the `next-screen-context-lines' top lines of | |
690 the top window in the chain will be visible in the bottom window. | |
691 | |
692 If called with an argument, scroll ARG lines down. | |
693 Negative ARG means scroll upward. | |
694 | |
695 Works like `scroll-up' when not in Follow Mode." | |
696 (interactive "P") | |
697 (cond ((not (and (boundp 'follow-mode) follow-mode)) | |
698 (scroll-up arg)) | |
699 (arg | |
700 (save-excursion (scroll-down arg))) | |
701 (t | |
702 (let* ((windows (follow-all-followers)) | |
703 (win (car (reverse windows))) | |
704 (start (window-start (car windows)))) | |
705 (if (eq start (point-min)) | |
706 (signal 'beginning-of-buffer nil) | |
707 (select-window win) | |
708 (goto-char start) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
709 (vertical-motion (- (- (window-height win) |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
710 1 |
14578 | 711 next-screen-context-lines))) |
712 (set-window-start win (point)) | |
713 (goto-char start) | |
714 (vertical-motion (- next-screen-context-lines 1)) | |
715 (setq follow-internal-force-redisplay t)))))) | |
716 | |
717 ;;}}} | |
718 ;;{{{ Buffer | |
719 | |
720 ;;;###autoload | |
721 (defun follow-delete-other-windows-and-split (&optional arg) | |
722 "Create two side by side windows and enter Follow Mode. | |
723 | |
724 Execute this command to display as much as possible of the text | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
725 in the selected window. All other windows, in the current |
14578 | 726 frame, are deleted and the selected window is split in two |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
727 side-by-side windows. Follow Mode is activated, hence the |
14578 | 728 two windows always will display two successive pages. |
729 \(If one window is moved, the other one will follow.) | |
730 | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
731 If ARG is positive, the leftmost window is selected. If negative, |
14578 | 732 the rightmost is selected. If ARG is nil, the leftmost window is |
733 selected if the original window is the first one in the frame. | |
734 | |
735 To bind this command to a hotkey, place the following line | |
736 in your `~/.emacs' file, replacing [f7] by your favourite key: | |
737 (global-set-key [f7] 'follow-delete-other-windows-and-split)" | |
738 (interactive "P") | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
739 (let ((other (or (and (null arg) |
14578 | 740 (not (eq (selected-window) |
741 (frame-first-window (selected-frame))))) | |
742 (and arg | |
743 (< (prefix-numeric-value arg) 0)))) | |
744 (start (window-start))) | |
745 (delete-other-windows) | |
746 (split-window-horizontally) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
747 (if other |
14578 | 748 (progn |
749 (other-window 1) | |
750 (set-window-start (selected-window) start) | |
751 (setq follow-internal-force-redisplay t))) | |
752 (follow-mode 1))) | |
753 | |
754 (defun follow-switch-to-buffer (buffer) | |
755 "Show BUFFER in all windows in the current Follow Mode window chain." | |
756 (interactive "BSwitch to Buffer: ") | |
757 (let ((orig-window (selected-window)) | |
758 (windows (follow-all-followers))) | |
759 (while windows | |
760 (select-window (car windows)) | |
761 (switch-to-buffer buffer) | |
762 (setq windows (cdr windows))) | |
763 (select-window orig-window))) | |
764 | |
765 | |
766 (defun follow-switch-to-buffer-all (&optional buffer) | |
767 "Show BUFFER in all windows on this frame. | |
768 Defaults to current buffer." | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
769 (interactive (list (read-buffer "Switch to Buffer: " |
14578 | 770 (current-buffer)))) |
771 (or buffer (setq buffer (current-buffer))) | |
772 (let ((orig-window (selected-window))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
773 (walk-windows |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
774 (function |
14578 | 775 (lambda (win) |
776 (select-window win) | |
777 (switch-to-buffer buffer)))) | |
778 (select-window orig-window) | |
779 (follow-redisplay))) | |
780 | |
781 | |
782 (defun follow-switch-to-current-buffer-all () | |
783 "Show current buffer in all windows on this frame, and enter Follow Mode. | |
784 | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
785 To bind this command to a hotkey place the following line |
14578 | 786 in your `~/.emacs' file: |
787 (global-set-key [f7] 'follow-switch-to-current-buffer-all)" | |
788 (interactive) | |
789 (or (and (boundp 'follow-mode) follow-mode) | |
790 (follow-mode 1)) | |
791 (follow-switch-to-buffer-all)) | |
792 | |
793 ;;}}} | |
794 ;;{{{ Movement | |
795 | |
796 ;; Note, these functions are not very useful, atleast not unless you | |
797 ;; rebind the rather cumbersome key sequence `C-c . p'. | |
798 | |
799 (defun follow-next-window () | |
800 "Select the next window showing the same buffer." | |
801 (interactive) | |
802 (let ((succ (cdr (follow-split-followers (follow-all-followers))))) | |
803 (if succ | |
804 (select-window (car succ)) | |
805 (error "%s" "No more windows")))) | |
806 | |
807 | |
808 (defun follow-previous-window () | |
809 "Select the previous window showing the same buffer." | |
810 (interactive) | |
811 (let ((pred (car (follow-split-followers (follow-all-followers))))) | |
812 (if pred | |
813 (select-window (car pred)) | |
814 (error "%s" "No more windows")))) | |
815 | |
816 | |
817 (defun follow-first-window () | |
818 "Select the first window in the frame showing the same buffer." | |
819 (interactive) | |
820 (select-window (car (follow-all-followers)))) | |
821 | |
822 | |
823 (defun follow-last-window () | |
824 "Select the last window in the frame showing the same buffer." | |
825 (interactive) | |
826 (select-window (car (reverse (follow-all-followers))))) | |
827 | |
828 ;;}}} | |
829 ;;{{{ Redraw | |
830 | |
831 (defun follow-recenter (&optional arg) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
832 "Recenter the middle window around point. |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
833 Rearrange all other windows around the middle window. |
14578 | 834 |
835 With a positive argument, place the current line ARG lines | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
836 from the top. With a negative argument, place it -ARG lines |
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
837 from the bottom." |
14578 | 838 (interactive "P") |
839 (if arg | |
840 (let ((p (point)) | |
841 (arg (prefix-numeric-value arg))) | |
842 (if (>= arg 0) | |
843 ;; Recenter relative to the top. | |
844 (progn | |
845 (follow-first-window) | |
846 (goto-char p) | |
847 (recenter arg)) | |
848 ;; Recenter relative to the bottom. | |
849 (follow-last-window) | |
850 (goto-char p) | |
851 (recenter arg) | |
852 ;; Otherwise, our post-command-hook will move the window | |
853 ;; right back. | |
854 (setq follow-internal-force-redisplay t))) | |
855 ;; Recenter in the middle. | |
856 (let* ((dest (point)) | |
857 (windows (follow-all-followers)) | |
858 (win (nth (/ (- (length windows) 1) 2) windows))) | |
859 (select-window win) | |
860 (goto-char dest) | |
861 (recenter) | |
862 ;;(setq follow-internal-force-redisplay t) | |
863 ))) | |
864 | |
865 | |
866 (defun follow-redraw () | |
867 "Arrange windows displaying the same buffer in successor order. | |
868 This function can be called even if the buffer is not in Follow mode. | |
869 | |
870 Hopefully, there should be no reason to call this function when in | |
871 Follow mode since the windows should always be aligned." | |
872 (interactive) | |
873 (sit-for 0) | |
874 (follow-redisplay)) | |
875 | |
876 ;;}}} | |
877 ;;{{{ End of buffer | |
878 | |
879 (defun follow-end-of-buffer (&optional arg) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
880 "Move point to the end of the buffer, Follow Mode style. |
14578 | 881 |
882 If the end is not visible, it will be displayed in the last possible | |
883 window in the Follow Mode window chain. | |
884 | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
885 The mark is left at the previous position. With arg N, put point N/10 |
14578 | 886 of the way from the true end." |
887 (interactive "P") | |
888 (let ((followers (follow-all-followers)) | |
889 (pos (point))) | |
890 (cond (arg | |
891 (select-window (car (reverse followers)))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
892 ((follow-select-if-end-visible |
14578 | 893 (follow-windows-start-end followers))) |
894 (t | |
895 (select-window (car (reverse followers))))) | |
896 (goto-char pos) | |
61772
bd5a90076cd2
(follow-end-of-buffer): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
60902
diff
changeset
|
897 (with-no-warnings |
bd5a90076cd2
(follow-end-of-buffer): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
60902
diff
changeset
|
898 (end-of-buffer arg)))) |
14578 | 899 |
900 ;;}}} | |
901 | |
902 ;;}}} | |
903 | |
904 ;;{{{ Display | |
905 | |
906 ;;;; The display routines | |
907 | |
908 ;;{{{ Information gathering functions | |
909 | |
910 (defun follow-all-followers (&optional testwin) | |
911 "Return all windows displaying the same buffer as the TESTWIN. | |
912 The list contains only windows displayed in the same frame as TESTWIN. | |
913 If TESTWIN is nil the selected window is used." | |
914 (or (and testwin (window-live-p testwin)) | |
915 (setq testwin (selected-window))) | |
916 (let* ((top (frame-first-window (window-frame testwin))) | |
917 (win top) | |
918 (done nil) | |
919 (windows '()) | |
920 (buffer (window-buffer testwin))) | |
921 (while (and (not done) win) | |
922 (if (eq (window-buffer win) buffer) | |
923 (setq windows (cons win windows))) | |
924 (setq win (next-window win 'not)) | |
925 (if (eq win top) | |
926 (setq done t))) | |
927 (nreverse windows))) | |
928 | |
929 | |
930 (defun follow-split-followers (windows &optional win) | |
931 "Split the WINDOWS into the sets: predecessors and successors. | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
932 Return `(PRED . SUCC)' where `PRED' and `SUCC' are ordered starting |
14578 | 933 from the selected window." |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
934 (or win |
14578 | 935 (setq win (selected-window))) |
936 (let ((pred '())) | |
937 (while (not (eq (car windows) win)) | |
938 (setq pred (cons (car windows) pred)) | |
939 (setq windows (cdr windows))) | |
940 (cons pred (cdr windows)))) | |
941 | |
942 | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
943 ;; This function is optimized function for speed! |
14578 | 944 |
945 (defun follow-calc-win-end (&optional win) | |
946 "Calculate the presumed window end for WIN. | |
947 | |
948 Actually, the position returned is the start of the next | |
949 window, normally is the end plus one. | |
950 | |
951 If WIN is nil, the selected window is used. | |
952 | |
953 Returns (end-pos end-of-buffer-p)" | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
954 (if (featurep 'xemacs) |
14578 | 955 ;; XEmacs can calculate the end of the window by using |
956 ;; the 'guarantee options. GOOD! | |
957 (let ((end (window-end win t))) | |
958 (if (= end (funcall (symbol-function 'point-max) | |
959 (window-buffer win))) | |
960 (list end t) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
961 (list (+ end 1) nil))) |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
962 ;; Emacs: We have to calculate the end by ourselves. |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
963 ;; This code works on both XEmacs and Emacs, but now |
14578 | 964 ;; that XEmacs has got custom-written code, this could |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
965 ;; be optimized for Emacs. |
14578 | 966 (let ((orig-win (and win (selected-window))) |
967 height | |
968 buffer-end-p) | |
969 (if win (select-window win)) | |
970 (prog1 | |
971 (save-excursion | |
972 (goto-char (window-start)) | |
973 (setq height (- (window-height) 1)) | |
974 (setq buffer-end-p | |
975 (if (bolp) | |
976 (not (= height (vertical-motion height))) | |
977 (save-restriction | |
978 ;; Fix a mis-feature in `vertical-motion': | |
979 ;; The start of the window is assumed to | |
980 ;; coinside with the start of a line. | |
981 (narrow-to-region (point) (point-max)) | |
982 (not (= height (vertical-motion height)))))) | |
983 (list (point) buffer-end-p)) | |
984 (if orig-win | |
985 (select-window orig-win)))))) | |
986 | |
987 | |
988 ;; Can't use `save-window-excursion' since it triggers a redraw. | |
989 (defun follow-calc-win-start (windows pos win) | |
990 "Calculate where WIN will start if the first in WINDOWS start at POS. | |
991 | |
992 If WIN is nil the point below all windows is returned." | |
993 (let (start) | |
994 (while (and windows (not (eq (car windows) win))) | |
995 (setq start (window-start (car windows))) | |
996 (set-window-start (car windows) pos 'noforce) | |
997 (setq pos (car (inline (follow-calc-win-end (car windows))))) | |
998 (set-window-start (car windows) start 'noforce) | |
999 (setq windows (cdr windows))) | |
1000 pos)) | |
1001 | |
1002 | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1003 ;; The result from `follow-windows-start-end' is cached when using |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1004 ;; a handful simple commands, like cursor movement commands. |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1005 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1006 (defsubst follow-cache-valid-p (windows) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1007 "Test if the cached value of `follow-windows-start-end' can be used. |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1008 Note that this handles the case when the cache has been set to nil." |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1009 (let ((res t) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1010 (cache follow-windows-start-end-cache)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1011 (while (and res windows cache) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1012 (setq res (and (eq (car windows) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1013 (car (car cache))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1014 (eq (window-start (car windows)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1015 (car (cdr (car cache)))))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1016 (setq windows (cdr windows)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1017 (setq cache (cdr cache))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1018 (and res (null windows) (null cache)))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1019 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1020 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1021 (defsubst follow-invalidate-cache () |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1022 "Force `follow-windows-start-end' to recalculate the end of the window." |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1023 (setq follow-windows-start-end-cache nil)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1024 |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1025 |
14578 | 1026 ;; Build a list of windows and their start and end positions. |
1027 ;; Useful to avoid calculating start/end position whenever they are needed. | |
1028 ;; The list has the format: | |
1029 ;; ((Win Start End End-of-buffer-visible-p) ...) | |
1030 | |
1031 ;; Used to have a `save-window-excursion', but it obviously triggered | |
1032 ;; redraws of the display. Check if I used it for anything. | |
1033 | |
1034 | |
1035 (defun follow-windows-start-end (windows) | |
1036 "Builds a list of (WIN START END BUFFER-END-P) for every window in WINDOWS." | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1037 (if (follow-cache-valid-p windows) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1038 follow-windows-start-end-cache |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1039 (let ((win-start-end '()) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1040 (orig-win (selected-window))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1041 (while windows |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1042 (select-window (car windows)) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1043 (setq win-start-end |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1044 (cons (cons (car windows) |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1045 (cons (window-start) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1046 (follow-calc-win-end))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1047 win-start-end)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1048 (setq windows (cdr windows))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1049 (select-window orig-win) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1050 (setq follow-windows-start-end-cache (nreverse win-start-end)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1051 follow-windows-start-end-cache))) |
14578 | 1052 |
1053 | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1054 (defsubst follow-pos-visible (pos win win-start-end) |
14578 | 1055 "Non-nil when POS is visible in WIN." |
1056 (let ((wstart-wend-bend (cdr (assq win win-start-end)))) | |
1057 (and (>= pos (car wstart-wend-bend)) | |
1058 (or (< pos (car (cdr wstart-wend-bend))) | |
1059 (nth 2 wstart-wend-bend))))) | |
1060 | |
1061 | |
1062 ;; By `aligned' we mean that for all adjecent windows, the end of the | |
1063 ;; first is equal with the start of the successor. The first window | |
1064 ;; should start at a full screen line. | |
1065 | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1066 (defsubst follow-windows-aligned-p (win-start-end) |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1067 "Non-nil if the follower windows are aligned." |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1068 (let ((res t)) |
14578 | 1069 (save-excursion |
1070 (goto-char (window-start (car (car win-start-end)))) | |
1071 (if (bolp) | |
1072 nil | |
1073 (vertical-motion 0 (car (car win-start-end))) | |
1074 (setq res (eq (point) (window-start (car (car win-start-end))))))) | |
1075 (while (and res (cdr win-start-end)) | |
1076 ;; At least two followers left | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1077 (setq res (eq (car (cdr (cdr (car win-start-end)))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1078 (car (cdr (car (cdr win-start-end)))))) |
14578 | 1079 (setq win-start-end (cdr win-start-end))) |
1080 res)) | |
1081 | |
1082 | |
1083 ;; Check if the point is visible in all windows. (So that | |
1084 ;; no one will be recentered.) | |
1085 | |
1086 (defun follow-point-visible-all-windows-p (win-start-end) | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1087 "Non-nil when the `window-point' is visible in all windows." |
14578 | 1088 (let ((res t)) |
1089 (while (and res win-start-end) | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1090 (setq res (follow-pos-visible (window-point (car (car win-start-end))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1091 (car (car win-start-end)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1092 win-start-end)) |
14578 | 1093 (setq win-start-end (cdr win-start-end))) |
1094 res)) | |
1095 | |
1096 | |
1097 ;; Make sure WIN always starts at the beginning of an whole screen | |
1098 ;; line. If WIN is not aligned the start is updated which probably | |
1099 ;; will lead to a redisplay of the screen later on. | |
1100 ;; | |
1101 ;; This is used with the first window in a follow chain. The reason | |
1102 ;; is that we want to detect that the point is outside the window. | |
1103 ;; (Without the update, the start of the window will move as the | |
1104 ;; user presses BackSpace, and the other window redisplay routines | |
1105 ;; will move the start of the window in the wrong direction.) | |
1106 | |
1107 (defun follow-update-window-start (win) | |
1108 "Make sure that the start of WIN starts at a full screen line." | |
1109 (save-excursion | |
1110 (goto-char (window-start win)) | |
1111 (if (bolp) | |
1112 nil | |
1113 (vertical-motion 0 win) | |
1114 (if (eq (point) (window-start win)) | |
1115 nil | |
1116 (vertical-motion 1 win) | |
1117 (set-window-start win (point) 'noforce))))) | |
1118 | |
1119 ;;}}} | |
1120 ;;{{{ Selection functions | |
1121 | |
1122 ;; Make a window in WINDOWS selected if it currently | |
1123 ;; is displaying the position DEST. | |
1124 ;; | |
1125 ;; We don't select a window if it just has been moved. | |
1126 | |
1127 (defun follow-select-if-visible (dest win-start-end) | |
1128 "Select and return a window, if DEST is visible in it. | |
1129 Return the selected window." | |
1130 (let ((win nil)) | |
1131 (while (and (not win) win-start-end) | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1132 ;; Don't select a window that was just moved. This makes it |
14578 | 1133 ;; possible to later select the last window after a `end-of-buffer' |
1134 ;; command. | |
1135 (if (follow-pos-visible dest (car (car win-start-end)) win-start-end) | |
1136 (progn | |
1137 (setq win (car (car win-start-end))) | |
1138 (select-window win))) | |
1139 (setq win-start-end (cdr win-start-end))) | |
1140 win)) | |
1141 | |
1142 | |
1143 ;; Lets select a window showing the end. Make sure we only select it if it | |
1144 ;; it wasn't just moved here. (i.e. M-> shall not unconditionally place | |
1145 ;; the point in the selected window.) | |
1146 ;; | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1147 ;; (Compability cludge: in Emacs `window-end' is equal to `point-max'; |
14578 | 1148 ;; in XEmacs, it is equal to `point-max + 1'. Should I really bother |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1149 ;; checking `window-end' now when I check `end-of-buffer' explicitly?) |
14578 | 1150 |
1151 (defun follow-select-if-end-visible (win-start-end) | |
1152 "Select and return a window, if end is visible in it." | |
1153 (let ((win nil)) | |
1154 (while (and (not win) win-start-end) | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1155 ;; Don't select a window that was just moved. This makes it |
14578 | 1156 ;; possible to later select the last window after a `end-of-buffer' |
1157 ;; command. | |
1158 (if (and (eq (point-max) (nth 2 (car win-start-end))) | |
1159 (nth 3 (car win-start-end)) | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1160 ;; `window-end' might return nil. |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1161 (let ((end (window-end (car (car win-start-end))))) |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1162 (and end |
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1163 (eq (point-max) (min (point-max) end))))) |
14578 | 1164 (progn |
1165 (setq win (car (car win-start-end))) | |
1166 (select-window win))) | |
1167 (setq win-start-end (cdr win-start-end))) | |
1168 win)) | |
1169 | |
1170 | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1171 ;; Select a window that will display the point if the windows would |
14578 | 1172 ;; be redisplayed with the first window fixed. This is useful for |
1173 ;; example when the user has pressed return at the bottom of a window | |
1174 ;; as the point is not visible in any window. | |
1175 | |
1176 (defun follow-select-if-visible-from-first (dest windows) | |
1177 "Select and return a window with DEST, if WINDOWS are redrawn from top." | |
1178 (let ((win nil) | |
1179 end-pos-end-p) | |
1180 (save-excursion | |
1181 (goto-char (window-start (car windows))) | |
1182 ;; Make sure the line start in the beginning of a real screen | |
1183 ;; line. | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1184 (vertical-motion 0 (car windows)) |
14578 | 1185 (if (< dest (point)) |
1186 ;; Above the start, not visible. | |
1187 nil | |
1188 ;; At or below the start. Check the windows. | |
1189 (save-window-excursion | |
1190 (while (and (not win) windows) | |
1191 (set-window-start (car windows) (point) 'noforce) | |
1192 (setq end-pos-end-p (follow-calc-win-end (car windows))) | |
1193 (goto-char (car end-pos-end-p)) | |
1194 ;; Visible, if dest above end, or if eob is visible inside | |
1195 ;; the window. | |
1196 (if (or (car (cdr end-pos-end-p)) | |
1197 (< dest (point))) | |
1198 (setq win (car windows)) | |
1199 (setq windows (cdr windows))))))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1200 (if win |
14578 | 1201 (select-window win)) |
1202 win)) | |
1203 | |
1204 | |
1205 ;;}}} | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1206 ;;{{{ Redisplay |
14578 | 1207 |
1208 ;; Redraw all the windows on the screen, starting with the top window. | |
1209 ;; The window used as as marker is WIN, or the selcted window if WIN | |
1210 ;; is nil. | |
1211 | |
1212 (defun follow-redisplay (&optional windows win) | |
1213 "Reposition the WINDOWS around WIN. | |
1214 Should the point be too close to the roof we redisplay everything | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1215 from the top. WINDOWS should contain a list of windows to |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1216 redisplay, it is assumed that WIN is a member of the list. |
14578 | 1217 Should WINDOWS be nil, the windows displaying the |
1218 same buffer as WIN, in the current frame, are used. | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1219 Should WIN be nil, the selected window is used." |
14578 | 1220 (or win |
1221 (setq win (selected-window))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1222 (or windows |
14578 | 1223 (setq windows (follow-all-followers win))) |
1224 (follow-downward windows (follow-calculate-first-window-start windows win))) | |
1225 | |
1226 | |
1227 ;; Redisplay a chain of windows. Start every window directly after the | |
1228 ;; end of the previous window, to make sure long lines are displayed | |
1229 ;; correctly. | |
1230 | |
1231 (defun follow-downward (windows pos) | |
1232 "Redisplay all WINDOWS starting at POS." | |
1233 (while windows | |
1234 (set-window-start (car windows) pos) | |
1235 (setq pos (car (follow-calc-win-end (car windows)))) | |
1236 (setq windows (cdr windows)))) | |
1237 | |
1238 | |
1239 ;;(defun follow-downward (windows pos) | |
1240 ;; "Redisplay all WINDOWS starting at POS." | |
1241 ;; (let (p) | |
1242 ;; (while windows | |
1243 ;; (setq p (window-point (car windows))) | |
1244 ;; (set-window-start (car windows) pos) | |
1245 ;; (set-window-point (car windows) (max p pos)) | |
1246 ;; (setq pos (car (follow-calc-win-end (car windows)))) | |
1247 ;; (setq windows (cdr windows))))) | |
1248 | |
1249 | |
1250 ;; Return the start of the first window. | |
1251 ;; | |
1252 ;; First, estimate the position. It the value is not perfect (i.e. we | |
1253 ;; have somewhere splited a line between windows) we try to enhance | |
1254 ;; the value. | |
1255 ;; | |
1256 ;; The guess is always perfect if no long lines is split between | |
1257 ;; windows. | |
1258 ;; | |
1259 ;; The worst case peformace of probably very bad, but it is very | |
1260 ;; unlikely that we ever will miss the correct start by more than one | |
1261 ;; or two lines. | |
1262 | |
1263 (defun follow-calculate-first-window-start (windows &optional win start) | |
1264 "Calculate the start of the first window. | |
1265 | |
1266 WINDOWS is a chain of windows to work with. WIN is the window | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1267 to recenter around. It is assumed that WIN starts at position |
14578 | 1268 START." |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1269 (or win |
14578 | 1270 (setq win (selected-window))) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1271 (or start |
14578 | 1272 (setq start (window-start win))) |
1273 (let ((guess (follow-estimate-first-window-start windows win start))) | |
1274 (if (car guess) | |
1275 (cdr guess) | |
1276 ;; The guess wasn't exact, try to enhance it. | |
1277 (let ((win-start (follow-calc-win-start windows (cdr guess) win))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1278 (cond ((= win-start start) |
14578 | 1279 (follow-debug-message "exact") |
1280 (cdr guess)) | |
1281 ((< win-start start) | |
1282 (follow-debug-message "above") | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1283 (follow-calculate-first-window-start-from-above |
14578 | 1284 windows (cdr guess) win start)) |
1285 (t | |
1286 (follow-debug-message "below") | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1287 (follow-calculate-first-window-start-from-below |
14578 | 1288 windows (cdr guess) win start))))))) |
1289 | |
1290 | |
1291 ;; `exact' is disabled due to XEmacs and fonts of variable | |
1292 ;; height. | |
1293 (defun follow-estimate-first-window-start (windows win start) | |
1294 "Estimate the position of the first window. | |
1295 | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1296 Returns (EXACT . POS). If EXACT is non-nil, POS is the starting |
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1297 position of the first window. Otherwise it is a good guess." |
14578 | 1298 (let ((pred (car (follow-split-followers windows win))) |
1299 (exact nil)) | |
1300 (save-excursion | |
1301 (goto-char start) | |
1302 ;(setq exact (bolp)) | |
1303 (vertical-motion 0 win) | |
1304 (while pred | |
1305 (vertical-motion (- 1 (window-height (car pred))) (car pred)) | |
1306 (if (not (bolp)) | |
1307 (setq exact nil)) | |
1308 (setq pred (cdr pred))) | |
1309 (cons exact (point))))) | |
1310 | |
1311 | |
1312 ;; Find the starting point, start at GUESS and search downward. | |
1313 ;; The returned point is always a point below GUESS. | |
1314 | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1315 (defun follow-calculate-first-window-start-from-above |
14578 | 1316 (windows guess win start) |
1317 (save-excursion | |
1318 (let ((done nil) | |
1319 win-start | |
1320 res) | |
1321 (goto-char guess) | |
1322 (while (not done) | |
1323 (if (not (= (vertical-motion 1 (car windows)) 1)) | |
1324 ;; Hit bottom! (Can we really do this?) | |
1325 ;; We'll keep it, since it ensures termination. | |
1326 (progn | |
1327 (setq done t) | |
1328 (setq res (point-max))) | |
1329 (setq win-start (follow-calc-win-start windows (point) win)) | |
1330 (if (>= win-start start) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1331 (progn |
14578 | 1332 (setq done t) |
1333 (setq res (point)))))) | |
1334 res))) | |
1335 | |
1336 | |
1337 ;; Find the starting point, start at GUESS and search upward. Return | |
1338 ;; a point on the same line as GUESS, or above. | |
1339 ;; | |
1340 ;; (Is this ever used? I must make sure it works just in case it is | |
1341 ;; ever called.) | |
1342 | |
1343 (defun follow-calculate-first-window-start-from-below | |
1344 (windows guess &optional win start) | |
1345 (setq win (or win (selected-window))) | |
1346 (setq start (or start (window-start win))) | |
1347 (save-excursion | |
1348 (let ((done nil) | |
1349 win-start | |
1350 res) | |
1351 ;; Always calculate what happend when no line is displayed in the first | |
1352 ;; window. (The `previous' res is needed below!) | |
1353 (goto-char guess) | |
1354 (vertical-motion 0 (car windows)) | |
1355 (setq res (point)) | |
1356 (while (not done) | |
1357 (if (not (= (vertical-motion -1 (car windows)) -1)) | |
1358 ;; Hit roof! | |
1359 (progn | |
1360 (setq done t) | |
1361 (setq res (point-min))) | |
1362 (setq win-start (follow-calc-win-start windows (point) win)) | |
1363 (cond ((= win-start start) ; Perfect match, use this value | |
1364 (setq done t) | |
1365 (setq res (point))) | |
1366 ((< win-start start) ; Walked to far, use preious result | |
1367 (setq done t)) | |
1368 (t ; Store result for next iteration | |
1369 (setq res (point)))))) | |
1370 res))) | |
1371 | |
1372 ;;}}} | |
1373 ;;{{{ Avoid tail recenter | |
1374 | |
1375 ;; This sets the window internal flag `force_start'. The effect is that | |
1376 ;; windows only displaying the tail isn't recentered. | |
1377 ;; Has to be called before every redisplay... (Great isn't it?) | |
1378 ;; | |
1379 ;; XEmacs doesn't recenter the tail, GOOD! | |
1380 ;; | |
1381 ;; A window displaying only the tail, is a windows whose | |
1382 ;; window-start position is equal to (point-max) of the buffer it | |
1383 ;; displays. | |
1384 ;; | |
1385 ;; This function is also added to `post-command-idle-hook', introduced | |
1386 ;; in Emacs 19.30. This is needed since the vaccine injected by the | |
1387 ;; call from `post-command-hook' only works until the next redisplay. | |
1388 ;; It is possible that the functions in the `post-command-idle-hook' | |
1389 ;; can cause a redisplay, and hence a new vaccine is needed. | |
1390 ;; | |
1391 ;; Sometimes, calling this function could actually cause a redisplay, | |
1392 ;; especially if it is placed in the debug filter section. I must | |
1393 ;; investigate this further... | |
1394 | |
1395 (defun follow-avoid-tail-recenter (&rest rest) | |
1396 "Make sure windows displaying the end of a buffer aren't recentered. | |
1397 | |
36904
ad219664900c
(follow-avoid-tail-recenter): Doc fix.
Gerd Moellmann <gerd@gnu.org>
parents:
26523
diff
changeset
|
1398 This is done by reading and rewriting the start position of |
14578 | 1399 non-first windows in Follow Mode." |
1400 (if follow-avoid-tail-recenter-p | |
1401 (let* ((orig-buffer (current-buffer)) | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1402 (top (frame-first-window (selected-frame))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1403 (win top) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1404 (who '()) ; list of (buffer . frame) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1405 start |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1406 pair) ; (buffer . frame) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1407 ;; If the only window in the frame is a minibuffer |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1408 ;; window, `next-window' will never find it again... |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1409 (if (window-minibuffer-p top) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1410 nil |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1411 (while ;; look, no body! |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1412 (progn |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1413 (setq start (window-start win)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1414 (set-buffer (window-buffer win)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1415 (setq pair (cons (window-buffer win) (window-frame win))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1416 (if (member pair who) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1417 (if (and (boundp 'follow-mode) follow-mode |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1418 (eq (point-max) start)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1419 ;; Write the same window start back, but don't |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1420 ;; set the NOFORCE flag. |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1421 (set-window-start win start)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1422 (setq who (cons pair who))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1423 (setq win (next-window win 'not t)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1424 (not (eq win top)))) ;; Loop while this is true. |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1425 (set-buffer orig-buffer))))) |
14578 | 1426 |
1427 ;;}}} | |
1428 | |
1429 ;;}}} | |
1430 ;;{{{ Post Command Hook | |
1431 | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1432 ;; The magic little box. This function is called after every command. |
14578 | 1433 |
1434 ;; This is not as complicated as it seems. It is simply a list of common | |
1435 ;; display situations and the actions to take, plus commands for redrawing | |
1436 ;; the screen if it should be unaligned. | |
1437 ;; | |
1438 ;; We divide the check into two parts; whether we are at the end or not. | |
1439 ;; This is due to the fact that the end can actaually be visible | |
1440 ;; in several window even though they are aligned. | |
1441 | |
1442 (defun follow-post-command-hook () | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1443 "Ensure that the windows in Follow mode are adjacent after each command." |
14578 | 1444 (setq follow-inside-post-command-hook t) |
1445 (if (or (not (input-pending-p)) | |
1446 ;; Sometimes, in XEmacs, mouse events are not handled | |
1447 ;; properly by `input-pending-p'. A typical example is | |
1448 ;; when clicking on a node in `info'. | |
1449 (and (boundp 'current-mouse-event) | |
1450 (symbol-value 'current-mouse-event) | |
1451 (fboundp 'button-event-p) | |
1452 (funcall (symbol-function 'button-event-p) | |
1453 (symbol-value 'current-mouse-event)))) | |
1454 ;; Work in the selected window, not in the current buffer. | |
1455 (let ((orig-buffer (current-buffer)) | |
1456 (win (selected-window))) | |
1457 (set-buffer (window-buffer win)) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1458 (or (and (symbolp this-command) |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1459 (get this-command 'follow-mode-use-cache)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1460 (follow-invalidate-cache)) |
14578 | 1461 (if (and (boundp 'follow-mode) follow-mode |
1462 (not (window-minibuffer-p win))) | |
1463 ;; The buffer shown in the selected window is in follow | |
1464 ;; mode, lets find the current state of the display and | |
1465 ;; cache the result for speed (i.e. `aligned' and `visible'.) | |
1466 (let* ((windows (inline (follow-all-followers win))) | |
1467 (dest (point)) | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1468 (win-start-end (inline |
14578 | 1469 (follow-update-window-start (car windows)) |
1470 (follow-windows-start-end windows))) | |
1471 (aligned (follow-windows-aligned-p win-start-end)) | |
1472 (visible (follow-pos-visible dest win win-start-end))) | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1473 (if (not (and aligned visible)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1474 (follow-invalidate-cache)) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1475 (inline (follow-avoid-tail-recenter)) |
14578 | 1476 ;; Select a window to display the point. |
1477 (or follow-internal-force-redisplay | |
1478 (progn | |
1479 (if (eq dest (point-max)) | |
55257
c4d464135bfc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
1480 ;; We're at the end, we have to be careful since |
14578 | 1481 ;; the display can be aligned while `dest' can |
1482 ;; be visible in several windows. | |
1483 (cond | |
1484 ;; Select the current window, but only when | |
1485 ;; the display is correct. (When inserting | |
1486 ;; character in a tail window, the display is | |
1487 ;; not correct, as they are shown twice.) | |
1488 ;; | |
1489 ;; Never stick to the current window after a | |
1490 ;; deletion. The reason is cosmetic, when | |
1491 ;; typing `DEL' in a window showing only the | |
1492 ;; end of the file, character are removed | |
1493 ;; from the window above, which is very | |
1494 ;; unintuitive. | |
1495 ((and visible | |
1496 aligned | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1497 (not (memq this-command |
14578 | 1498 '(backward-delete-char |
1499 delete-backward-char | |
1500 backward-delete-char-untabify | |
1501 kill-region)))) | |
1502 (follow-debug-message "Max: same")) | |
1503 ;; If the end is visible, and the window | |
1504 ;; doesn't seems like it just has been moved, | |
1505 ;; select it. | |
1506 ((follow-select-if-end-visible win-start-end) | |
1507 (follow-debug-message "Max: end visible") | |
1508 (setq visible t) | |
1509 (setq aligned nil) | |
1510 (goto-char dest)) | |
1511 ;; Just show the end... | |
1512 (t | |
1513 (follow-debug-message "Max: default") | |
1514 (select-window (car (reverse windows))) | |
1515 (goto-char dest) | |
1516 (setq visible nil) | |
1517 (setq aligned nil))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1518 |
14578 | 1519 ;; We're not at the end, here life is much simpler. |
1520 (cond | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1521 ;; This is the normal case! |
14578 | 1522 ;; It should be optimized for speed. |
1523 ((and visible aligned) | |
1524 (follow-debug-message "same")) | |
1525 ;; Pick a position in any window. If the | |
1526 ;; display is ok, this will pick the `correct' | |
1527 ;; window. If the display is wierd do this | |
1528 ;; anyway, this will be the case after a delete | |
1529 ;; at the beginning of the window. | |
1530 ((follow-select-if-visible dest win-start-end) | |
1531 (follow-debug-message "visible") | |
1532 (setq visible t) | |
1533 (goto-char dest)) | |
1534 ;; Not visible anywhere else, lets pick this one. | |
1535 ;; (Is this case used?) | |
1536 (visible | |
1537 (follow-debug-message "visible in selected.")) | |
1538 ;; Far out! | |
1539 ((eq dest (point-min)) | |
1540 (follow-debug-message "min") | |
1541 (select-window (car windows)) | |
1542 (goto-char dest) | |
1543 (set-window-start (selected-window) (point-min)) | |
1544 (setq win-start-end (follow-windows-start-end windows)) | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1545 (follow-invalidate-cache) |
14578 | 1546 (setq visible t) |
1547 (setq aligned nil)) | |
1548 ;; If we can position the cursor without moving the first | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1549 ;; window, do it. This is the case that catches `RET' |
14578 | 1550 ;; at the bottom of a window. |
1551 ((follow-select-if-visible-from-first dest windows) | |
1552 (follow-debug-message "Below first") | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1553 (setq visible t) |
14578 | 1554 (setq aligned t) |
1555 (follow-redisplay windows (car windows)) | |
1556 (goto-char dest)) | |
1557 ;; None of the above. For simplicity, we stick to the | |
1558 ;; selected window. | |
1559 (t | |
1560 (follow-debug-message "None") | |
1561 (setq visible nil) | |
1562 (setq aligned nil)))) | |
1563 ;; If a new window has been selected, make sure that the | |
1564 ;; old is not scrolled when the point is outside the | |
1565 ;; window. | |
1566 (or (eq win (selected-window)) | |
1567 (let ((p (window-point win))) | |
1568 (set-window-start win (window-start win) nil) | |
1569 (set-window-point win p))))) | |
1570 ;; Make sure the point is visible in the selected window. | |
1571 ;; (This could lead to a scroll.) | |
1572 (if (or visible | |
1573 (follow-pos-visible dest win win-start-end)) | |
1574 nil | |
1575 (sit-for 0) | |
1576 (follow-avoid-tail-recenter) | |
1577 (setq win-start-end (follow-windows-start-end windows)) | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1578 (follow-invalidate-cache) |
14578 | 1579 (setq aligned nil)) |
1580 ;; Redraw the windows whenever needed. | |
1581 (if (or follow-internal-force-redisplay | |
1582 (not (or aligned | |
1583 (follow-windows-aligned-p win-start-end))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1584 (not (inline (follow-point-visible-all-windows-p |
14578 | 1585 win-start-end)))) |
1586 (progn | |
1587 (setq follow-internal-force-redisplay nil) | |
1588 (follow-redisplay windows (selected-window)) | |
1589 (setq win-start-end (follow-windows-start-end windows)) | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1590 (follow-invalidate-cache) |
14578 | 1591 ;; When the point ends up in another window. This |
1592 ;; happends when dest is in the beginning of the | |
1593 ;; file and the selected window is not the first. | |
1594 ;; It can also, in rare situations happend when | |
1595 ;; long lines are used and there is a big | |
1596 ;; difference between the width of the windows. | |
1597 ;; (When scrolling one line in a wide window which | |
1598 ;; will cause a move larger that an entire small | |
1599 ;; window.) | |
1600 (if (follow-pos-visible dest win win-start-end) | |
1601 nil | |
1602 (follow-select-if-visible dest win-start-end) | |
1603 (goto-char dest)))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1604 |
14578 | 1605 ;; If the region is visible, make it look good when spanning |
1606 ;; multiple windows. | |
1607 (if (or (and (boundp 'mark-active) (symbol-value 'mark-active)) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1608 (and (fboundp 'region-active-p) |
14578 | 1609 (funcall (symbol-function 'region-active-p)))) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1610 (follow-maximize-region |
14578 | 1611 (selected-window) windows win-start-end)) |
1612 | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
1613 (inline (follow-avoid-tail-recenter)) |
14578 | 1614 ;; DEBUG |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1615 ;;(if (not (follow-windows-aligned-p |
14578 | 1616 ;; (follow-windows-start-end windows))) |
1617 ;; (message "follow-mode: windows still unaligend!")) | |
1618 ;; END OF DEBUG | |
1619 ) ; Matches (let* | |
1620 ;; Buffer not in follow mode: | |
1621 ;; We still must update the windows displaying the tail so that | |
1622 ;; Emacs won't recenter them. | |
1623 (follow-avoid-tail-recenter)) | |
1624 (set-buffer orig-buffer))) | |
1625 (setq follow-inside-post-command-hook nil)) | |
1626 | |
1627 ;;}}} | |
1628 ;;{{{ The region | |
1629 | |
1630 ;; Tries to make the highlighted area representing the region look | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1631 ;; good when spanning several windows. |
14578 | 1632 ;; |
1633 ;; Not perfect, as the point can't be placed at window end, only at | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1634 ;; end-1. This will highlight a little bit in windows above |
14578 | 1635 ;; the current. |
1636 | |
1637 (defun follow-maximize-region (win windows win-start-end) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1638 "Make a highlighted region stretching multiple windows look good." |
14578 | 1639 (let* ((all (follow-split-followers windows win)) |
1640 (pred (car all)) | |
1641 (succ (cdr all)) | |
1642 data) | |
1643 (while pred | |
1644 (setq data (assq (car pred) win-start-end)) | |
1645 (set-window-point (car pred) (max (nth 1 data) (- (nth 2 data) 1))) | |
1646 (setq pred (cdr pred))) | |
1647 (while succ | |
1648 (set-window-point (car succ) (nth 1 (assq (car succ) win-start-end))) | |
1649 (setq succ (cdr succ))))) | |
1650 | |
1651 ;;}}} | |
1652 ;;{{{ Scroll bar | |
1653 | |
1654 ;;;; Scroll-bar support code. | |
1655 | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1656 ;; Why is it needed? Well, if the selected window is in follow mode, |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1657 ;; all its follower stick to it blindly. If one of them is scrolled, |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1658 ;; it immediately returns to the original position when the mouse is |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1659 ;; released. If the selected window is not a follower of the dragged |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1660 ;; window the windows will be unaligned. |
14578 | 1661 |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1662 ;; The advices doesn't get compiled. Aestetically, this might be a |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1663 ;; problem but in practical life it isn't. |
14578 | 1664 |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1665 ;; Discussion: Now when the other windows in the chain follow the |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1666 ;; dragged, should we really select it? |
14578 | 1667 |
1668 (cond ((fboundp 'scroll-bar-drag) | |
1669 ;;; | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1670 ;;; Emacs style scrollbars. |
14578 | 1671 ;;; |
1672 | |
1673 ;; Select the dragged window if it is a follower of the | |
1674 ;; selected window. | |
1675 ;; | |
1676 ;; Generate advices of the form: | |
1677 ;; (defadvice scroll-bar-drag (after follow-scroll-bar-drag activate) | |
1678 ;; "Adviced by `follow-mode'." | |
1679 ;; (follow-redraw-after-event (ad-get-arg 0))) | |
1680 (let ((cmds '(scroll-bar-drag | |
1681 scroll-bar-drag-1 ; Executed at every move. | |
1682 scroll-bar-scroll-down | |
1683 scroll-bar-scroll-up | |
1684 scroll-bar-set-window-start))) | |
1685 (while cmds | |
1686 (eval | |
26523
c06aa85fd1ad
Use modern backquote syntax. Minor comment update.
Gerd Moellmann <gerd@gnu.org>
parents:
22250
diff
changeset
|
1687 `(defadvice ,(intern (symbol-name (car cmds))) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1688 (after |
26523
c06aa85fd1ad
Use modern backquote syntax. Minor comment update.
Gerd Moellmann <gerd@gnu.org>
parents:
22250
diff
changeset
|
1689 ,(intern (concat "follow-" (symbol-name (car cmds)))) |
14578 | 1690 activate) |
1691 "Adviced by Follow Mode." | |
26523
c06aa85fd1ad
Use modern backquote syntax. Minor comment update.
Gerd Moellmann <gerd@gnu.org>
parents:
22250
diff
changeset
|
1692 (follow-redraw-after-event (ad-get-arg 0)))) |
14578 | 1693 (setq cmds (cdr cmds)))) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1694 |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1695 |
14578 | 1696 (defun follow-redraw-after-event (event) |
1697 "Adviced by Follow mode." | |
1698 (condition-case nil | |
1699 (let* ((orig-win (selected-window)) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1700 (win (nth 0 (funcall |
14578 | 1701 (symbol-function 'event-start) event))) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1702 (fmode (assq 'follow-mode |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1703 (buffer-local-variables |
14578 | 1704 (window-buffer win))))) |
1705 (if (and fmode (cdr fmode)) | |
1706 ;; The selected window is in follow-mode | |
1707 (progn | |
1708 ;; Recenter around the dragged window. | |
1709 (select-window win) | |
1710 (follow-redisplay) | |
1711 (select-window orig-win)))) | |
1712 (error nil)))) | |
1713 | |
1714 | |
1715 ((fboundp 'scrollbar-vertical-drag) | |
1716 ;;; | |
1717 ;;; XEmacs style scrollbars. | |
1718 ;;; | |
1719 | |
1720 ;; Advice all scrollbar functions on the form: | |
1721 ;; | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1722 ;; (defadvice scrollbar-line-down |
14578 | 1723 ;; (after follow-scrollbar-line-down activate) |
1724 ;; (follow-xemacs-scrollbar-support (ad-get-arg 0))) | |
1725 | |
1726 (let ((cmds '(scrollbar-line-down ; Window | |
1727 scrollbar-line-up | |
1728 scrollbar-page-down ; Object | |
1729 scrollbar-page-up | |
1730 scrollbar-to-bottom ; Window | |
1731 scrollbar-to-top | |
1732 scrollbar-vertical-drag ; Object | |
1733 ))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1734 |
14578 | 1735 (while cmds |
1736 (eval | |
26523
c06aa85fd1ad
Use modern backquote syntax. Minor comment update.
Gerd Moellmann <gerd@gnu.org>
parents:
22250
diff
changeset
|
1737 `(defadvice ,(intern (symbol-name (car cmds))) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1738 (after |
26523
c06aa85fd1ad
Use modern backquote syntax. Minor comment update.
Gerd Moellmann <gerd@gnu.org>
parents:
22250
diff
changeset
|
1739 ,(intern (concat "follow-" (symbol-name (car cmds)))) |
14578 | 1740 activate) |
1741 "Adviced by `follow-mode'." | |
26523
c06aa85fd1ad
Use modern backquote syntax. Minor comment update.
Gerd Moellmann <gerd@gnu.org>
parents:
22250
diff
changeset
|
1742 (follow-xemacs-scrollbar-support (ad-get-arg 0)))) |
14578 | 1743 (setq cmds (cdr cmds)))) |
1744 | |
1745 | |
1746 (defun follow-xemacs-scrollbar-support (window) | |
1747 "Redraw windows showing the same buffer as shown in WINDOW. | |
1748 WINDOW is either the dragged window, or a cons containing the | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1749 window as its first element. This is called while the user drags |
14578 | 1750 the scrollbar. |
1751 | |
1752 WINDOW can be an object or a window." | |
1753 (condition-case nil | |
1754 (progn | |
1755 (if (consp window) | |
1756 (setq window (car window))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1757 (let ((fmode (assq 'follow-mode |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1758 (buffer-local-variables |
14578 | 1759 (window-buffer window)))) |
1760 (orig-win (selected-window))) | |
1761 (if (and fmode (cdr fmode)) | |
1762 (progn | |
1763 ;; Recenter around the dragged window. | |
1764 (select-window window) | |
1765 (follow-redisplay) | |
1766 (select-window orig-win))))) | |
1767 (error nil))))) | |
1768 | |
1769 ;;}}} | |
1770 ;;{{{ Process output | |
1771 | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1772 ;; The following sections installs a spy that listens to process |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1773 ;; output and tries to reposition the windows whose buffers are in |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1774 ;; Follow mode. We play safe as much as possible... |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1775 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1776 ;; When follow-mode is activated all active processes are |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1777 ;; intercepted. All new processes that change their filter function |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1778 ;; using `set-process-filter' are also intercepted. The reason is |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1779 ;; that a process can cause a redisplay recentering "tail" windows. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1780 ;; Note that it doesn't hurt to spy on more processes than needed. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1781 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1782 ;; Technically, we set the process filter to `follow-generic-filter'. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1783 ;; The original filter is stored in `follow-process-filter-alist'. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1784 ;; Our generic filter calls the original filter, or inserts the |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1785 ;; output into the buffer, if the buffer originally didn't have an |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1786 ;; output filter. It also makes sure that the windows connected to |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1787 ;; the buffer are aligned. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1788 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1789 ;; Discussion: How do we find processes that don't call |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1790 ;; `set-process-filter'? (How often are processes created in a |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1791 ;; buffer after Follow mode are activated?) |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1792 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1793 ;; Discussion: Should we also advice `process-filter' to make our |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1794 ;; filter invisible to others? |
14578 | 1795 |
1796 ;;{{{ Advice for `set-process-filter' | |
1797 | |
1798 ;; Do not call this with 'follow-generic-filter as the name of the | |
1799 ;; filter... | |
1800 | |
1801 (defadvice set-process-filter (before follow-set-process-filter activate) | |
18144
f8860990bdf7
(set-process-filter): Advice doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18133
diff
changeset
|
1802 "Ensure process output will be displayed correctly in Follow Mode buffers. |
14578 | 1803 |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1804 Follow Mode inserts its own process filter to do its |
14578 | 1805 magic stuff before the real process filter is called." |
1806 (if follow-intercept-processes | |
1807 (progn | |
1808 (setq follow-process-filter-alist | |
1809 (delq (assq (ad-get-arg 0) follow-process-filter-alist) | |
1810 follow-process-filter-alist)) | |
1811 (follow-tidy-process-filter-alist) | |
1812 (cond ((eq (ad-get-arg 1) t)) | |
1813 ((eq (ad-get-arg 1) nil) | |
1814 (ad-set-arg 1 'follow-generic-filter)) | |
1815 (t | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1816 (setq follow-process-filter-alist |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1817 (cons (cons (ad-get-arg 0) (ad-get-arg 1)) |
14578 | 1818 follow-process-filter-alist)) |
1819 (ad-set-arg 1 'follow-generic-filter)))))) | |
1820 | |
1821 | |
1822 (defun follow-call-set-process-filter (proc filter) | |
1823 "Call original `set-process-filter' without the Follow mode advice." | |
1824 (ad-disable-advice 'set-process-filter 'before | |
1825 'follow-set-process-filter) | |
1826 (ad-activate 'set-process-filter) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1827 (prog1 |
14578 | 1828 (set-process-filter proc filter) |
1829 (ad-enable-advice 'set-process-filter 'before | |
1830 'follow-set-process-filter) | |
1831 (ad-activate 'set-process-filter))) | |
1832 | |
1833 | |
1834 (defadvice process-filter (after follow-process-filter activate) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1835 "Return the original process filter, not `follow-generic-filter'." |
14578 | 1836 (cond ((eq ad-return-value 'follow-generic-filter) |
1837 (setq ad-return-value | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1838 (cdr-safe (assq (ad-get-arg 0) |
14578 | 1839 follow-process-filter-alist)))))) |
1840 | |
1841 | |
1842 (defun follow-call-process-filter (proc) | |
1843 "Call original `process-filter' without the Follow mode advice." | |
1844 (ad-disable-advice 'process-filter 'after | |
1845 'follow-process-filter) | |
1846 (ad-activate 'process-filter) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1847 (prog1 |
14578 | 1848 (process-filter proc) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1849 (ad-enable-advice 'process-filter 'after |
14578 | 1850 'follow-process-filter) |
1851 (ad-activate 'process-filter))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1852 |
14578 | 1853 |
1854 (defun follow-tidy-process-filter-alist () | |
1855 "Remove old processes from `follow-process-filter-alist'." | |
1856 (let ((alist follow-process-filter-alist) | |
1857 (ps (process-list)) | |
1858 (new ())) | |
1859 (while alist | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1860 (if (and (not (memq (process-status (car (car alist))) |
14578 | 1861 '(exit signal closed nil))) |
1862 (memq (car (car alist)) ps)) | |
1863 (setq new (cons (car alist) new))) | |
1864 (setq alist (cdr alist))) | |
1865 (setq follow-process-filter-alist new))) | |
1866 | |
1867 ;;}}} | |
1868 ;;{{{ Start/stop interception of processes. | |
1869 | |
1870 ;; Normally, all new processed are intercepted by our `set-process-filter'. | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
1871 ;; This is needed to intercept old processed that were started before we were |
14578 | 1872 ;; loaded, and processes we have forgotten by calling |
1873 ;; `follow-stop-intercept-process-output'. | |
1874 | |
1875 (defun follow-intercept-process-output () | |
1876 "Intercept all active processes. | |
1877 | |
1878 This is needed so that Follow Mode can track all display events in the | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1879 system. (See `follow-mode'.)" |
14578 | 1880 (interactive) |
1881 (let ((list (process-list))) | |
1882 (while list | |
1883 (if (eq (process-filter (car list)) 'follow-generic-filter) | |
1884 nil | |
1885 ;; The custom `set-process-filter' defined above. | |
1886 (set-process-filter (car list) (process-filter (car list)))) | |
1887 (setq list (cdr list)))) | |
1888 (setq follow-intercept-processes t)) | |
1889 | |
1890 | |
1891 (defun follow-stop-intercept-process-output () | |
1892 "Stop Follow Mode from spying on processes. | |
1893 | |
1894 All current spypoints are removed and no new will be added. | |
1895 | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1896 The effect is that Follow mode won't be able to handle buffers |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1897 connected to processes. |
14578 | 1898 |
1899 The only reason to call this function is if the Follow mode spy filter | |
1900 would interfere with some other package. If this happens, please | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1901 report this using the `report-emacs-bug' function." |
14578 | 1902 (interactive) |
1903 (follow-tidy-process-filter-alist) | |
1904 (let ((list (process-list))) | |
1905 (while list | |
1906 (if (eq (process-filter (car list)) 'follow-generic-filter) | |
1907 (progn | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1908 (follow-call-set-process-filter |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1909 (car list) |
14578 | 1910 (cdr-safe (assq (car list) follow-process-filter-alist))) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1911 (setq follow-process-filter-alist |
14578 | 1912 (delq (assq (car list) follow-process-filter-alist) |
1913 follow-process-filter-alist)))) | |
1914 (setq list (cdr list)))) | |
1915 (setq follow-intercept-processes nil)) | |
1916 | |
1917 ;;}}} | |
1918 ;;{{{ The filter | |
1919 | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1920 ;; The following section is a naive method to make buffers with |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1921 ;; process output to work with Follow mode. Whenever the start of the |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1922 ;; window displaying the buffer is moved, we moves it back to its |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1923 ;; original position and try to select a new window. (If we fail, |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1924 ;; the normal redisplay functions of Emacs will scroll it right |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
1925 ;; back!) |
14578 | 1926 |
1927 (defun follow-generic-filter (proc output) | |
1928 "Process output filter for process connected to buffers in Follow mode." | |
1929 (let* ((old-buffer (current-buffer)) | |
1930 (orig-win (selected-window)) | |
1931 (buf (process-buffer proc)) | |
1932 (win (and buf (if (eq buf (window-buffer orig-win)) | |
1933 orig-win | |
1934 (get-buffer-window buf t)))) | |
1935 (return-to-orig-win (and win (not (eq win orig-win)))) | |
1936 (orig-window-start (and win (window-start win)))) | |
1937 | |
1938 ;; If input is pending, the `sit-for' below won't redraw the | |
1939 ;; display. In that case, calling `follow-avoid-tail-recenter' may | |
1940 ;; provoke the process hadnling code to sceduling a redisplay. | |
1941 ;(or (input-pending-p) | |
1942 ; (follow-avoid-tail-recenter)) | |
1943 | |
1944 ;; Output the `output'. | |
1945 (let ((filter (cdr-safe (assq proc follow-process-filter-alist)))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1946 (cond |
14578 | 1947 ;; Call the original filter function |
1948 (filter | |
1949 (funcall filter proc output)) | |
1950 | |
1951 ;; No filter, but we've got a buffer. Just output into it. | |
1952 (buf | |
1953 (set-buffer buf) | |
1954 (if (not (marker-buffer (process-mark proc))) | |
1955 (set-marker (process-mark proc) (point-max))) | |
1956 (let ((moving (= (point) (process-mark proc))) | |
47628
e44b96f09893
(follow-generic-filter): Simply bind deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents:
42880
diff
changeset
|
1957 deactivate-mark |
e44b96f09893
(follow-generic-filter): Simply bind deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents:
42880
diff
changeset
|
1958 (inhibit-read-only t)) |
14578 | 1959 (save-excursion |
1960 (goto-char (process-mark proc)) | |
1961 ;; `insert-before-markers' just in case the users next | |
1962 ;; command is M-y. | |
1963 (insert-before-markers output) | |
1964 (set-marker (process-mark proc) (point))) | |
47628
e44b96f09893
(follow-generic-filter): Simply bind deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents:
42880
diff
changeset
|
1965 (if moving (goto-char (process-mark proc))))))) |
14578 | 1966 |
1967 ;; If we're in follow mode, do our stuff. Select a new window and | |
1968 ;; redisplay. (Actually, it is redundant to check `buf', but I | |
1969 ;; feel it's more correct.) | |
1970 (if (and buf win (window-live-p win)) | |
1971 (progn | |
1972 (set-buffer buf) | |
1973 (if (and (boundp 'follow-mode) follow-mode) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
1974 (progn |
14578 | 1975 (select-window win) |
1976 (let* ((windows (follow-all-followers win)) | |
1977 (win-start-end (follow-windows-start-end windows)) | |
1978 (new-window-start (window-start win)) | |
1979 (new-window-point (window-point win))) | |
1980 (cond | |
42880 | 1981 ;; The start of the selected window was repositioned. |
1982 ;; Try to use the original start position and continue | |
1983 ;; working with a window to the "right" in the window | |
1984 ;; chain. This will create the effect that the output | |
1985 ;; starts in one window and continues into the next. | |
1986 | |
1987 ;; If the display has changed so much that it is not | |
1988 ;; possible to keep the original window fixed and still | |
1989 ;; display the point then we give up and use the new | |
1990 ;; window start. | |
1991 | |
1992 ;; This case is typically used when the process filter | |
1993 ;; tries to reposition the start of the window in order | |
1994 ;; to view the tail of the output. | |
14578 | 1995 ((not (eq orig-window-start new-window-start)) |
1996 (follow-debug-message "filter: Moved") | |
1997 (set-window-start win orig-window-start) | |
1998 (follow-redisplay windows win) | |
1999 (setq win-start-end (follow-windows-start-end windows)) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2000 (follow-select-if-visible new-window-point |
14578 | 2001 win-start-end) |
2002 (goto-char new-window-point) | |
2003 (if (eq win (selected-window)) | |
2004 (set-window-start win new-window-start)) | |
2005 (setq win-start-end (follow-windows-start-end windows))) | |
2006 ;; Stick to this window, if point is visible in it. | |
2007 ((pos-visible-in-window-p new-window-point) | |
2008 (follow-debug-message "filter: Visible in window")) | |
2009 ;; Avoid redisplaying the first window. If the | |
2010 ;; point is visible at a window below, | |
2011 ;; redisplay and select it. | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2012 ((follow-select-if-visible-from-first |
14578 | 2013 new-window-point windows) |
2014 (follow-debug-message "filter: Seen from first") | |
2015 (follow-redisplay windows (car windows)) | |
2016 (goto-char new-window-point) | |
2017 (setq win-start-end | |
2018 (follow-windows-start-end windows))) | |
2019 ;; None of the above. We stick to the current window. | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2020 (t |
14578 | 2021 (follow-debug-message "filter: nothing"))) |
2022 | |
2023 ;; Here we have slected a window. Make sure the | |
2024 ;; windows are aligned and the point is visible | |
2025 ;; in the selected window. | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2026 (if (and (not (follow-pos-visible |
14578 | 2027 (point) (selected-window) win-start-end)) |
2028 (not return-to-orig-win)) | |
2029 (progn | |
2030 (sit-for 0) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2031 (setq win-start-end |
14578 | 2032 (follow-windows-start-end windows)))) |
2033 | |
2034 (if (or follow-internal-force-redisplay | |
2035 (not (follow-windows-aligned-p win-start-end))) | |
2036 (follow-redisplay windows))))))) | |
2037 | |
2038 ;; return to the original window. | |
2039 (if return-to-orig-win | |
2040 (select-window orig-win)) | |
18028
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
2041 ;; Restore the orignal buffer, unless the filter explicitly |
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
2042 ;; changed buffer or killed the old buffer. |
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
2043 (if (and (eq buf (current-buffer)) |
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
2044 (buffer-name old-buffer)) |
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
2045 (set-buffer old-buffer))) |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2046 |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
2047 (follow-invalidate-cache) |
14578 | 2048 |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
2049 ;; Normally, if the display has been changed, it is redrawn. All |
78772
578320c8f7ec
(follow-generic-filter): Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents:
78236
diff
changeset
|
2050 ;; windows showing only the end of a buffer are unconditionally |
578320c8f7ec
(follow-generic-filter): Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents:
78236
diff
changeset
|
2051 ;; recentered; we can't prevent that by calling |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
2052 ;; `follow-avoid-tail-recenter'. |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
2053 ;; |
78772
578320c8f7ec
(follow-generic-filter): Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents:
78236
diff
changeset
|
2054 ;; We force a redisplay here on our own, so Emacs does need to. |
578320c8f7ec
(follow-generic-filter): Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents:
78236
diff
changeset
|
2055 ;; (However, redisplaying when there's input available just seems |
578320c8f7ec
(follow-generic-filter): Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents:
78236
diff
changeset
|
2056 ;; to make things worse, so we exclude that case.) |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
2057 (if (and follow-avoid-tail-recenter-p |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
2058 (not (input-pending-p))) |
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
2059 (sit-for 0))) |
14578 | 2060 |
2061 ;;}}} | |
2062 | |
2063 ;;}}} | |
2064 ;;{{{ Window size change | |
2065 | |
2066 ;; In Emacs 19.29, the functions in `window-size-change-functions' are | |
2067 ;; called every time a window in a frame changes size. Most notably, it | |
2068 ;; is called after the frame has been resized. | |
2069 ;; | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
2070 ;; We basically call our post-command-hook for every buffer that is |
14578 | 2071 ;; visible in any window in the resized frame, which is in follow-mode. |
2072 ;; | |
2073 ;; Since this function can be called indirectly from | |
2074 ;; `follow-post-command-hook' we have a potential infinite loop. We | |
2075 ;; handle this problem by simply not doing anything at all in this | |
2076 ;; situation. The variable `follow-inside-post-command-hook' contains | |
2077 ;; information about whether the execution actually is inside the | |
2078 ;; post-command-hook or not. | |
2079 | |
2080 (if (boundp 'window-size-change-functions) | |
2081 (add-hook 'window-size-change-functions 'follow-window-size-change)) | |
2082 | |
2083 | |
2084 (defun follow-window-size-change (frame) | |
2085 "Redraw all windows in FRAME, when in Follow mode." | |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
2086 ;; Below, we call `post-command-hook'. This makes sure that we |
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
2087 ;; don't start a mutually recursive endless loop. |
14578 | 2088 (if follow-inside-post-command-hook |
2089 nil | |
2090 (let ((buffers '()) | |
2091 (orig-window (selected-window)) | |
2092 (orig-buffer (current-buffer)) | |
2093 (orig-frame (selected-frame)) | |
2094 windows | |
2095 buf) | |
2096 (select-frame frame) | |
2097 (unwind-protect | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2098 (walk-windows |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2099 (function |
14578 | 2100 (lambda (win) |
2101 (setq buf (window-buffer win)) | |
2102 (if (memq buf buffers) | |
2103 nil | |
2104 (set-buffer buf) | |
2105 (if (and (boundp 'follow-mode) | |
2106 follow-mode) | |
2107 (progn | |
2108 (setq windows (follow-all-followers win)) | |
2109 (if (memq orig-window windows) | |
2110 (progn | |
2111 ;; Make sure we're redrawing around the | |
2112 ;; selected window. | |
2113 ;; | |
2114 ;; We must be really careful not to do this | |
2115 ;; when we are (indirectly) called by | |
2116 ;; `post-command-hook'. | |
2117 (select-window orig-window) | |
2118 (follow-post-command-hook) | |
2119 (setq orig-window (selected-window))) | |
2120 (follow-redisplay windows win)) | |
2121 (setq buffers (cons buf buffers)))))))) | |
2122 (select-frame orig-frame) | |
2123 (set-buffer orig-buffer) | |
2124 (select-window orig-window))))) | |
2125 | |
2126 ;;}}} | |
2127 | |
2128 ;;{{{ XEmacs isearch | |
2129 | |
2130 ;; In XEmacs, isearch often finds matches in other windows than the | |
2131 ;; currently selected. However, when exiting the old window | |
2132 ;; configuration is restored, with the exception of the beginning of | |
2133 ;; the start of the window for the selected window. This is not much | |
2134 ;; help for us. | |
2135 ;; | |
2136 ;; We overwrite the stored window configuration with the current, | |
2137 ;; unless we are in `slow-search-mode', i.e. only a few lines | |
2138 ;; of text is visible. | |
2139 | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2140 (if (featurep 'xemacs) |
14578 | 2141 (defadvice isearch-done (before follow-isearch-done activate) |
2142 (if (and (boundp 'follow-mode) | |
2143 follow-mode | |
2144 (boundp 'isearch-window-configuration) | |
2145 isearch-window-configuration | |
2146 (boundp 'isearch-slow-terminal-mode) | |
2147 (not isearch-slow-terminal-mode)) | |
2148 (let ((buf (current-buffer))) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2149 (setq isearch-window-configuration |
14578 | 2150 (current-window-configuration)) |
2151 (set-buffer buf))))) | |
2152 | |
2153 ;;}}} | |
2154 ;;{{{ Tail window handling | |
2155 | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2156 ;; In Emacs (not XEmacs) windows showing nothing are sometimes |
78162
a09176483fa1
(follow-mode-hook, follow-mode-off-hook, follow-mode,
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
2157 ;; recentered. When in Follow Mode, this is not desirable for |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2158 ;; non-first windows in the window chain. This section tries to |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2159 ;; make the windows stay where they should be. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2160 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2161 ;; If the display is updated, all windows starting at (point-max) are |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2162 ;; going to be recentered at the next redisplay, unless we do a |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2163 ;; read-and-write cycle to update the `force' flag inside the windows. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2164 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2165 ;; In 19.30, a new varible `window-scroll-functions' is called every |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2166 ;; time a window is recentered. It is not perfect for our situation, |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2167 ;; since when it is called for a tail window, it is to late. However, |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2168 ;; if it is called for another window, we can try to update our |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2169 ;; windows. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2170 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2171 ;; By patching `sit-for' we can make sure that to catch all explicit |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2172 ;; updates initiated by lisp programs. Internal calls, on the other |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2173 ;; hand, are not handled. |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2174 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2175 ;; Please note that the function `follow-avoid-tail-recenter' is also |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2176 ;; called from other places, e.g. `post-command-hook' and |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2177 ;; `post-command-idle-hook'. |
14578 | 2178 |
18028
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
2179 ;; If this function is called it is too late for this window, but |
89f6e1e17d2d
(follow-submit-feedback, follow-mode): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
16425
diff
changeset
|
2180 ;; we might save other windows from being recentered. |
14578 | 2181 |
2182 (if (and follow-avoid-tail-recenter-p (boundp 'window-scroll-functions)) | |
2183 (add-hook 'window-scroll-functions 'follow-avoid-tail-recenter t)) | |
2184 | |
2185 | |
21333
a6119c0748e9
(follow-scroll-up): Cope if `window-end' returns nil.
Richard M. Stallman <rms@gnu.org>
parents:
21088
diff
changeset
|
2186 ;; This prevents all packages that calls `sit-for' directly |
14578 | 2187 ;; to recenter tail windows. |
2188 | |
2189 (if follow-avoid-tail-recenter-p | |
2190 (defadvice sit-for (before follow-sit-for activate) | |
2191 "Adviced by Follow Mode. | |
2192 | |
2193 Avoid to recenter windows displaying only the end of a file as when | |
2194 displaying a short file in two windows, using Follow Mode." | |
2195 (follow-avoid-tail-recenter))) | |
2196 | |
2197 | |
2198 ;; Without this advice, `mouse-drag-region' would start to recenter | |
2199 ;; tail windows. | |
2200 | |
2201 (if (and follow-avoid-tail-recenter-p | |
2202 (fboundp 'move-overlay)) | |
2203 (defadvice move-overlay (before follow-move-overlay activate) | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2204 "Adviced by Follow Mode. |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2205 Don't recenter windows showing only the end of a buffer. |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2206 This prevents `mouse-drag-region' from messing things up." |
14578 | 2207 (follow-avoid-tail-recenter))) |
2208 | |
2209 ;;}}} | |
2210 ;;{{{ profile support | |
2211 | |
2212 ;; The following (non-evaluated) section can be used to | |
2213 ;; profile this package using `elp'. | |
2214 ;; | |
2215 ;; Invalid indentation on purpose! | |
2216 | |
2217 (cond (nil | |
2218 (setq elp-function-list | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2219 '(window-end |
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2220 vertical-motion |
14578 | 2221 ; sit-for ;; elp can't handle advices... |
2222 follow-mode | |
2223 follow-all-followers | |
18133
7900f6f3c36e
(follow-windows-aligned-p): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
18028
diff
changeset
|
2224 follow-split-followers |
14578 | 2225 follow-redisplay |
2226 follow-downward | |
2227 follow-calculate-first-window-start | |
2228 follow-estimate-first-window-start | |
2229 follow-calculate-first-window-start-from-above | |
2230 follow-calculate-first-window-start-from-below | |
2231 follow-calc-win-end | |
2232 follow-calc-win-start | |
2233 follow-pos-visible | |
2234 follow-windows-start-end | |
14609
a8eeafa7c4af
Update some doc string. Call `add-minor-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
14578
diff
changeset
|
2235 follow-cache-valid-p |
14578 | 2236 follow-select-if-visible |
2237 follow-select-if-visible-from-first | |
2238 follow-windows-aligned-p | |
2239 follow-point-visible-all-windows-p | |
2240 follow-avoid-tail-recenter | |
2241 follow-update-window-start | |
2242 follow-post-command-hook | |
2243 )))) | |
2244 | |
2245 ;;}}} | |
2246 | |
2247 ;;{{{ The end | |
2248 | |
70226
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2249 ;; |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2250 ;; We're done! |
6bc1222277e1
Use (featurep 'xemacs) everywhere.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
2251 ;; |
14578 | 2252 |
2253 (provide 'follow) | |
2254 | |
2255 ;;}}} | |
2256 | |
2257 ;; /------------------------------------------------------------------------\ | |
2258 ;; | "I [..] am rarely happier then when spending an entire day programming | | |
2259 ;; | my computer to perform automatically a task that it would otherwise | | |
2260 ;; | take me a good ten seconds to do by hand. Ten seconds, I tell myself, | | |
2261 ;; | is ten seconds. Time is valuable and ten seconds' worth of it is well | | |
2262 ;; | worth the investment of a day's happy activity working out a way to | | |
2263 ;; | save it". -- Douglas Adams, "Last Chance to See" | | |
2264 ;; \------------------------------------------------------------------------/ | |
2265 | |
60902
7160fe3a7ef1
find-file-hooks -> find-file-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55257
diff
changeset
|
2266 ;; arch-tag: 7b16bb1a-808c-4991-a8cc-66d3822936d0 |
14578 | 2267 ;;; follow.el ends here |