Function: forward-button
forward-button is an interactive and byte-compiled function defined in
button.el.gz.
Signature
(forward-button N &optional WRAP DISPLAY-MESSAGE NO-ERROR)
Documentation
Move to the Nth next button, or Nth previous button if N is negative.
If N is 0, move to the start of any button at point.
If WRAP is non-nil, moving past either end of the buffer continues from the
other end.
If DISPLAY-MESSAGE is non-nil, the button's help-echo property
is displayed. Any button with a non-nil skip property is
skipped over.
If NO-ERROR, return nil if no further buttons could be found instead of erroring out.
Returns the button found.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/button.el.gz
(defun forward-button (n &optional wrap display-message no-error)
"Move to the Nth next button, or Nth previous button if N is negative.
If N is 0, move to the start of any button at point.
If WRAP is non-nil, moving past either end of the buffer continues from the
other end.
If DISPLAY-MESSAGE is non-nil, the button's `help-echo' property
is displayed. Any button with a non-nil `skip' property is
skipped over.
If NO-ERROR, return nil if no further buttons could be found
instead of erroring out.
Returns the button found."
(interactive "p\nd\nd")
(let (button)
(if (zerop n)
;; Move to start of current button
(if (setq button (button-at (point)))
(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)))
opoint fail)
(setq n (abs n))
(setq button t) ; just to start the loop
(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)
(unless no-error
(user-error (if wrap "No buttons!" "No more buttons")))
(let ((msg (and display-message (button--help-echo button))))
(when msg
(message "%s" msg)))
button)))