emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp follow.el


From: Chong Yidong
Subject: [Emacs-diffs] emacs/lisp follow.el
Date: Tue, 30 Dec 2008 15:09:35 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Chong Yidong <cyd>      08/12/30 15:09:35

Modified files:
        lisp           : follow.el 

Log message:
        (follow-calculate-first-window-start-from-below): Avoid looping
        forever if vertical-motion returns an unexpected value.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/follow.el?cvsroot=emacs&r1=1.51&r2=1.52

Patches:
Index: follow.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/follow.el,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- follow.el   30 Dec 2008 13:26:23 -0000      1.51
+++ follow.el   30 Dec 2008 15:09:35 -0000      1.52
@@ -1208,22 +1208,25 @@
   (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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]