diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2008-12-30 15:09:35 +0000 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2008-12-30 15:09:35 +0000 |
commit | 13d5c73fb0798b64a3cdcd25815bd56144bbed6f (patch) | |
tree | 687ec99da87c63e509ea0d7ede8f589c09970db9 /lisp/follow.el | |
parent | a2227e215c9a789bfeeeb862a6ccbe55fde9a2cb (diff) | |
download | emacs-13d5c73fb0798b64a3cdcd25815bd56144bbed6f.tar.gz |
(follow-calculate-first-window-start-from-below): Avoid looping
forever if vertical-motion returns an unexpected value.
Diffstat (limited to 'lisp/follow.el')
-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." (setq win (or win (selected-window))) (setq start (or start (window-start win))) (save-excursion - (let ((done nil) - win-start - res) + (let (done win-start res opoint) ;; Always calculate what happens when no line is displayed in the first ;; window. (The `previous' res is needed below!) (goto-char guess) (vertical-motion 0 (car windows)) (setq res (point)) (while (not done) + (setq opoint (point)) (if (not (= (vertical-motion -1 (car windows)) -1)) ;; Hit roof! (setq done t res (point-min)) (setq win-start (follow-calc-win-start windows (point) win)) - (cond ((= win-start start) ; Perfect match, use this value - (setq done t) - (setq res (point))) + (cond ((>= (point) opoint) + ;; In some pathological cases, vertical-motion may + ;; return -1 even though point has not decreased. In + ;; that case, avoid looping forever. + (setq done t res (point))) + ((= win-start start) ; Perfect match, use this value + (setq done t res (point))) ((< win-start start) ; Walked to far, use preious result (setq done t)) (t ; Store result for next iteration |