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