Function: widget-move

widget-move is a byte-compiled function defined in wid-edit.el.gz.

Signature

(widget-move ARG &optional SUPPRESS-ECHO)

Documentation

Move point to the ARG next field or button.

ARG may be negative to move backward. When the second optional argument is non-nil, nothing is shown in the echo area.

Source Code

;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-move (arg &optional suppress-echo)
  "Move point to the ARG next field or button.
ARG may be negative to move backward.
When the second optional argument is non-nil,
nothing is shown in the echo area."
  (let ((wrapped 0)
	(number arg)
	(old (widget-tabable-at)))
    ;; Forward.
    (while (> arg 0)
      (cond ((eobp)
	     (goto-char (point-min))
	     (setq wrapped (1+ wrapped)))
	    (widget-use-overlay-change
	     (goto-char (next-overlay-change (point))))
	    (t
	     (forward-char 1)))
      (and (= wrapped 2)
	   (eq arg number)
	   (error "No buttons or fields found"))
      (let ((new (widget-tabable-at)))
	(when new
	  (unless (eq new old)
	    (setq arg (1- arg))
	    (setq old new)))))
    ;; Backward.
    (while (< arg 0)
      (cond ((bobp)
	     (goto-char (point-max))
	     (setq wrapped (1+ wrapped)))
	    (widget-use-overlay-change
	     (goto-char (previous-overlay-change (point))))
	    (t
	     (backward-char 1)))
      (and (= wrapped 2)
	   (eq arg number)
	   (error "No buttons or fields found"))
      (let ((new (widget-tabable-at)))
	(when new
	  (unless (eq new old)
	    (setq arg (1+ arg))))))
    (let ((new (widget-tabable-at)))
      (while (eq (widget-tabable-at) new)
	(backward-char)))
    (forward-char))
  (unless suppress-echo
    (widget-echo-help (point)))
  (run-hooks 'widget-move-hook))