Mercurial > emacs
comparison lisp/follow.el @ 91040:14c4a6aac623
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 866-879)
- Merge multi-tty branch
- Update from CVS
- Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 11 Oct 2007 16:14:00 +0000 |
parents | f55f9811f5d7 315eb0aa2341 |
children | d38543a1c0f9 |
comparison
equal
deleted
inserted
replaced
91039:eefadc1e1d5e | 91040:14c4a6aac623 |
---|---|
33 ;; combines windows into one tall virtual window. | 33 ;; combines windows into one tall virtual window. |
34 ;; | 34 ;; |
35 ;; The feeling of a "virtual window" has been accomplished by the use | 35 ;; The feeling of a "virtual window" has been accomplished by the use |
36 ;; of two major techniques: | 36 ;; of two major techniques: |
37 ;; | 37 ;; |
38 ;; * The windows always displays adjacent sections of the buffer. | 38 ;; * The windows always display adjacent sections of the buffer. |
39 ;; This means that whenever one window is moved, all the | 39 ;; This means that whenever one window is moved, all the |
40 ;; others will follow. (Hence the name Follow Mode.) | 40 ;; others will follow. (Hence the name Follow Mode.) |
41 ;; | 41 ;; |
42 ;; * Should the point (cursor) end up outside a window, another | 42 ;; * Should the point (cursor) end up outside a window, another |
43 ;; window displaying that point is selected, if possible. This | 43 ;; window displaying that point is selected, if possible. This |
44 ;; makes it possible to walk between windows using normal cursor | 44 ;; makes it possible to walk between windows using normal cursor |
45 ;; movement commands. | 45 ;; movement commands. |
46 ;; | 46 ;; |
47 ;; Follow mode comes to its prime when a large screen and two | 47 ;; Follow mode comes to its prime when a large screen and two |
48 ;; side-by-side window are used. The user can, with the help of Follow | 48 ;; side-by-side window are used. The user can, with the help of Follow |
49 ;; mode, use two full-height windows as though they would have been | 49 ;; mode, use two full-height windows as though they are one. |
50 ;; one. Imagine yourself editing a large function, or section of text, | 50 ;; Imagine yourself editing a large function, or section of text, |
51 ;; and being able to use 144 lines instead of the normal 72... (your | 51 ;; and being able to use 144 lines instead of the normal 72... (your |
52 ;; mileage may vary). | 52 ;; mileage may vary). |
53 | 53 |
54 ;; To test this package, make sure `follow' is loaded, or will be | 54 ;; To test this package, make sure `follow' is loaded, or will be |
55 ;; autoloaded when activated (see below). Then do the following: | 55 ;; autoloaded when activated (see below). Then do the following: |
75 ;; |72 |144 | | 75 ;; |72 |144 | |
76 ;; +----------+----------+ | 76 ;; +----------+----------+ |
77 ;; | 77 ;; |
78 ;; As you can see, the right-hand window starts at line 73, the line | 78 ;; As you can see, the right-hand window starts at line 73, the line |
79 ;; immediately below the end of the left-hand window. As long as | 79 ;; immediately below the end of the left-hand window. As long as |
80 ;; `follow-mode' is active, the two windows will follow eachother! | 80 ;; `follow-mode' is active, the two windows will follow each other! |
81 ;; | 81 ;; |
82 ;; * Play around and enjoy! Scroll one window and watch the other. | 82 ;; * Play around and enjoy! Scroll one window and watch the other. |
83 ;; Jump to the beginning or end. Press `Cursor down' at the last | 83 ;; Jump to the beginning or end. Press `Cursor down' at the last |
84 ;; line of the left-hand window. Enter new lines into the | 84 ;; line of the left-hand window. Enter new lines into the |
85 ;; text. Enter long lines spanning several lines, or several | 85 ;; text. Enter long lines spanning several lines, or several |
99 ;; | 99 ;; |
100 ;; (global-set-key [f8] 'follow-mode) | 100 ;; (global-set-key [f8] 'follow-mode) |
101 ;; (global-set-key [f7] 'follow-delete-other-windows-and-split) | 101 ;; (global-set-key [f7] 'follow-delete-other-windows-and-split) |
102 | 102 |
103 | 103 |
104 ;; There exists two system variables that controls the appearence of | 104 ;; There exist two system variables that control the appearence of |
105 ;; lines that are wider than the window containing them. The default | 105 ;; lines wider than the window containing them. The default is to |
106 ;; is to truncate long lines whenever a window isn't as wide as the | 106 ;; truncate long lines whenever a window isn't as wide as the frame. |
107 ;; frame. | |
108 ;; | 107 ;; |
109 ;; To make sure lines are never truncated, please place the following | 108 ;; To make sure lines are never truncated, please place the following |
110 ;; lines in your init file: | 109 ;; lines in your init file: |
111 ;; | 110 ;; |
112 ;; (setq truncate-lines nil) | 111 ;; (setq truncate-lines nil) |
121 ;; | 120 ;; |
122 ;; (setq pixel-vertical-clip-threshold 30) | 121 ;; (setq pixel-vertical-clip-threshold 30) |
123 | 122 |
124 | 123 |
125 ;; The correct way to cofigurate Follow mode, or any other mode for | 124 ;; The correct way to cofigurate Follow mode, or any other mode for |
126 ;; that matter, is to create one (or more) function that does | 125 ;; that matter, is to create one or more functions that do |
127 ;; whatever you would like to do. The function is then added to | 126 ;; whatever you would like to do. These functions are then added to |
128 ;; a hook. | 127 ;; a hook. |
129 ;; | 128 ;; |
130 ;; When `Follow' mode is activated, functions stored in the hook | 129 ;; When `Follow' mode is activated, functions stored in the hook |
131 ;; `follow-mode-hook' are called. When it is deactivated | 130 ;; `follow-mode-hook' are called. When it is deactivated |
132 ;; `follow-mode-off-hook' is run. | 131 ;; `follow-mode-off-hook' is run. |
142 ;; (define-key follow-mode-map "\C-cb" 'another-function)) | 141 ;; (define-key follow-mode-map "\C-cb" 'another-function)) |
143 | 142 |
144 | 143 |
145 ;; Usage: | 144 ;; Usage: |
146 ;; | 145 ;; |
147 ;; To activate issue the command "M-x follow-mode" | 146 ;; To activate, issue the command "M-x follow-mode" |
148 ;; and press return. To deactivate, do it again. | 147 ;; and press Return. To deactivate, do it again. |
149 ;; | 148 ;; |
150 ;; The following is a list of commands useful when follow-mode is active. | 149 ;; The following is a list of commands useful when follow-mode is active. |
151 ;; | 150 ;; |
152 ;; follow-scroll-up C-c . C-v | 151 ;; follow-scroll-up C-c . C-v |
153 ;; Scroll text in a Follow Mode window chain up. | 152 ;; Scroll text in a Follow Mode window chain up. |
154 ;; | 153 ;; |
155 ;; follow-scroll-down C-c . v | 154 ;; follow-scroll-down C-c . v |
156 ;; Like `follow-scroll-up', but in the other direction. | 155 ;; Like `follow-scroll-up', but in the other direction. |
157 ;; | 156 ;; |
158 ;; follow-delete-other-windows-and-split C-c . 1 | 157 ;; follow-delete-other-windows-and-split C-c . 1 |
159 ;; Maximise the visible area of the current buffer, | 158 ;; Maximize the visible area of the current buffer, |
160 ;; and enter Follow Mode. This is a very convenient | 159 ;; and enter Follow Mode. This is a very convenient |
161 ;; way to start Follow Mode, hence it is recomended | 160 ;; way to start Follow Mode, hence we recomend that |
162 ;; that this command is added to the global keymap. | 161 ;; this command be added to the global keymap. |
163 ;; | 162 ;; |
164 ;; follow-recenter C-c . C-l | 163 ;; follow-recenter C-c . C-l |
165 ;; Place the point in the center of the middle window, | 164 ;; Place the point in the center of the middle window, |
166 ;; or a specified number of lines from either top or bottom. | 165 ;; or a specified number of lines from either top or bottom. |
167 ;; | 166 ;; |
168 ;; follow-switch-to-buffer C-c . b | 167 ;; follow-switch-to-buffer C-c . b |
169 ;; Switch buffer in all windows displaying the current buffer | 168 ;; Switch buffer in all windows displaying the current buffer |
170 ;; in this frame. | 169 ;; in this frame. |
171 ;; | 170 ;; |
172 ;; follow-switch-to-buffer-all C-c . C-b | 171 ;; follow-switch-to-buffer-all C-c . C-b |
173 ;; Switch buffer in all windows in the active frame. | 172 ;; Switch buffer in all windows in the selected frame. |
174 ;; | 173 ;; |
175 ;; follow-switch-to-current-buffer-all | 174 ;; follow-switch-to-current-buffer-all |
176 ;; Show the current buffer in all windows on the current | 175 ;; Show the current buffer in all windows on the current |
177 ;; frame and turn on `follow-mode'. | 176 ;; frame and turn on `follow-mode'. |
178 ;; | 177 ;; |
205 | 204 |
206 ;; Implementation: | 205 ;; Implementation: |
207 ;; | 206 ;; |
208 ;; In an ideal world, follow mode would have been implemented in the | 207 ;; In an ideal world, follow mode would have been implemented in the |
209 ;; kernel of the display routines, making sure that the windows (using | 208 ;; kernel of the display routines, making sure that the windows (using |
210 ;; follow mode) ALWAYS are aligned. On planet earth, however, we must | 209 ;; follow mode) ALWAYS are aligned. On planet Earth, however, we must |
211 ;; accept a solution where we ALMOST ALWAYS can make sure that the | 210 ;; accept a solution where we ALMOST ALWAYS can make sure that the |
212 ;; windows are aligned. | 211 ;; windows are aligned. |
213 ;; | 212 ;; |
214 ;; Follow mode does this in three places: | 213 ;; Follow mode does this in three places: |
215 ;; 1) After each user command. | 214 ;; 1) After each user command. |
252 ;; annoying, we test if the byte-compiler has been loaded. This can, | 251 ;; annoying, we test if the byte-compiler has been loaded. This can, |
253 ;; of course, lead to some occasional unintended evaluation... | 252 ;; of course, lead to some occasional unintended evaluation... |
254 ;; | 253 ;; |
255 ;; Should someone come up with a better solution, please let me | 254 ;; Should someone come up with a better solution, please let me |
256 ;; know. | 255 ;; know. |
256 | |
257 (require 'easymenu) | |
257 | 258 |
258 (eval-when-compile | 259 (eval-when-compile |
259 (if (or (featurep 'bytecomp) | 260 (if (or (featurep 'bytecomp) |
260 (featurep 'byte-compile)) | 261 (featurep 'byte-compile)) |
261 (cond ((featurep 'xemacs) | 262 (cond ((featurep 'xemacs) |
276 :prefix "follow-" | 277 :prefix "follow-" |
277 :group 'windows | 278 :group 'windows |
278 :group 'convenience) | 279 :group 'convenience) |
279 | 280 |
280 (defcustom follow-mode-hook nil | 281 (defcustom follow-mode-hook nil |
281 "Hooks to run when Follow mode is turned on." | 282 "Normal hook run by `follow-mode'." |
282 :type 'hook | 283 :type 'hook |
283 :group 'follow) | 284 :group 'follow) |
284 | 285 |
285 (defcustom follow-mode-off-hook nil | 286 (defcustom follow-mode-off-hook nil |
286 "Hooks to run when Follow mode is turned off." | 287 "Hooks to run when Follow mode is turned off." |
287 :type 'hook | 288 :type 'hook |
288 :group 'follow) | 289 :group 'follow) |
289 | 290 (make-obsolete-variable 'follow-mode-off-hook 'follow-mode-hook "22.2") |
290 | 291 |
291 ;;{{{ Keymap/Menu | 292 ;;{{{ Keymap/Menu |
292 | 293 |
293 ;; Define keys for the follow-mode minor mode map and replace some | 294 ;; Define keys for the follow-mode minor mode map and replace some |
294 ;; functions in the global map. All `follow' mode special functions | 295 ;; functions in the global map. All `follow' mode special functions |
515 | 516 |
516 If the variable `follow-intercept-processes' is non-nil, Follow mode | 517 If the variable `follow-intercept-processes' is non-nil, Follow mode |
517 will listen to the output of processes and redisplay accordingly. | 518 will listen to the output of processes and redisplay accordingly. |
518 \(This is the default.) | 519 \(This is the default.) |
519 | 520 |
520 When Follow mode is switched on, the hook `follow-mode-hook' | 521 This command runs the normal hook `follow-mode-hook'. |
521 is called. When turned off, `follow-mode-off-hook' is called. | |
522 | 522 |
523 Keys specific to Follow mode: | 523 Keys specific to Follow mode: |
524 \\{follow-mode-map}" | 524 \\{follow-mode-map}" |
525 :keymap follow-mode-map | 525 :keymap follow-mode-map |
526 (if (and follow-mode follow-intercept-processes) | 526 (when (and follow-mode follow-intercept-processes) |
527 (follow-intercept-process-output)) | 527 (follow-intercept-process-output)) |
528 (cond (follow-mode ; On | 528 (cond (follow-mode ; On |
529 ;; XEmacs: If this is non-nil, the window will scroll before | 529 ;; XEmacs: If this is non-nil, the window will scroll before |
530 ;; the point will have a chance to get into the next window. | 530 ;; the point will have a chance to get into the next window. |
531 (if (boundp 'scroll-on-clipped-lines) | 531 (when (boundp 'scroll-on-clipped-lines) |
532 (setq scroll-on-clipped-lines nil)) | 532 (setq scroll-on-clipped-lines nil)) |
533 (force-mode-line-update) | 533 (force-mode-line-update) |
534 (add-hook 'post-command-hook 'follow-post-command-hook t) | 534 (add-hook 'post-command-hook 'follow-post-command-hook t)) |
535 (run-hooks 'follow-mode-hook)) | |
536 | 535 |
537 ((not follow-mode) ; Off | 536 ((not follow-mode) ; Off |
538 (force-mode-line-update) | 537 (force-mode-line-update)))) |
539 (run-hooks 'follow-mode-off-hook)))) | |
540 | 538 |
541 ;;}}} | 539 ;;}}} |
542 ;;{{{ Find file hook | 540 ;;{{{ Find file hook |
543 | 541 |
544 ;; This will start follow-mode whenever a new file is loaded, if | 542 ;; This will start follow-mode whenever a new file is loaded, if |
1966 (set-buffer old-buffer))) | 1964 (set-buffer old-buffer))) |
1967 | 1965 |
1968 (follow-invalidate-cache) | 1966 (follow-invalidate-cache) |
1969 | 1967 |
1970 ;; Normally, if the display has been changed, it is redrawn. All | 1968 ;; Normally, if the display has been changed, it is redrawn. All |
1971 ;; windows showing only the end of a buffer is unconditionally | 1969 ;; windows showing only the end of a buffer are unconditionally |
1972 ;; recentered, we can't prevent it by calling | 1970 ;; recentered; we can't prevent that by calling |
1973 ;; `follow-avoid-tail-recenter'. | 1971 ;; `follow-avoid-tail-recenter'. |
1974 ;; | 1972 ;; |
1975 ;; By performing a redisplay on our own, Emacs need not perform | 1973 ;; We force a redisplay here on our own, so Emacs does need to. |
1976 ;; the above described redisplay. (However, bu performing it when | 1974 ;; (However, redisplaying when there's input available just seems |
1977 ;; there are input available just seems to make things worse.) | 1975 ;; to make things worse, so we exclude that case.) |
1978 (if (and follow-avoid-tail-recenter-p | 1976 (if (and follow-avoid-tail-recenter-p |
1979 (not (input-pending-p))) | 1977 (not (input-pending-p))) |
1980 (sit-for 0))) | 1978 (sit-for 0))) |
1981 | 1979 |
1982 ;;}}} | 1980 ;;}}} |