Function: evil-search-function

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

Signature

(evil-search-function &optional FORWARD REGEXP-P WRAP PREDICATE)

Documentation

Return a search function.

If FORWARD is nil, search backward, otherwise forward. If REGEXP-P is non-nil, the input is a regular expression. If WRAP is non-nil, the search wraps around the top or bottom of the buffer. If PREDICATE is non-nil, it must be a function accepting two arguments: the bounds of a match, returning non-nil if that match is acceptable.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-search.el
(defun evil-search-function (&optional forward regexp-p wrap predicate)
  "Return a search function.
If FORWARD is nil, search backward, otherwise forward.
If REGEXP-P is non-nil, the input is a regular expression.
If WRAP is non-nil, the search wraps around the top or bottom
of the buffer.
If PREDICATE is non-nil, it must be a function accepting two
arguments: the bounds of a match, returning non-nil if that match is
acceptable."
  `(lambda (string &optional bound noerror count)
     (let ((start (point))
           (search-fun ',(if regexp-p
                             (if forward
                                 're-search-forward
                               're-search-backward)
                           (if forward
                               'search-forward
                             'search-backward)))
           result)
       (setq result (evil-search-with-predicate
                     search-fun ,predicate string
                     bound ,(if wrap t 'noerror) count))
       (when (and ,wrap (null result))
         (goto-char ,(if forward '(point-min) '(point-max)))
         (unwind-protect
             (setq result (evil-search-with-predicate
                           search-fun ,predicate string bound noerror count))
           (unless result
             (goto-char start))))
       result)))