annotate lisp/follow.el @ 102147:4112729ac2e4

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