(widget-move): Don't loop infinitely when there is
authorAndreas Schwab <schwab@suse.de>
Sat, 14 Dec 2002 14:27:23 +0000 (14:27 +0000)
committerAndreas Schwab <schwab@suse.de>
Sat, 14 Dec 2002 14:27:23 +0000 (14:27 +0000)
no field or button.

lisp/ChangeLog
lisp/wid-edit.el

index ecc2ee2..5055090 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-14  Andreas Schwab  <schwab@suse.de>
+
+       * wid-edit.el (widget-move): Don't loop infinitely when there is
+       no field or button.
+
 2002-12-13  Stefan Monnier  <monnier@cs.yale.edu>
 
        * uniquify.el (uniquify-rationalize-file-buffer-names, rename-buffer)
index 4e97f9a..068b805 100644 (file)
@@ -1002,19 +1002,20 @@ This is much faster, but doesn't work reliably on Emacs 19.34.")
   "Move point to the ARG next field or button.
 ARG may be negative to move backward."
   (or (bobp) (> arg 0) (backward-char))
-  (let ((pos (point))
+  (let ((wrapped 0)
        (number arg)
        (old (widget-tabable-at))
        new)
     ;; Forward.
     (while (> arg 0)
       (cond ((eobp)
-            (goto-char (point-min)))
+            (goto-char (point-min))
+            (setq wrapped (1+ wrapped)))
            (widget-use-overlay-change
             (goto-char (next-overlay-change (point))))
            (t
             (forward-char 1)))
-      (and (eq pos (point))
+      (and (= wrapped 2)
           (eq arg number)
           (error "No buttons or fields found"))
       (let ((new (widget-tabable-at)))
@@ -1025,12 +1026,13 @@ ARG may be negative to move backward."
     ;; Backward.
     (while (< arg 0)
       (cond ((bobp)
-            (goto-char (point-max)))
+            (goto-char (point-max))
+            (setq wrapped (1+ wrapped)))
            (widget-use-overlay-change
             (goto-char (previous-overlay-change (point))))
            (t
             (backward-char 1)))
-      (and (eq pos (point))
+      (and (= wrapped 2)
           (eq arg number)
           (error "No buttons or fields found"))
       (let ((new (widget-tabable-at)))