Function: evil-search-with-predicate

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

Signature

(evil-search-with-predicate SEARCH-FUN PRED STRING BOUND NOERROR COUNT)

Documentation

Execute a search with a predicate function.

SEARCH-FUN is a search function (e.g. re-search-forward) and PREDICATE is a two-argument function satisfying the interface of isearch-filter-predicate, or nil. STRING, BOUND, NOERROR and COUNT are passed unchanged to SEARCH-FUN. The first match satisfying the predicate (or nil) is returned.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-search.el
(defun evil-search-with-predicate (search-fun pred string bound noerror count)
  "Execute a search with a predicate function.
SEARCH-FUN is a search function (e.g. `re-search-forward') and
PREDICATE is a two-argument function satisfying the interface of
`isearch-filter-predicate', or `nil'.  STRING, BOUND, NOERROR and
COUNT are passed unchanged to SEARCH-FUN.  The first match
satisfying the predicate (or `nil') is returned."
  (catch 'done
    (while t
      (let ((result (funcall search-fun string bound noerror count)))
        (cond
         ((not result) (throw 'done nil))
         ((not pred) (throw 'done result))
         ((funcall pred (match-beginning 0) (match-end 0)) (throw 'done result)))))))