]> git.eshelyaron.com Git - emacs.git/commitdiff
Add treesit-query-compile to manual
authorYuan Fu <casouri@gmail.com>
Tue, 14 Jun 2022 21:17:17 +0000 (14:17 -0700)
committerYuan Fu <casouri@gmail.com>
Tue, 14 Jun 2022 21:17:17 +0000 (14:17 -0700)
* doc/lispref/parsing.texi: Add treesit-query-compile.

doc/lispref/parsing.texi

index c6909da00284fab25e9737ab45aa998e14aae915..1c4a7805a31f752d495d4fc2e4043c5808bbb2e2 100644 (file)
@@ -804,10 +804,10 @@ name @code{biexp}:
 Now we can introduce the query functions.
 
 @defun treesit-query-capture node query &optional beg end
-This function matches patterns in @var{query} in @var{node}.
-Argument @var{query} can be a either string or a s-expression.  For
-now, we focus on the string syntax; s-expression syntax is described
-at the end of the section.
+This function matches patterns in @var{query} in @var{node}.  Argument
+@var{query} can be either a string, a s-expression, or a compiled
+query object.  For now, we focus on the string syntax; s-expression
+syntax and compiled query are described at the end of the section.
 
 The function returns all captured nodes in a list of
 @code{(@var{capture_name} . @var{node})}.  If @var{beg} and @var{end}
@@ -1101,10 +1101,26 @@ is written in s-expression as
 @end group
 @end example
 
+@heading Compiling queries
+
+If a query will be used repeatedly, especially in tight loops, it is
+important to compile that query, because a compiled query is much
+faster than an uncompiled one.  A compiled query can be used anywhere
+a query is accepted.
+
+@defun treesit-query-compile language query
+This function compiles @var{query} for @var{language} into a compiled
+query object and returns it.
+@end defun
+
 @defun treesit-expand-query query
 This function expands the s-expression @var{query} into a string
-query.  It is usually a good idea to expand the s-expression patterns
-into strings for font-lock queries since they are called repeatedly.
+query.
+@end defun
+
+@defun treesit-expand-pattern pattern
+This function expands the s-expression @var{pattern} into a string
+pattern.
 @end defun
 
 Finally, tree-sitter project's documentation about