Function: evil-forward-nearest
evil-forward-nearest is a byte-compiled function defined in
evil-common.el.
Signature
(evil-forward-nearest COUNT &rest FORWARDS)
Documentation
Move point forward to the first of several motions.
FORWARDS is a list of forward motion functions (i.e. each moves point forward to the next end of a text object (if passed a +1) or backward to the preceeding beginning of a text object (if passed a -1)). This function calls each of these functions once and moves point to the nearest of the resulting positions. If COUNT is positive point is moved forward COUNT times, if negative point is moved backward -COUNT times.
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
(defun evil-forward-nearest (count &rest forwards)
"Move point forward to the first of several motions.
FORWARDS is a list of forward motion functions (i.e. each moves
point forward to the next end of a text object (if passed a +1)
or backward to the preceeding beginning of a text object (if
passed a -1)). This function calls each of these functions once
and moves point to the nearest of the resulting positions. If
COUNT is positive point is moved forward COUNT times, if negative
point is moved backward -COUNT times."
(evil-motion-loop (dir (or count 1))
(let ((pnt (point))
(nxt (if (< dir 0) (point-min) (point-max))))
(dolist (fwd forwards)
(goto-char pnt)
(ignore-errors
(evil-with-restriction
(when (< dir 0)
(save-excursion
(goto-char nxt)
(line-beginning-position 0)))
(when (> dir 0)
(save-excursion
(goto-char nxt)
(line-end-position 2)))
(and (zerop (funcall fwd dir))
(/= (point) pnt)
(if (< dir 0) (> (point) nxt) (< (point) nxt))
(setq nxt (point))))))
(goto-char nxt))))