]> git.eshelyaron.com Git - emacs.git/commit
Support more predicates in tree-sitter search functions
authorYuan Fu <casouri@gmail.com>
Thu, 13 Apr 2023 22:03:05 +0000 (15:03 -0700)
committerYuan Fu <casouri@gmail.com>
Thu, 13 Apr 2023 22:08:51 +0000 (15:08 -0700)
commit361c5fc2d8e52d70aa58956c57eaef9495881197
tree31c1573058144e6a70515b0198f1c2e7cf34e8bb
parenta5eb9f6ad4e6f5a2819b540a477f1e889f6ef355
Support more predicates in tree-sitter search functions

Right now we support regexp strings and predicate functions for the
PRED argument. This change adds support for (not ...) (or ...)
and (regexp . pred) predicates.

I still need to find a place to document the supported shapes of a
predicate.

* src/treesit.c (treesit_traverse_validate_predicate): New function.
(treesit_traverse_match_predicate): Support more predicate shapes.
(treesit_search_dfs):
(treesit_search_forward)
(treesit_build_sparse_tree): Fix docstring (unrelated to this change).
(Ftreesit_search_subtree)
(Ftreesit_search_forward)
(Ftreesit_induce_sparse_tree): Use the new function to validate
predicate shape.
(syms_of_treesit): New error Qtreesit_invalid_predicate.

* test/src/treesit-tests.el:
(treesit--ert-search-setup): Add edebug declaration.
(treesit-search-forward-predicate)
(treesit-search-forward-predicate-invalid-predicate): New tests.
src/treesit.c
test/src/treesit-tests.el