changeset 48842:66dc7b1b4b00

(widget-move): Don't loop infinitely when there is no field or button.
author Andreas Schwab <schwab@suse.de>
date Sat, 14 Dec 2002 14:25:53 +0000
parents 24ee0d16711c
children d39927a676f3
files lisp/wid-edit.el
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/wid-edit.el	Sat Dec 14 00:12:21 2002 +0000
+++ b/lisp/wid-edit.el	Sat Dec 14 14:25:53 2002 +0000
@@ -1002,19 +1002,20 @@
   "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 @@
     ;; 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)))