aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-07-31 22:15:45 +0000
committerChong Yidong2008-07-31 22:15:45 +0000
commitf46a36427c209de792a5625bee22b2829a7ba56e (patch)
tree0e8ef9b80d9afbca470f98a2b0e1d66918826bcc
parent60f4c0c8bab711e474a63f763d227248b35c2df4 (diff)
downloademacs-f46a36427c209de792a5625bee22b2829a7ba56e.tar.gz
emacs-f46a36427c209de792a5625bee22b2829a7ba56e.zip
(forward-button): Avoid infloop.
-rw-r--r--lisp/button.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/lisp/button.el b/lisp/button.el
index 6a558af445a..b474a74da9c 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -437,15 +437,22 @@ Returns the button found."
437 (goto-char (button-start button))) 437 (goto-char (button-start button)))
438 ;; Move to Nth next button 438 ;; Move to Nth next button
439 (let ((iterator (if (> n 0) #'next-button #'previous-button)) 439 (let ((iterator (if (> n 0) #'next-button #'previous-button))
440 (wrap-start (if (> n 0) (point-min) (point-max)))) 440 (wrap-start (if (> n 0) (point-min) (point-max)))
441 opoint fail)
441 (setq n (abs n)) 442 (setq n (abs n))
442 (setq button t) ; just to start the loop 443 (setq button t) ; just to start the loop
443 (while (and (> n 0) button) 444 (while (and (null fail) (> n 0) button)
444 (setq button (funcall iterator (point))) 445 (setq button (funcall iterator (point)))
445 (when (and (not button) wrap) 446 (when (and (not button) wrap)
446 (setq button (funcall iterator wrap-start t))) 447 (setq button (funcall iterator wrap-start t)))
447 (when button 448 (when button
448 (goto-char (button-start button)) 449 (goto-char (button-start button))
450 ;; Avoid looping forever (e.g., if all the buttons have
451 ;; the `skip' property).
452 (cond ((null opoint)
453 (setq opoint (point)))
454 ((= opoint (point))
455 (setq fail t)))
449 (unless (button-get button 'skip) 456 (unless (button-get button 'skip)
450 (setq n (1- n))))))) 457 (setq n (1- n)))))))
451 (if (null button) 458 (if (null button)