Function: evil-match
evil-match is a byte-compiled function defined in evil-commands.el.
Signature
(evil-match DIRECTION COUNT)
Documentation
Find COUNTth next match in DIRECTION.
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
(defun evil-match (direction count)
"Find COUNTth next match in DIRECTION."
(defvar evil-search-module)
(unless (eq evil-search-module 'evil-search)
(user-error "Match text objects only work with Evil search module"))
(let ((pnt (point))
(count (abs count)) ; Undo effect of evil-visual-direction
(evil-ex-search-direction 'backward)
(visual-state (evil-visual-state-p))
on-start-match in-match on-end-match)
(save-excursion
(unless (eobp) (forward-char)) ; If on start of a match, stay there
(evil-ex-search 1)
(setq on-start-match (= evil-ex-search-match-beg pnt)
in-match (<= evil-ex-search-match-beg pnt (1- evil-ex-search-match-end))
on-end-match (= (1- evil-ex-search-match-end) pnt)
evil-ex-search-direction direction)
(cond
((and visual-state on-start-match (eq 'backward direction))
(evil-ex-search count))
((and visual-state on-end-match (eq 'forward direction))
(evil-ex-search count))
((or in-match (eq 'backward direction))
(evil-ex-search (1- count)))
(t (evil-ex-search count)))
(setq pnt (point)))
(goto-char pnt)
(cond
((evil-normal-state-p)
(evil-visual-select evil-ex-search-match-beg
evil-ex-search-match-end
'inclusive
(pcase direction ('forward +1) ('backward -1))
t)
(list evil-ex-search-match-beg evil-ex-search-match-end))
((and visual-state (eq 'forward direction))
(goto-char (1- evil-ex-search-match-end)))
((and visual-state (eq 'backward direction))
(goto-char evil-ex-search-match-beg))
;; e.g. operator pending...
(t (list evil-ex-search-match-beg evil-ex-search-match-end)))))