Function: evil-ex-find-next

evil-ex-find-next is a byte-compiled function defined in evil-search.el.

Signature

(evil-ex-find-next &optional PATTERN DIRECTION NOWRAP)

Documentation

Search for the next occurrence of the PATTERN in DIRECTION.

PATTERN must be created using evil-ex-make-pattern, DIRECTION is either forward or backward. If NOWRAP is non-nil, the search does not wrap at buffer boundaries. Furthermore this function only searches invisible text if search-invisible is t. If PATTERN is not specified the current global pattern evil-ex-search-pattern and if DIRECTION is not specified the current global direction evil-ex-search-direction is used. This function returns t if the search was successful, nil if it was unsuccessful and wrapped if the search was successful but wrapped around at buffer boundaries.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-search.el
(defun evil-ex-find-next (&optional pattern direction nowrap)
  "Search for the next occurrence of the PATTERN in DIRECTION.
PATTERN must be created using `evil-ex-make-pattern', DIRECTION is
either `forward' or `backward'. If NOWRAP is non-nil, the search does
not wrap at buffer boundaries. Furthermore this function only searches
invisible text if `search-invisible' is t. If PATTERN is not specified
the current global pattern `evil-ex-search-pattern' and if DIRECTION
is not specified the current global direction
`evil-ex-search-direction' is used. This function returns t if the
search was successful, nil if it was unsuccessful and `wrapped' if the
search was successful but wrapped around at buffer boundaries."
  (setq pattern (or pattern evil-ex-search-pattern)
        direction (or direction evil-ex-search-direction))
  (unless (and pattern (evil-ex-pattern-regex pattern))
    (signal 'search-failed (list "No search pattern")))
  (catch 'done
    (let (wrapped)
      (while t
        (if (evil-ex-search-find-next-pattern pattern direction)
            (when (or (eq search-invisible t)
                      (not (isearch-range-invisible
                            (match-beginning 0) (match-end 0))))
              ;; Successful search and not invisible
              (throw 'done (if wrapped 'wrapped t)))
          ;; Unsuccessful search
          (if nowrap
              (throw 'done nil)
            (setq nowrap t
                  wrapped t)
            (goto-char (if (eq direction 'forward)
                           (point-min)
                         (point-max)))))))))