Function: combobulate-query-find-test-function
combobulate-query-find-test-function is a natively compiled function
defined in combobulate-navigation.el.
Signature
(combobulate-query-find-test-function TERM)
Source Code
;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-navigation.el
(defun combobulate-query-find-test-function (term)
(let ((term-type (combobulate-query--term-type term)))
(cond
;; wildcard -- (_) and _ -- query terms are
;; handled differently from explicit nodes:
;;
;; (_) wildcards match any named node.
;;
;; _ wildcards match both anonymous and named
;; alike.
;;
;; Combined with `*' or `+' and it'll greedily
;; consume all possible matches, as per their
;; respective rules.
;;
;; Ordinarily, we'd recurse into the subquery
;; of a named cons cell node query to match;
;; this is not required here at all. Simply
;; return the item itself to match.
((eq term-type 'named-wildcard)
(lambda (child _) (if (combobulate-node-named-p child)
(cons 'match (cons (list child) nil))
(cons 'no-match (cons nil nil)))))
((eq term-type 'wildcard)
(lambda (child _) (cons 'match (cons (list child) nil))))
;; strings are handled by equality checking
;; the node text against `sub-query'.
((eq term-type 'anonymous)
(lambda (child _)
(if (equal term (combobulate-node-text child))
(cons 'match (cons (list child) nil))
(cons 'no-match (cons nil nil)))))
;; a single standalone (not in a cons cell)
;; symbol is usually the first symbol in a
;; query as it indicates the parent node
;; against which any children must match.
((eq term-type 'node)
(lambda (child _)
(if (eq term (combobulate-query--node-type child))
(cons 'match (cons (list child) nil))
(cons 'no-match (cons nil nil)))))
;; For everything else, apply recursion.
(t (lambda (child term)
(if-let (result (combobulate-query-search-1 child term))
(cons 'match (cons (list result) nil))
(cons 'no-match (cons nil nil))))))))