This commit only adds the new function, the fix for the bug is
in the next commit.
* doc/lispref/parsing.texi (Using Parser): Add docs.
* lisp/treesit.el (treesit): Add shortdoc.
* src/treesit.c (treesit_get_affected_ranges): New function
extracted from treesit_call_after_change_functions.
(treesit_call_after_change_functions): Extract out.
(treesit_ensure_parsed): Return affected regions.
(Ftreesit_parser_changed_regions): New function that returns the
affected regions.
(cherry picked from commit
564b947745b2a685edcd93eb8f0d8825352030b8)
This function returns the list of @var{parser}'s notifier functions.
@end defun
+A lisp program can also choose to force a parser to reparse and get the
+changed regions immediately with @code{treesit-parser-changed-regions}.
+
+@defun treesit-parser-changed-regions parser
+This function force @var{parser} to reparse, and return the affected
+regions: a list of @w{@code{(@var{start} . @var{end})}}. If the parser
+has nothing new to reparse, or the affected regions are empty,
+@code{nil} is returned.
+@end defun
+
+
@heading Substitute parser for another language
@cindex remap language grammar, tree-sitter
@cindex replace language grammar, tree-sitter
(treesit-parser-language
:no-eval (treesit-parser-language parser)
:eg-result c)
+ (treesit-parser-tag
+ :no-eval (treesit-parser-tag parser)
+ :eg-result 'embeded)
+ (treesit-parser-changed-regions
+ :no-eval (treesit-parser-changed-regions parser)
+ :eg-result '((1 . 10) (24 . 58)))
+
+ (treesit-parser-embed-level
+ :no-eval (treesit-parser-embed-level parser)
+ :eg-result 1)
+ (treesit-parser-set-embed-level
+ :no-eval (treesit-parser-set-embed-level parser 1))
+
(treesit-parser-add-notifier)
(treesit-parser-remove-notifier)
(treesit-parser-notifiers