summaryrefslogtreecommitdiff
path: root/doc/lispref/parsing.texi
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2022-11-15 21:30:13 -0800
committerYuan Fu <casouri@gmail.com>2022-11-16 14:40:40 -0800
commit75b65b3f67eb9a4e5722780cb915b880e667d674 (patch)
tree19c3884f0b92a25f8f02a232004d3999288bd8ee /doc/lispref/parsing.texi
parent306e49285a04c02f0a575a7d7b2f82eeb032c86b (diff)
downloademacs-75b65b3f67eb9a4e5722780cb915b880e667d674.tar.gz
emacs-75b65b3f67eb9a4e5722780cb915b880e667d674.tar.bz2
emacs-75b65b3f67eb9a4e5722780cb915b880e667d674.zip
; Add documentation for tree-sitter parser after-change notifiers
* doc/lispref/parsing.texi (Using Parser): Update manual. * lisp/treesit.el (treesit): Add shordocs. * src/treesit.c: Augment docstrings.
Diffstat (limited to 'doc/lispref/parsing.texi')
-rw-r--r--doc/lispref/parsing.texi39
1 files changed, 39 insertions, 0 deletions
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 0f4a004ee90..2ea229ec907 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -478,6 +478,45 @@ This function parses @var{string} using @var{language}, and returns
the root node of the generated syntax tree.
@end defun
+@cindex parse-tree update callback, tree-sitter
+@cindex parse-tree after-change notifer, tree-sitter
+@cindex tree-sitter parse-tree update callback
+@cindex tree-sitter parse-tree after-change notifer
+@heading Be notified by changes to the parse tree
+
+A Lisp program might want to be notified of affected text of a
+incremental parse. For example, inserting a closing comment token
+converts text before that closing comment token into comments. Even
+though those text are not directly edited, they are changed
+nevertheless.
+
+Emacs lets a Lisp program to register callback functions
+(@dfn{notifiers}) for this kind of changes. A notifier function takes
+2 arguments: @var{ranges} and @var{parser}. @var{ranges} is a list of
+cons of the form @w{@code{(@var{start} . @var{end})}}, where
+@var{start} and @var{end} marks the start and end position of a range.
+@var{parser} is the parser issuing the notification.
+
+Every time a parser reparses a buffer, it compares the old and new
+parse-tree, computes the ranges in which nodes have changed, and
+passes the ranges to notifier functions.
+
+@defun treesit-parser-add-notifier parser function
+This function adds @var{function} to @var{parser}'s after-change
+notifier functions list. @var{function} must be a function symbol,
+rather than a lambda function.
+@end defun
+
+@defun treesit-parser-remove-notifier parser function
+This function removes @var{function} from @var{parser}'s after-change
+notifier functions list. @var{function} must be a function symbol,
+rather than a lambda function.
+@end defun
+
+@defun treesit-parser-notifiers parser
+This function returns @var{parser}'s notifier function list.
+@end defun
+
@node Retrieving Nodes
@section Retrieving Nodes
@cindex retrieve node, tree-sitter