annotate lisp/modes/follow.el @ 0:376386a54a3c r19-14

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