Function: evil--ex-syntactic-context
evil--ex-syntactic-context is a byte-compiled function defined in
evil-ex.el.
Signature
(evil--ex-syntactic-context &optional (POS (point)) (TREE (save-excursion (goto-char (minibuffer-prompt-end)) (evil-ex-parse nil t))))
Documentation
Return the syntactical context in TREE of the character at POS.
POS defaults to the current position of point.
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-ex.el
(cl-defun evil--ex-syntactic-context
(&optional (pos (point))
(tree (save-excursion (goto-char (minibuffer-prompt-end))
(evil-ex-parse nil t)))
&aux i result)
"Return the syntactical context in TREE of the character at POS.
POS defaults to the current position of point."
;; Iterate over syntax tree leaves (i.e. the strings), and return
;; the path to the leaf containing the cursor. Or, if not found,
;; e.g. because of trailing whitespace, the leaf at most one char
;; past the rightmost non-empty string.
(cl-labels
((traverse
(node path)
(while (and (consp node) (symbolp (car node)))
(push (cons (pop node) i) path))
(if (listp node)
(dolist (child node) (traverse child path))
;; NODE is the end position of a parsed string
(when (>= node pos) (cl-return-from evil--ex-syntactic-context path))
(when (or (null result) (> node i))
(setq i node
result path)))))
(traverse tree ()))
result)