Function: evil-ex-search-full-pattern
evil-ex-search-full-pattern is a byte-compiled function defined in
evil-search.el.
Signature
(evil-ex-search-full-pattern STRING COUNT DIRECTION)
Documentation
Search for a full search pattern STRING in DIRECTION.
This function splits STRING into "pattern/offset/;next-pattern"
parts and performs the search in DIRECTION which must be either
forward or backward. The first search is repeated COUNT times. If
the pattern part of STRING is empty, the last global pattern stored in
evil-ex-search-pattern is used instead if in addition the offset
part is nil (i.e. no pattern/offset separator), the last global offset
stored in evil-ex-search-offset is used as offset. The current match
data will correspond to the last successful match. This function
returns a triplet (RESULT PATTERN OFFSET) where RESULT is one of
t the search was successful without wrapping
wrap the search was successful with wrapping
empty-pattern the last pattern was empty
nil the search was unsuccessful
and PATTERN and OFFSET are the last pattern and offset this function searched for. Note that this function does not handle any error conditions.
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-search.el
(defun evil-ex-search-full-pattern (string count direction)
"Search for a full search pattern STRING in DIRECTION.
This function splits STRING into \"pattern/offset/;next-pattern\"
parts and performs the search in DIRECTION which must be either
`forward' or `backward'. The first search is repeated COUNT times. If
the pattern part of STRING is empty, the last global pattern stored in
`evil-ex-search-pattern' is used instead if in addition the offset
part is nil (i.e. no pattern/offset separator), the last global offset
stored in `evil-ex-search-offset' is used as offset. The current match
data will correspond to the last successful match. This function
returns a triplet (RESULT PATTERN OFFSET) where RESULT is one of
t the search was successful without wrapping
`wrap' the search was successful with wrapping
`empty-pattern' the last pattern was empty
nil the search was unsuccessful
and PATTERN and OFFSET are the last pattern and offset this
function searched for. Note that this function does not handle
any error conditions."
(setq count (or count 1))
(catch 'done
(while t
(let* ((res (evil-ex-split-search-pattern string direction))
(pat (pop res))
(offset (pop res))
(next-pat (pop res))
(orig-pat pat)
new-dir repeat-last wrapped)
(if (> (length pat) 0)
(setq pat (evil-ex-make-search-pattern pat))
;; use last pattern if no new pattern has been specified
(setq pat (or evil-ex-search-pattern
(throw 'done (list 'empty-pattern pat offset)))
offset (or offset evil-ex-search-offset)))
(while (> count 0)
(when (eq (or (evil-ex-find-next pat direction
(not evil-search-wrap))
(throw 'done (list nil pat offset)))
'wrapped)
(setq wrapped t))
(setq count (1- count)))
(cond
;; no next pattern, search complete
((zerop (length next-pat))
(evil-ex-search-goto-offset offset)
(throw 'done (list (if wrapped 'wrap t) pat offset)))
;; single \"?\" or \"/\" means repeat last pattern and finish
((= 1 (length next-pat))
(evil-ex-search-goto-offset offset)
(setq new-dir (if (string= "/" next-pat) 'forward 'backward)
count (if (eq direction new-dir) 1 2)
string orig-pat
direction new-dir))
;; next non-empty pattern, next search iteration
(t (evil-ex-search-goto-offset offset)
(setq new-dir (if (= (aref next-pat 0) ?/) 'forward 'backward)
repeat-last (when (<= 2 (length next-pat))
(member (substring next-pat 0 2) '("//" "??")))
count (if (or (eq direction new-dir) (not repeat-last)) 1 2)
string (if repeat-last
(concat orig-pat (substring next-pat 1))
(substring next-pat 1))
direction new-dir)))))))