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