# HG changeset patch # User Chong Yidong # Date 1217542545 0 # Node ID a9fd3177343b9c2fd83773ddec3f009a94ba8d1d # Parent 75a85b06acb3461ec7f52ef628ba26d7e0fb9651 (forward-button): Avoid infloop. diff -r 75a85b06acb3 -r a9fd3177343b lisp/button.el --- a/lisp/button.el Thu Jul 31 22:15:18 2008 +0000 +++ b/lisp/button.el Thu Jul 31 22:15:45 2008 +0000 @@ -437,15 +437,22 @@ (goto-char (button-start button))) ;; Move to Nth next button (let ((iterator (if (> n 0) #'next-button #'previous-button)) - (wrap-start (if (> n 0) (point-min) (point-max)))) + (wrap-start (if (> n 0) (point-min) (point-max))) + opoint fail) (setq n (abs n)) (setq button t) ; just to start the loop - (while (and (> n 0) button) + (while (and (null fail) (> n 0) button) (setq button (funcall iterator (point))) (when (and (not button) wrap) (setq button (funcall iterator wrap-start t))) (when button (goto-char (button-start button)) + ;; Avoid looping forever (e.g., if all the buttons have + ;; the `skip' property). + (cond ((null opoint) + (setq opoint (point))) + ((= opoint (point)) + (setq fail t))) (unless (button-get button 'skip) (setq n (1- n))))))) (if (null button)