@@ -1539,22 +1539,35 @@ the specific error. You can use @code{treesit-query-validate} to
1539
1539
validate and debug the query.
1540
1540
@end defun
1541
1541
1542
- @defun treesit-query-language query
1543
- This function returns the language of @var {query }.
1544
- @end defun
1542
+ @findex treesit-query-language
1543
+ @findex treesit-query-expand
1544
+ @findex treesit-pattern-expand
1545
+ @findex treesit-query-valid-p
1546
+ There are some additional functions for queries:
1547
+ @code {treesit-query-language } returns the language of a query;
1548
+ @code {treesit-query-valid-p } checks whether a query is valid;
1549
+ @code {treesit-query-expand } converts a s-expression query into the
1550
+ string format; and @code {treesit-pattern-expand } converts a pattern.
1551
+
1552
+ @findex treesit-query-first-valid
1553
+ Tree-sitter grammars change overtime. To support multiple possible
1554
+ versions of a grammar, a Lisp program can use
1555
+ @code {treesit-query-first-valid } to pick the right query to use. For
1556
+ example, if a grammar has a @code {(defun) } node in one version, and
1557
+ later renamed it to @code {(function_definition) }, a Lisp program can use
1545
1558
1546
- @defun treesit-query-expand query
1547
- This function converts the s-expression @var {query } into the string
1548
- format.
1549
- @end defun
1559
+ @example
1560
+ @group
1561
+ (treesit-query-first-valid 'lang
1562
+ '((defun) @defun )
1563
+ '((function_definition) @defun ))
1564
+ @end group
1565
+ @end example
1550
1566
1551
- @defun treesit-pattern-expand pattern
1552
- This function converts the s-expression @var {pattern } into the string
1553
- format.
1554
- @end defun
1567
+ to support both versions of the grammar.
1555
1568
1556
- For more details, read the tree-sitter project's documentation about
1557
- pattern-matching, which can be found at
1569
+ For more details, consider reading the tree-sitter project's
1570
+ documentation about pattern-matching. The documentation can be found at
1558
1571
@uref {https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries }.
1559
1572
1560
1573
@node User-defined Things
0 commit comments