1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Make treesit-search-forward-goto accept a NODE argument

With NODE argument we can do

(setq node (treesit-search-forward-goto node))

And we can choose what node to pass to it (maybe we want to pass it
the largest node at point, rather than the smallest node, and in case
of multiple parsers, we can choose which parser to use).

* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* lisp/treesit.el (treesit-search-forward-goto): Accept a NODE
argument.
This commit is contained in:
Yuan Fu 2022-10-23 18:29:02 -07:00
parent 524d10c86b
commit 6cf2a9c55d
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 19 additions and 15 deletions

View file

@ -702,10 +702,14 @@ answering questions like ``what is the first node after @var{start} in
the buffer that satisfies some condition?''
@end defun
@defun treesit-search-forward-goto predicate &optional start backward all
This function moves point to the start or end of the next node in
the buffer that matches @var{predicate}. If @var{start} is
non-nil, stop at the beginning rather than the end of a node.
@defun treesit-search-forward-goto node predicate &optional start backward all
This function moves point to the start or end of the next node after
@var{node} in the buffer that matches @var{predicate}. If @var{start}
is non-nil, stop at the beginning rather than the end of a node.
This function guarantees that the matched node it returns makes
progress in terms of buffer position: the start/end position of the
returned node is always greater than that of @var{node}.
Arguments @var{predicate}, @var{backward} and @var{all} are the same
as in @code{treesit-search-forward}.