diff options
| -rw-r--r-- | lisp/follow.el | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lisp/follow.el b/lisp/follow.el index 59b8a8a38fd..7af3a049299 100644 --- a/lisp/follow.el +++ b/lisp/follow.el | |||
| @@ -1208,22 +1208,25 @@ should be a member of WINDOWS, starts at position START." | |||
| 1208 | (setq win (or win (selected-window))) | 1208 | (setq win (or win (selected-window))) |
| 1209 | (setq start (or start (window-start win))) | 1209 | (setq start (or start (window-start win))) |
| 1210 | (save-excursion | 1210 | (save-excursion |
| 1211 | (let ((done nil) | 1211 | (let (done win-start res opoint) |
| 1212 | win-start | ||
| 1213 | res) | ||
| 1214 | ;; Always calculate what happens when no line is displayed in the first | 1212 | ;; Always calculate what happens when no line is displayed in the first |
| 1215 | ;; window. (The `previous' res is needed below!) | 1213 | ;; window. (The `previous' res is needed below!) |
| 1216 | (goto-char guess) | 1214 | (goto-char guess) |
| 1217 | (vertical-motion 0 (car windows)) | 1215 | (vertical-motion 0 (car windows)) |
| 1218 | (setq res (point)) | 1216 | (setq res (point)) |
| 1219 | (while (not done) | 1217 | (while (not done) |
| 1218 | (setq opoint (point)) | ||
| 1220 | (if (not (= (vertical-motion -1 (car windows)) -1)) | 1219 | (if (not (= (vertical-motion -1 (car windows)) -1)) |
| 1221 | ;; Hit roof! | 1220 | ;; Hit roof! |
| 1222 | (setq done t res (point-min)) | 1221 | (setq done t res (point-min)) |
| 1223 | (setq win-start (follow-calc-win-start windows (point) win)) | 1222 | (setq win-start (follow-calc-win-start windows (point) win)) |
| 1224 | (cond ((= win-start start) ; Perfect match, use this value | 1223 | (cond ((>= (point) opoint) |
| 1225 | (setq done t) | 1224 | ;; In some pathological cases, vertical-motion may |
| 1226 | (setq res (point))) | 1225 | ;; return -1 even though point has not decreased. In |
| 1226 | ;; that case, avoid looping forever. | ||
| 1227 | (setq done t res (point))) | ||
| 1228 | ((= win-start start) ; Perfect match, use this value | ||
| 1229 | (setq done t res (point))) | ||
| 1227 | ((< win-start start) ; Walked to far, use preious result | 1230 | ((< win-start start) ; Walked to far, use preious result |
| 1228 | (setq done t)) | 1231 | (setq done t)) |
| 1229 | (t ; Store result for next iteration | 1232 | (t ; Store result for next iteration |