diff options
| author | Chong Yidong | 2008-12-30 10:52:01 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-12-30 10:52:01 +0000 |
| commit | 4484b97dcd8dfb90121c3524c544bc4c772e5108 (patch) | |
| tree | 4cecd3b27a44f462c614acf8257118b6720ca461 | |
| parent | 0d05df650b3a856e48f84d6e3662820cfc3c6c0a (diff) | |
| download | emacs-4484b97dcd8dfb90121c3524c544bc4c772e5108.tar.gz emacs-4484b97dcd8dfb90121c3524c544bc4c772e5108.zip | |
(follow-calc-win-start): Don't use `inline'.
(follow-update-window-start, follow-select-if-visible)
(follow-calculate-first-window-start-from-below)
(follow-post-command-hook): Code cleanup.
(follow-downward, follow-calculate-first-window-start): Function
deleted and merged into follow-redisplay.
(follow-redisplay): Merge code from follow-downward and
follow-calculate-first-window-start.
| -rw-r--r-- | lisp/follow.el | 473 |
1 files changed, 186 insertions, 287 deletions
diff --git a/lisp/follow.el b/lisp/follow.el index 61ede230be1..3c871a57e5c 100644 --- a/lisp/follow.el +++ b/lisp/follow.el | |||
| @@ -913,7 +913,7 @@ If WIN is nil the point below all windows is returned." | |||
| 913 | (while (and windows (not (eq (car windows) win))) | 913 | (while (and windows (not (eq (car windows) win))) |
| 914 | (setq start (window-start (car windows))) | 914 | (setq start (window-start (car windows))) |
| 915 | (set-window-start (car windows) pos 'noforce) | 915 | (set-window-start (car windows) pos 'noforce) |
| 916 | (setq pos (car (inline (follow-calc-win-end (car windows))))) | 916 | (setq pos (car (follow-calc-win-end (car windows)))) |
| 917 | (set-window-start (car windows) start 'noforce) | 917 | (set-window-start (car windows) start 'noforce) |
| 918 | (setq windows (cdr windows))) | 918 | (setq windows (cdr windows))) |
| 919 | pos)) | 919 | pos)) |
| @@ -1027,11 +1027,9 @@ Note that this handles the case when the cache has been set to nil." | |||
| 1027 | "Make sure that the start of WIN starts at a full screen line." | 1027 | "Make sure that the start of WIN starts at a full screen line." |
| 1028 | (save-excursion | 1028 | (save-excursion |
| 1029 | (goto-char (window-start win)) | 1029 | (goto-char (window-start win)) |
| 1030 | (if (bolp) | 1030 | (unless (bolp) |
| 1031 | nil | ||
| 1032 | (vertical-motion 0 win) | 1031 | (vertical-motion 0 win) |
| 1033 | (if (eq (point) (window-start win)) | 1032 | (unless (eq (point) (window-start win)) |
| 1034 | nil | ||
| 1035 | (vertical-motion 1 win) | 1033 | (vertical-motion 1 win) |
| 1036 | (set-window-start win (point) 'noforce))))) | 1034 | (set-window-start win (point) 'noforce))))) |
| 1037 | 1035 | ||
| @@ -1046,15 +1044,14 @@ Note that this handles the case when the cache has been set to nil." | |||
| 1046 | (defun follow-select-if-visible (dest win-start-end) | 1044 | (defun follow-select-if-visible (dest win-start-end) |
| 1047 | "Select and return a window, if DEST is visible in it. | 1045 | "Select and return a window, if DEST is visible in it. |
| 1048 | Return the selected window." | 1046 | Return the selected window." |
| 1049 | (let ((win nil)) | 1047 | (let (win) |
| 1050 | (while (and (not win) win-start-end) | 1048 | (while (and (not win) win-start-end) |
| 1051 | ;; Don't select a window that was just moved. This makes it | 1049 | ;; Don't select a window that was just moved. This makes it |
| 1052 | ;; possible to later select the last window after a `end-of-buffer' | 1050 | ;; possible to later select the last window after a `end-of-buffer' |
| 1053 | ;; command. | 1051 | ;; command. |
| 1054 | (if (follow-pos-visible dest (car (car win-start-end)) win-start-end) | 1052 | (when (follow-pos-visible dest (caar win-start-end) win-start-end) |
| 1055 | (progn | 1053 | (setq win (caar win-start-end)) |
| 1056 | (setq win (car (car win-start-end))) | 1054 | (select-window win)) |
| 1057 | (select-window win))) | ||
| 1058 | (setq win-start-end (cdr win-start-end))) | 1055 | (setq win-start-end (cdr win-start-end))) |
| 1059 | win)) | 1056 | win)) |
| 1060 | 1057 | ||
| @@ -1126,7 +1123,8 @@ Return the selected window." | |||
| 1126 | 1123 | ||
| 1127 | ;; Redraw all the windows on the screen, starting with the top window. | 1124 | ;; Redraw all the windows on the screen, starting with the top window. |
| 1128 | ;; The window used as as marker is WIN, or the selcted window if WIN | 1125 | ;; The window used as as marker is WIN, or the selcted window if WIN |
| 1129 | ;; is nil. | 1126 | ;; is nil. Start every window directly after the end of the previous |
| 1127 | ;; window, to make sure long lines are displayed correctly. | ||
| 1130 | 1128 | ||
| 1131 | (defun follow-redisplay (&optional windows win) | 1129 | (defun follow-redisplay (&optional windows win) |
| 1132 | "Reposition the WINDOWS around WIN. | 1130 | "Reposition the WINDOWS around WIN. |
| @@ -1136,98 +1134,41 @@ redisplay, it is assumed that WIN is a member of the list. | |||
| 1136 | Should WINDOWS be nil, the windows displaying the | 1134 | Should WINDOWS be nil, the windows displaying the |
| 1137 | same buffer as WIN, in the current frame, are used. | 1135 | same buffer as WIN, in the current frame, are used. |
| 1138 | Should WIN be nil, the selected window is used." | 1136 | Should WIN be nil, the selected window is used." |
| 1139 | (or win | 1137 | (or win (setq win (selected-window))) |
| 1140 | (setq win (selected-window))) | 1138 | (or windows (setq windows (follow-all-followers win))) |
| 1141 | (or windows | 1139 | ;; Calculate the start of the first window. |
| 1142 | (setq windows (follow-all-followers win))) | 1140 | (let* ((old-win-start (window-start win)) |
| 1143 | (follow-downward windows (follow-calculate-first-window-start windows win))) | 1141 | (try-first-start (follow-estimate-first-window-start |
| 1144 | 1142 | windows win old-win-start)) | |
| 1145 | 1143 | (try-win-start (follow-calc-win-start | |
| 1146 | ;; Redisplay a chain of windows. Start every window directly after the | 1144 | windows try-first-start win)) |
| 1147 | ;; end of the previous window, to make sure long lines are displayed | 1145 | (start (cond ((= try-win-start old-win-start) |
| 1148 | ;; correctly. | 1146 | (follow-debug-message "exact") |
| 1149 | 1147 | try-first-start) | |
| 1150 | (defun follow-downward (windows pos) | 1148 | ((< try-win-start old-win-start) |
| 1151 | "Redisplay all WINDOWS starting at POS." | 1149 | (follow-debug-message "above") |
| 1152 | (while windows | 1150 | (follow-calculate-first-window-start-from-above |
| 1153 | (set-window-start (car windows) pos) | 1151 | windows try-first-start win old-win-start)) |
| 1154 | (setq pos (car (follow-calc-win-end (car windows)))) | 1152 | (t |
| 1155 | (setq windows (cdr windows)))) | 1153 | (follow-debug-message "below") |
| 1156 | 1154 | (follow-calculate-first-window-start-from-below | |
| 1157 | 1155 | windows try-first-start win old-win-start))))) | |
| 1158 | ;;(defun follow-downward (windows pos) | 1156 | (dolist (w windows) |
| 1159 | ;; "Redisplay all WINDOWS starting at POS." | 1157 | (set-window-start w start) |
| 1160 | ;; (let (p) | 1158 | (setq start (car (follow-calc-win-end w)))))) |
| 1161 | ;; (while windows | ||
| 1162 | ;; (setq p (window-point (car windows))) | ||
| 1163 | ;; (set-window-start (car windows) pos) | ||
| 1164 | ;; (set-window-point (car windows) (max p pos)) | ||
| 1165 | ;; (setq pos (car (follow-calc-win-end (car windows)))) | ||
| 1166 | ;; (setq windows (cdr windows))))) | ||
| 1167 | |||
| 1168 | |||
| 1169 | ;; Return the start of the first window. | ||
| 1170 | ;; | ||
| 1171 | ;; First, estimate the position. It the value is not perfect (i.e. we | ||
| 1172 | ;; have somewhere splited a line between windows) we try to enhance | ||
| 1173 | ;; the value. | ||
| 1174 | ;; | ||
| 1175 | ;; The guess is always perfect if no long lines is split between | ||
| 1176 | ;; windows. | ||
| 1177 | ;; | ||
| 1178 | ;; The worst case peformace of probably very bad, but it is very | ||
| 1179 | ;; unlikely that we ever will miss the correct start by more than one | ||
| 1180 | ;; or two lines. | ||
| 1181 | |||
| 1182 | (defun follow-calculate-first-window-start (windows &optional win start) | ||
| 1183 | "Calculate the start of the first window. | ||
| 1184 | |||
| 1185 | WINDOWS is a chain of windows to work with. WIN is the window | ||
| 1186 | to recenter around. It is assumed that WIN starts at position | ||
| 1187 | START." | ||
| 1188 | (or win | ||
| 1189 | (setq win (selected-window))) | ||
| 1190 | (or start | ||
| 1191 | (setq start (window-start win))) | ||
| 1192 | (let ((guess (follow-estimate-first-window-start windows win start))) | ||
| 1193 | (if (car guess) | ||
| 1194 | (cdr guess) | ||
| 1195 | ;; The guess wasn't exact, try to enhance it. | ||
| 1196 | (let ((win-start (follow-calc-win-start windows (cdr guess) win))) | ||
| 1197 | (cond ((= win-start start) | ||
| 1198 | (follow-debug-message "exact") | ||
| 1199 | (cdr guess)) | ||
| 1200 | ((< win-start start) | ||
| 1201 | (follow-debug-message "above") | ||
| 1202 | (follow-calculate-first-window-start-from-above | ||
| 1203 | windows (cdr guess) win start)) | ||
| 1204 | (t | ||
| 1205 | (follow-debug-message "below") | ||
| 1206 | (follow-calculate-first-window-start-from-below | ||
| 1207 | windows (cdr guess) win start))))))) | ||
| 1208 | 1159 | ||
| 1209 | 1160 | ||
| 1210 | ;; `exact' is disabled due to XEmacs and fonts of variable | ||
| 1211 | ;; height. | ||
| 1212 | (defun follow-estimate-first-window-start (windows win start) | 1161 | (defun follow-estimate-first-window-start (windows win start) |
| 1213 | "Estimate the position of the first window. | 1162 | "Estimate the position of the first window. |
| 1214 | 1163 | The estimate is computed by assuming that the window WIN, which | |
| 1215 | Returns (EXACT . POS). If EXACT is non-nil, POS is the starting | 1164 | should be a member of WINDOWS, starts at position START." |
| 1216 | position of the first window. Otherwise it is a good guess." | 1165 | (let ((windows-before (car (follow-split-followers windows win)))) |
| 1217 | (let ((pred (car (follow-split-followers windows win))) | ||
| 1218 | (exact nil)) | ||
| 1219 | (save-excursion | 1166 | (save-excursion |
| 1220 | (goto-char start) | 1167 | (goto-char start) |
| 1221 | ;(setq exact (bolp)) | ||
| 1222 | (vertical-motion 0 win) | 1168 | (vertical-motion 0 win) |
| 1223 | (while pred | 1169 | (dolist (w windows-before) |
| 1224 | (vertical-motion | 1170 | (vertical-motion (- 1 (window-text-height w)) w)) |
| 1225 | (- (if header-line-format 2 1) | 1171 | (point)))) |
| 1226 | (window-height (car pred))) (car pred)) | ||
| 1227 | (if (not (bolp)) | ||
| 1228 | (setq exact nil)) | ||
| 1229 | (setq pred (cdr pred))) | ||
| 1230 | (cons exact (point))))) | ||
| 1231 | 1172 | ||
| 1232 | 1173 | ||
| 1233 | ;; Find the starting point, start at GUESS and search downward. | 1174 | ;; Find the starting point, start at GUESS and search downward. |
| @@ -1249,9 +1190,7 @@ position of the first window. Otherwise it is a good guess." | |||
| 1249 | (setq res (point-max))) | 1190 | (setq res (point-max))) |
| 1250 | (setq win-start (follow-calc-win-start windows (point) win)) | 1191 | (setq win-start (follow-calc-win-start windows (point) win)) |
| 1251 | (if (>= win-start start) | 1192 | (if (>= win-start start) |
| 1252 | (progn | 1193 | (setq done t res (point))))) |
| 1253 | (setq done t) | ||
| 1254 | (setq res (point)))))) | ||
| 1255 | res))) | 1194 | res))) |
| 1256 | 1195 | ||
| 1257 | 1196 | ||
| @@ -1277,9 +1216,7 @@ position of the first window. Otherwise it is a good guess." | |||
| 1277 | (while (not done) | 1216 | (while (not done) |
| 1278 | (if (not (= (vertical-motion -1 (car windows)) -1)) | 1217 | (if (not (= (vertical-motion -1 (car windows)) -1)) |
| 1279 | ;; Hit roof! | 1218 | ;; Hit roof! |
| 1280 | (progn | 1219 | (setq done t res (point-min)) |
| 1281 | (setq done t) | ||
| 1282 | (setq res (point-min))) | ||
| 1283 | (setq win-start (follow-calc-win-start windows (point) win)) | 1220 | (setq win-start (follow-calc-win-start windows (point) win)) |
| 1284 | (cond ((= win-start start) ; Perfect match, use this value | 1221 | (cond ((= win-start start) ; Perfect match, use this value |
| 1285 | (setq done t) | 1222 | (setq done t) |
| @@ -1362,190 +1299,154 @@ non-first windows in Follow mode." | |||
| 1362 | 1299 | ||
| 1363 | (defun follow-post-command-hook () | 1300 | (defun follow-post-command-hook () |
| 1364 | "Ensure that the windows in Follow mode are adjacent after each command." | 1301 | "Ensure that the windows in Follow mode are adjacent after each command." |
| 1365 | (setq follow-inside-post-command-hook t) | 1302 | (unless (input-pending-p) |
| 1366 | (if (or (not (input-pending-p)) | 1303 | (let ((follow-inside-post-command-hook t) |
| 1367 | ;; Sometimes, in XEmacs, mouse events are not handled | 1304 | (win (selected-window))) |
| 1368 | ;; properly by `input-pending-p'. A typical example is | ||
| 1369 | ;; when clicking on a node in `info'. | ||
| 1370 | (and (boundp 'current-mouse-event) | ||
| 1371 | (symbol-value 'current-mouse-event) | ||
| 1372 | (fboundp 'button-event-p) | ||
| 1373 | (funcall (symbol-function 'button-event-p) | ||
| 1374 | (symbol-value 'current-mouse-event)))) | ||
| 1375 | ;; Work in the selected window, not in the current buffer. | 1305 | ;; Work in the selected window, not in the current buffer. |
| 1376 | (let ((orig-buffer (current-buffer)) | 1306 | (with-current-buffer (window-buffer win) |
| 1377 | (win (selected-window))) | 1307 | (unless (and (symbolp this-command) |
| 1378 | (set-buffer (window-buffer win)) | 1308 | (get this-command 'follow-mode-use-cache)) |
| 1379 | (or (and (symbolp this-command) | 1309 | (follow-invalidate-cache)) |
| 1380 | (get this-command 'follow-mode-use-cache)) | 1310 | (when (and follow-mode |
| 1381 | (follow-invalidate-cache)) | 1311 | (not (window-minibuffer-p win))) |
| 1382 | (if (and (boundp 'follow-mode) follow-mode | 1312 | ;; The buffer shown in the selected window is in follow |
| 1383 | (not (window-minibuffer-p win))) | 1313 | ;; mode. Find the current state of the display and cache |
| 1384 | ;; The buffer shown in the selected window is in follow | 1314 | ;; the result for speed (i.e. `aligned' and `visible'.) |
| 1385 | ;; mode, lets find the current state of the display and | 1315 | (let* ((windows (follow-all-followers win)) |
| 1386 | ;; cache the result for speed (i.e. `aligned' and `visible'.) | 1316 | (dest (point)) |
| 1387 | (let* ((windows (inline (follow-all-followers win))) | 1317 | (win-start-end (progn |
| 1388 | (dest (point)) | 1318 | (follow-update-window-start (car windows)) |
| 1389 | (win-start-end (inline | 1319 | (follow-windows-start-end windows))) |
| 1390 | (follow-update-window-start (car windows)) | 1320 | (aligned (follow-windows-aligned-p win-start-end)) |
| 1391 | (follow-windows-start-end windows))) | 1321 | (visible (follow-pos-visible dest win win-start-end))) |
| 1392 | (aligned (follow-windows-aligned-p win-start-end)) | 1322 | (unless (and aligned visible) |
| 1393 | (visible (follow-pos-visible dest win win-start-end))) | 1323 | (follow-invalidate-cache)) |
| 1394 | (if (not (and aligned visible)) | 1324 | (follow-avoid-tail-recenter) |
| 1395 | (follow-invalidate-cache)) | 1325 | ;; Select a window to display point. |
| 1396 | (inline (follow-avoid-tail-recenter)) | 1326 | (unless follow-internal-force-redisplay |
| 1397 | ;; Select a window to display the point. | 1327 | (if (eq dest (point-max)) |
| 1398 | (or follow-internal-force-redisplay | 1328 | ;; At point-max, we have to be careful since the |
| 1399 | (progn | 1329 | ;; display can be aligned while `dest' can be |
| 1400 | (if (eq dest (point-max)) | 1330 | ;; visible in several windows. |
| 1401 | ;; We're at the end, we have to be careful since | 1331 | (cond |
| 1402 | ;; the display can be aligned while `dest' can | 1332 | ;; Select the current window, but only when the |
| 1403 | ;; be visible in several windows. | 1333 | ;; display is correct. (When inserting characters |
| 1404 | (cond | 1334 | ;; in a tail window, the display is not correct, as |
| 1405 | ;; Select the current window, but only when | 1335 | ;; they are shown twice.) |
| 1406 | ;; the display is correct. (When inserting | 1336 | ;; |
| 1407 | ;; character in a tail window, the display is | 1337 | ;; Never stick to the current window after a |
| 1408 | ;; not correct, as they are shown twice.) | 1338 | ;; deletion. The reason is cosmetic: when typing |
| 1409 | ;; | 1339 | ;; `DEL' in a window showing only the end of the |
| 1410 | ;; Never stick to the current window after a | 1340 | ;; file, a character would be removed from the |
| 1411 | ;; deletion. The reason is cosmetic, when | 1341 | ;; window above, which is very unintuitive. |
| 1412 | ;; typing `DEL' in a window showing only the | 1342 | ((and visible |
| 1413 | ;; end of the file, character are removed | 1343 | aligned |
| 1414 | ;; from the window above, which is very | 1344 | (not (memq this-command |
| 1415 | ;; unintuitive. | 1345 | '(backward-delete-char |
| 1416 | ((and visible | 1346 | delete-backward-char |
| 1417 | aligned | 1347 | backward-delete-char-untabify |
| 1418 | (not (memq this-command | 1348 | kill-region)))) |
| 1419 | '(backward-delete-char | 1349 | (follow-debug-message "Max: same")) |
| 1420 | delete-backward-char | 1350 | ;; If the end is visible, and the window doesn't |
| 1421 | backward-delete-char-untabify | 1351 | ;; seems like it just has been moved, select it. |
| 1422 | kill-region)))) | 1352 | ((follow-select-if-end-visible win-start-end) |
| 1423 | (follow-debug-message "Max: same")) | 1353 | (follow-debug-message "Max: end visible") |
| 1424 | ;; If the end is visible, and the window | 1354 | (setq visible t aligned nil) |
| 1425 | ;; doesn't seems like it just has been moved, | 1355 | (goto-char dest)) |
| 1426 | ;; select it. | 1356 | ;; Just show the end... |
| 1427 | ((follow-select-if-end-visible win-start-end) | 1357 | (t |
| 1428 | (follow-debug-message "Max: end visible") | 1358 | (follow-debug-message "Max: default") |
| 1429 | (setq visible t) | 1359 | (select-window (car (reverse windows))) |
| 1430 | (setq aligned nil) | 1360 | (goto-char dest) |
| 1431 | (goto-char dest)) | 1361 | (setq visible nil aligned nil))) |
| 1432 | ;; Just show the end... | 1362 | |
| 1433 | (t | 1363 | ;; We're not at the end, here life is much simpler. |
| 1434 | (follow-debug-message "Max: default") | 1364 | (cond |
| 1435 | (select-window (car (reverse windows))) | 1365 | ;; This is the normal case! |
| 1436 | (goto-char dest) | 1366 | ;; It should be optimized for speed. |
| 1437 | (setq visible nil) | 1367 | ((and visible aligned) |
| 1438 | (setq aligned nil))) | 1368 | (follow-debug-message "same")) |
| 1439 | 1369 | ;; Pick a position in any window. If the display is | |
| 1440 | ;; We're not at the end, here life is much simpler. | 1370 | ;; ok, this will pick the `correct' window. If the |
| 1441 | (cond | 1371 | ;; display is wierd (e.g., after a delete at the |
| 1442 | ;; This is the normal case! | 1372 | ;; beginning of the window) do this anyway. |
| 1443 | ;; It should be optimized for speed. | 1373 | ((follow-select-if-visible dest win-start-end) |
| 1444 | ((and visible aligned) | 1374 | (follow-debug-message "visible") |
| 1445 | (follow-debug-message "same")) | 1375 | (setq visible t) |
| 1446 | ;; Pick a position in any window. If the | 1376 | (goto-char dest)) |
| 1447 | ;; display is ok, this will pick the `correct' | 1377 | ;; Not visible anywhere else, lets pick this one. |
| 1448 | ;; window. If the display is wierd do this | 1378 | ;; (Is this case used?) |
| 1449 | ;; anyway, this will be the case after a delete | 1379 | (visible |
| 1450 | ;; at the beginning of the window. | 1380 | (follow-debug-message "visible in selected.")) |
| 1451 | ((follow-select-if-visible dest win-start-end) | 1381 | ;; Far out! |
| 1452 | (follow-debug-message "visible") | 1382 | ((eq dest (point-min)) |
| 1453 | (setq visible t) | 1383 | (follow-debug-message "min") |
| 1454 | (goto-char dest)) | 1384 | (select-window (car windows)) |
| 1455 | ;; Not visible anywhere else, lets pick this one. | 1385 | (goto-char dest) |
| 1456 | ;; (Is this case used?) | 1386 | (set-window-start (selected-window) (point-min)) |
| 1457 | (visible | 1387 | (setq win-start-end (follow-windows-start-end windows)) |
| 1458 | (follow-debug-message "visible in selected.")) | 1388 | (follow-invalidate-cache) |
| 1459 | ;; Far out! | 1389 | (setq visible t aligned nil)) |
| 1460 | ((eq dest (point-min)) | 1390 | ;; If we can position the cursor without moving the first |
| 1461 | (follow-debug-message "min") | 1391 | ;; window, do it. This is the case that catches `RET' |
| 1462 | (select-window (car windows)) | 1392 | ;; at the bottom of a window. |
| 1463 | (goto-char dest) | 1393 | ((follow-select-if-visible-from-first dest windows) |
| 1464 | (set-window-start (selected-window) (point-min)) | 1394 | (follow-debug-message "Below first") |
| 1465 | (setq win-start-end (follow-windows-start-end windows)) | 1395 | (setq visible t aligned t) |
| 1466 | (follow-invalidate-cache) | 1396 | (follow-redisplay windows (car windows)) |
| 1467 | (setq visible t) | 1397 | (goto-char dest)) |
| 1468 | (setq aligned nil)) | 1398 | ;; None of the above. For simplicity, we stick to the |
| 1469 | ;; If we can position the cursor without moving the first | 1399 | ;; selected window. |
| 1470 | ;; window, do it. This is the case that catches `RET' | 1400 | (t |
| 1471 | ;; at the bottom of a window. | 1401 | (follow-debug-message "None") |
| 1472 | ((follow-select-if-visible-from-first dest windows) | 1402 | (setq visible nil aligned nil)))) |
| 1473 | (follow-debug-message "Below first") | 1403 | ;; If a new window has been selected, make sure that the |
| 1474 | (setq visible t) | 1404 | ;; old is not scrolled when the point is outside the |
| 1475 | (setq aligned t) | 1405 | ;; window. |
| 1476 | (follow-redisplay windows (car windows)) | 1406 | (or (eq win (selected-window)) |
| 1477 | (goto-char dest)) | 1407 | (let ((p (window-point win))) |
| 1478 | ;; None of the above. For simplicity, we stick to the | 1408 | (set-window-start win (window-start win) nil) |
| 1479 | ;; selected window. | 1409 | (set-window-point win p)))) |
| 1480 | (t | 1410 | ;; Make sure the point is visible in the selected window. |
| 1481 | (follow-debug-message "None") | 1411 | ;; (This could lead to a scroll.) |
| 1482 | (setq visible nil) | 1412 | (unless (or visible |
| 1483 | (setq aligned nil)))) | 1413 | (follow-pos-visible dest win win-start-end)) |
| 1484 | ;; If a new window has been selected, make sure that the | 1414 | (sit-for 0) |
| 1485 | ;; old is not scrolled when the point is outside the | 1415 | (follow-avoid-tail-recenter) |
| 1486 | ;; window. | 1416 | (setq win-start-end (follow-windows-start-end windows)) |
| 1487 | (or (eq win (selected-window)) | 1417 | (follow-invalidate-cache) |
| 1488 | (let ((p (window-point win))) | 1418 | (setq aligned nil)) |
| 1489 | (set-window-start win (window-start win) nil) | 1419 | ;; Redraw the windows whenever needed. |
| 1490 | (set-window-point win p))))) | 1420 | (unless (and (not follow-internal-force-redisplay) |
| 1491 | ;; Make sure the point is visible in the selected window. | 1421 | (or aligned |
| 1492 | ;; (This could lead to a scroll.) | 1422 | (follow-windows-aligned-p win-start-end)) |
| 1493 | (if (or visible | 1423 | (follow-point-visible-all-windows-p |
| 1494 | (follow-pos-visible dest win win-start-end)) | 1424 | win-start-end)) |
| 1495 | nil | 1425 | (setq follow-internal-force-redisplay nil) |
| 1496 | (sit-for 0) | 1426 | (follow-redisplay windows (selected-window)) |
| 1497 | (follow-avoid-tail-recenter) | 1427 | (setq win-start-end (follow-windows-start-end windows)) |
| 1498 | (setq win-start-end (follow-windows-start-end windows)) | 1428 | (follow-invalidate-cache) |
| 1499 | (follow-invalidate-cache) | 1429 | ;; When the point ends up in another window. This |
| 1500 | (setq aligned nil)) | 1430 | ;; happens when dest is in the beginning of the file and |
| 1501 | ;; Redraw the windows whenever needed. | 1431 | ;; the selected window is not the first. It can also, |
| 1502 | (if (or follow-internal-force-redisplay | 1432 | ;; in rare situations happen when long lines are used |
| 1503 | (not (or aligned | 1433 | ;; and there is a big difference between the width of |
| 1504 | (follow-windows-aligned-p win-start-end))) | 1434 | ;; the windows. (When scrolling one line in a wide |
| 1505 | (not (inline (follow-point-visible-all-windows-p | 1435 | ;; window which will cause a move larger that an entire |
| 1506 | win-start-end)))) | 1436 | ;; small window.) |
| 1507 | (progn | 1437 | (unless (follow-pos-visible dest win win-start-end) |
| 1508 | (setq follow-internal-force-redisplay nil) | 1438 | (follow-select-if-visible dest win-start-end) |
| 1509 | (follow-redisplay windows (selected-window)) | 1439 | (goto-char dest))) |
| 1510 | (setq win-start-end (follow-windows-start-end windows)) | 1440 | |
| 1511 | (follow-invalidate-cache) | 1441 | ;; If the region is visible, make it look good when spanning |
| 1512 | ;; When the point ends up in another window. This | 1442 | ;; multiple windows. |
| 1513 | ;; happens when dest is in the beginning of the | 1443 | (when (region-active-p) |
| 1514 | ;; file and the selected window is not the first. | 1444 | (follow-maximize-region |
| 1515 | ;; It can also, in rare situations happen when | 1445 | (selected-window) windows win-start-end)))) |
| 1516 | ;; long lines are used and there is a big | 1446 | ;; Whether or not the buffer was in follow mode, we must |
| 1517 | ;; difference between the width of the windows. | 1447 | ;; update the windows displaying the tail so that Emacs won't |
| 1518 | ;; (When scrolling one line in a wide window which | 1448 | ;; recenter them. |
| 1519 | ;; will cause a move larger that an entire small | 1449 | (follow-avoid-tail-recenter))))) |
| 1520 | ;; window.) | ||
| 1521 | (if (follow-pos-visible dest win win-start-end) | ||
| 1522 | nil | ||
| 1523 | (follow-select-if-visible dest win-start-end) | ||
| 1524 | (goto-char dest)))) | ||
| 1525 | |||
| 1526 | ;; If the region is visible, make it look good when spanning | ||
| 1527 | ;; multiple windows. | ||
| 1528 | (if (or (and (boundp 'mark-active) (symbol-value 'mark-active)) | ||
| 1529 | ;; The following isn't used in Emacs, | ||
| 1530 | ;; since `mark-active' is bound. | ||
| 1531 | (and (fboundp 'region-active-p) | ||
| 1532 | (funcall (symbol-function 'region-active-p)))) | ||
| 1533 | (follow-maximize-region | ||
| 1534 | (selected-window) windows win-start-end)) | ||
| 1535 | |||
| 1536 | (inline (follow-avoid-tail-recenter)) | ||
| 1537 | ;; DEBUG | ||
| 1538 | ;;(if (not (follow-windows-aligned-p | ||
| 1539 | ;; (follow-windows-start-end windows))) | ||
| 1540 | ;; (message "follow-mode: windows still unaligend!")) | ||
| 1541 | ;; END OF DEBUG | ||
| 1542 | ) ; Matches (let* | ||
| 1543 | ;; Buffer not in follow mode: | ||
| 1544 | ;; We still must update the windows displaying the tail so that | ||
| 1545 | ;; Emacs won't recenter them. | ||
| 1546 | (follow-avoid-tail-recenter)) | ||
| 1547 | (set-buffer orig-buffer))) | ||
| 1548 | (setq follow-inside-post-command-hook nil)) | ||
| 1549 | 1450 | ||
| 1550 | ;;}}} | 1451 | ;;}}} |
| 1551 | ;;{{{ The region | 1452 | ;;{{{ The region |
| @@ -2143,8 +2044,6 @@ This prevents `mouse-drag-region' from messing things up." | |||
| 2143 | follow-all-followers | 2044 | follow-all-followers |
| 2144 | follow-split-followers | 2045 | follow-split-followers |
| 2145 | follow-redisplay | 2046 | follow-redisplay |
| 2146 | follow-downward | ||
| 2147 | follow-calculate-first-window-start | ||
| 2148 | follow-estimate-first-window-start | 2047 | follow-estimate-first-window-start |
| 2149 | follow-calculate-first-window-start-from-above | 2048 | follow-calculate-first-window-start-from-above |
| 2150 | follow-calculate-first-window-start-from-below | 2049 | follow-calculate-first-window-start-from-below |