aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2022-10-17 10:54:55 +0300
committerEli Zaretskii2022-10-17 10:54:55 +0300
commit260e47e9a3c9b3baecef81e69c218989dc0cd7a4 (patch)
treef491a6a6adcf626423797c5103a74d8cd650e569 /src
parentc6dce90d7e57486db687606bffd92d580a7d25ca (diff)
downloademacs-260e47e9a3c9b3baecef81e69c218989dc0cd7a4.tar.gz
emacs-260e47e9a3c9b3baecef81e69c218989dc0cd7a4.zip
; Fix doc strings in treesit.c
* src/treesit.c (Ftreesit_language_version) (Ftreesit_parser_create, Ftreesit_parser_delete) (Ftreesit_parser_language, Ftreesit_parser_set_included_ranges) (Ftreesit_parser_included_ranges, Ftreesit_node_start) (Ftreesit_node_end, Ftreesit_node_parent, Ftreesit_node_child) (Ftreesit_node_check, Ftreesit_node_field_name_for_child) (Ftreesit_node_child_by_field_name, Ftreesit_node_next_sibling) (Ftreesit_node_prev_sibling, Ftreesit_node_first_child_for_pos) (Ftreesit_node_descendant_for_range, Ftreesit_pattern_expand) (Ftreesit_query_expand, Ftreesit_query_compile) (Ftreesit_query_capture, Ftreesit_search_subtree) (Ftreesit_search_forward, Ftreesit_induce_sparse_tree) (syms_of_treesit): Doc string fixes.
Diffstat (limited to 'src')
-rw-r--r--src/treesit.c172
1 files changed, 94 insertions, 78 deletions
diff --git a/src/treesit.c b/src/treesit.c
index 1170a2fa7b4..10af37981b4 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -611,8 +611,12 @@ DEFUN ("treesit-language-version",
611 Ftreesit_language_version, 611 Ftreesit_language_version,
612 Streesit_language_version, 612 Streesit_language_version,
613 0, 1, 0, 613 0, 1, 0,
614 doc: /* Return the language version of tree-sitter library. 614 doc: /* Return the language ABI version of the tree-sitter library.
615If MIN-COMPATIBLE is non-nil, return the minimal compatible version. */) 615
616By default, report the latest ABI version supported by the library for
617loading language support modules. The library is backward-compatible
618with language modules which use older ABI versions; if MIN-COMPATIBLE
619is non-nil, return the oldest compatible ABI version. */)
616 (Lisp_Object min_compatible) 620 (Lisp_Object min_compatible)
617{ 621{
618 if (NILP (min_compatible)) 622 if (NILP (min_compatible))
@@ -1104,10 +1108,12 @@ DEFUN ("treesit-parser-create",
1104 1, 3, 0, 1108 1, 3, 0,
1105 doc: /* Create and return a parser in BUFFER for LANGUAGE. 1109 doc: /* Create and return a parser in BUFFER for LANGUAGE.
1106 1110
1107The parser is automatically added to BUFFER's `treesit-parser-list'. 1111The parser is automatically added to BUFFER's parser list, as
1108LANGUAGE is a language symbol. If BUFFER is nil, use the current 1112returned by `treesit-parser-list'.
1109buffer. If BUFFER already has a parser for LANGUAGE, return that 1113LANGUAGE is a language symbol. If BUFFER is nil or omitted, it
1110parser. If NO-REUSE is non-nil, always create a new parser. */) 1114defaults to the current buffer. If BUFFER already has a parser for
1115LANGUAGE, return that parser, but if NO-REUSE is non-nil, always
1116create a new parser. */)
1111 (Lisp_Object language, Lisp_Object buffer, Lisp_Object no_reuse) 1117 (Lisp_Object language, Lisp_Object buffer, Lisp_Object no_reuse)
1112{ 1118{
1113 ts_initialize (); 1119 ts_initialize ();
@@ -1158,7 +1164,8 @@ parser. If NO-REUSE is non-nil, always create a new parser. */)
1158DEFUN ("treesit-parser-delete", 1164DEFUN ("treesit-parser-delete",
1159 Ftreesit_parser_delete, Streesit_parser_delete, 1165 Ftreesit_parser_delete, Streesit_parser_delete,
1160 1, 1, 0, 1166 1, 1, 0,
1161 doc: /* Delete PARSER from its buffer. */) 1167 doc: /* Delete PARSER from its buffer's parser list.
1168See `treesit-parser-list' for the buffer's parser list. */)
1162 (Lisp_Object parser) 1169 (Lisp_Object parser)
1163{ 1170{
1164 ts_check_parser (parser); 1171 ts_check_parser (parser);
@@ -1213,7 +1220,7 @@ DEFUN ("treesit-parser-buffer",
1213DEFUN ("treesit-parser-language", 1220DEFUN ("treesit-parser-language",
1214 Ftreesit_parser_language, Streesit_parser_language, 1221 Ftreesit_parser_language, Streesit_parser_language,
1215 1, 1, 0, 1222 1, 1, 0,
1216 doc: /* Return parser's language symbol. 1223 doc: /* Return PARSER's language symbol.
1217This symbol is the one used to create the parser. */) 1224This symbol is the one used to create the parser. */)
1218 (Lisp_Object parser) 1225 (Lisp_Object parser)
1219{ 1226{
@@ -1269,11 +1276,11 @@ DEFUN ("treesit-parser-set-included-ranges",
1269 2, 2, 0, 1276 2, 2, 0,
1270 doc: /* Limit PARSER to RANGES. 1277 doc: /* Limit PARSER to RANGES.
1271 1278
1272RANGES is a list of (BEG . END), each (BEG . END) confines a range in 1279RANGES is a list of (BEG . END), each (BEG . END) defines a region in
1273which the parser should operate in. Each range must not overlap, and 1280which the parser should operate. Regions must not overlap, and the
1274each range should come in order. Signal `treesit-set-range-error' 1281regions should come in order in the list. Signal `treesit-set-range-error'
1275if the argument is invalid, or something else went wrong. If RANGES 1282if the argument is invalid, or something else went wrong. If RANGES
1276is nil, set PARSER to parse the whole buffer. */) 1283is nil, the PARSER is to parse the whole buffer. */)
1277 (Lisp_Object parser, Lisp_Object ranges) 1284 (Lisp_Object parser, Lisp_Object ranges)
1278{ 1285{
1279 ts_check_parser (parser); 1286 ts_check_parser (parser);
@@ -1340,7 +1347,8 @@ DEFUN ("treesit-parser-included-ranges",
1340 Streesit_parser_included_ranges, 1347 Streesit_parser_included_ranges,
1341 1, 1, 0, 1348 1, 1, 0,
1342 doc: /* Return the ranges set for PARSER. 1349 doc: /* Return the ranges set for PARSER.
1343See `treesit-parser-set-ranges'. If no range is set, return nil. */) 1350See `treesit-parser-set-ranges'. If no ranges are set for PARSER,
1351return nil. */)
1344 (Lisp_Object parser) 1352 (Lisp_Object parser)
1345{ 1353{
1346 ts_check_parser (parser); 1354 ts_check_parser (parser);
@@ -1413,7 +1421,7 @@ If NODE is nil, return nil. */)
1413 1421
1414DEFUN ("treesit-node-start", 1422DEFUN ("treesit-node-start",
1415 Ftreesit_node_start, Streesit_node_start, 1, 1, 0, 1423 Ftreesit_node_start, Streesit_node_start, 1, 1, 0,
1416 doc: /* Return the NODE's start position. 1424 doc: /* Return the NODE's start position in its buffer.
1417If NODE is nil, return nil. */) 1425If NODE is nil, return nil. */)
1418 (Lisp_Object node) 1426 (Lisp_Object node)
1419{ 1427{
@@ -1433,7 +1441,7 @@ If NODE is nil, return nil. */)
1433 1441
1434DEFUN ("treesit-node-end", 1442DEFUN ("treesit-node-end",
1435 Ftreesit_node_end, Streesit_node_end, 1, 1, 0, 1443 Ftreesit_node_end, Streesit_node_end, 1, 1, 0,
1436 doc: /* Return the NODE's end position. 1444 doc: /* Return the NODE's end position in its buffer.
1437If NODE is nil, return nil. */) 1445If NODE is nil, return nil. */)
1438 (Lisp_Object node) 1446 (Lisp_Object node)
1439{ 1447{
@@ -1469,7 +1477,7 @@ If NODE is nil, return nil. */)
1469DEFUN ("treesit-node-parent", 1477DEFUN ("treesit-node-parent",
1470 Ftreesit_node_parent, Streesit_node_parent, 1, 1, 0, 1478 Ftreesit_node_parent, Streesit_node_parent, 1, 1, 0,
1471 doc: /* Return the immediate parent of NODE. 1479 doc: /* Return the immediate parent of NODE.
1472Return nil if there isn't any. If NODE is nil, return nil. */) 1480Return nil if NODE has no parent. If NODE is nil, return nil. */)
1473 (Lisp_Object node) 1481 (Lisp_Object node)
1474{ 1482{
1475 if (NILP (node)) return Qnil; 1483 if (NILP (node)) return Qnil;
@@ -1489,7 +1497,7 @@ DEFUN ("treesit-node-child",
1489 Ftreesit_node_child, Streesit_node_child, 2, 3, 0, 1497 Ftreesit_node_child, Streesit_node_child, 2, 3, 0,
1490 doc: /* Return the Nth child of NODE. 1498 doc: /* Return the Nth child of NODE.
1491 1499
1492Return nil if there isn't any. If NAMED is non-nil, look for named 1500Return nil if there is no Nth child. If NAMED is non-nil, look for named
1493child only. NAMED defaults to nil. If NODE is nil, return nil. */) 1501child only. NAMED defaults to nil. If NODE is nil, return nil. */)
1494 (Lisp_Object node, Lisp_Object n, Lisp_Object named) 1502 (Lisp_Object node, Lisp_Object n, Lisp_Object named)
1495{ 1503{
@@ -1519,6 +1527,7 @@ DEFUN ("treesit-node-check",
1519 doc: /* Return non-nil if NODE has PROPERTY, nil otherwise. 1527 doc: /* Return non-nil if NODE has PROPERTY, nil otherwise.
1520 1528
1521PROPERTY could be `named', `missing', `extra', `has-changes', or `has-error'. 1529PROPERTY could be `named', `missing', `extra', `has-changes', or `has-error'.
1530
1522Named nodes correspond to named rules in the language definition, 1531Named nodes correspond to named rules in the language definition,
1523whereas "anonymous" nodes correspond to string literals in the 1532whereas "anonymous" nodes correspond to string literals in the
1524language definition. 1533language definition.
@@ -1564,7 +1573,7 @@ DEFUN ("treesit-node-field-name-for-child",
1564 Streesit_node_field_name_for_child, 2, 2, 0, 1573 Streesit_node_field_name_for_child, 2, 2, 0,
1565 doc: /* Return the field name of the Nth child of NODE. 1574 doc: /* Return the field name of the Nth child of NODE.
1566 1575
1567Return nil if not any child or no field is found. 1576Return nil if there's no Nth child, or if it has no field.
1568If NODE is nil, return nil. */) 1577If NODE is nil, return nil. */)
1569 (Lisp_Object node, Lisp_Object n) 1578 (Lisp_Object node, Lisp_Object n)
1570{ 1579{
@@ -1614,7 +1623,7 @@ DEFUN ("treesit-node-child-by-field-name",
1614 Ftreesit_node_child_by_field_name, 1623 Ftreesit_node_child_by_field_name,
1615 Streesit_node_child_by_field_name, 2, 2, 0, 1624 Streesit_node_child_by_field_name, 2, 2, 0,
1616 doc: /* Return the child of NODE with FIELD-NAME. 1625 doc: /* Return the child of NODE with FIELD-NAME.
1617Return nil if there isn't any. If NODE is nil, return nil. */) 1626Return nil if there is no such child. If NODE is nil, return nil. */)
1618 (Lisp_Object node, Lisp_Object field_name) 1627 (Lisp_Object node, Lisp_Object field_name)
1619{ 1628{
1620 if (NILP (node)) 1629 if (NILP (node))
@@ -1639,7 +1648,7 @@ DEFUN ("treesit-node-next-sibling",
1639 Streesit_node_next_sibling, 1, 2, 0, 1648 Streesit_node_next_sibling, 1, 2, 0,
1640 doc: /* Return the next sibling of NODE. 1649 doc: /* Return the next sibling of NODE.
1641 1650
1642Return nil if there isn't any. If NAMED is non-nil, look for named 1651Return nil if there is no next sibling. If NAMED is non-nil, look for named
1643siblings only. NAMED defaults to nil. If NODE is nil, return nil. */) 1652siblings only. NAMED defaults to nil. If NODE is nil, return nil. */)
1644 (Lisp_Object node, Lisp_Object named) 1653 (Lisp_Object node, Lisp_Object named)
1645{ 1654{
@@ -1665,8 +1674,9 @@ DEFUN ("treesit-node-prev-sibling",
1665 Streesit_node_prev_sibling, 1, 2, 0, 1674 Streesit_node_prev_sibling, 1, 2, 0,
1666 doc: /* Return the previous sibling of NODE. 1675 doc: /* Return the previous sibling of NODE.
1667 1676
1668Return nil if there isn't any. If NAMED is non-nil, look for named 1677Return nil if there is no previous sibling. If NAMED is non-nil, look
1669siblings only. NAMED defaults to nil. If NODE is nil, return nil. */) 1678for named siblings only. NAMED defaults to nil. If NODE is nil,
1679return nil. */)
1670 (Lisp_Object node, Lisp_Object named) 1680 (Lisp_Object node, Lisp_Object named)
1671{ 1681{
1672 if (NILP (node)) return Qnil; 1682 if (NILP (node)) return Qnil;
@@ -1690,12 +1700,12 @@ siblings only. NAMED defaults to nil. If NODE is nil, return nil. */)
1690DEFUN ("treesit-node-first-child-for-pos", 1700DEFUN ("treesit-node-first-child-for-pos",
1691 Ftreesit_node_first_child_for_pos, 1701 Ftreesit_node_first_child_for_pos,
1692 Streesit_node_first_child_for_pos, 2, 3, 0, 1702 Streesit_node_first_child_for_pos, 2, 3, 0,
1693 doc: /* Return the first child of NODE on POS. 1703 doc: /* Return the first child of NODE for buffer position POS.
1694 1704
1695Specifically, return the first child that extends beyond POS. POS is 1705Specifically, return the first child that extends beyond POS.
1696a position in the buffer. Return nil if there isn't any. If NAMED is 1706Return nil if there is no such child.
1697non-nil, look for named children only. NAMED defaults to nil. Note that 1707If NAMED is non-nil, look for named children only. NAMED defaults to nil.
1698this function returns an immediate child, not the smallest 1708Note that this function returns an immediate child, not the smallest
1699(grand)child. If NODE is nil, return nil. */) 1709(grand)child. If NODE is nil, return nil. */)
1700 (Lisp_Object node, Lisp_Object pos, Lisp_Object named) 1710 (Lisp_Object node, Lisp_Object pos, Lisp_Object named)
1701{ 1711{
@@ -1730,11 +1740,12 @@ this function returns an immediate child, not the smallest
1730DEFUN ("treesit-node-descendant-for-range", 1740DEFUN ("treesit-node-descendant-for-range",
1731 Ftreesit_node_descendant_for_range, 1741 Ftreesit_node_descendant_for_range,
1732 Streesit_node_descendant_for_range, 3, 4, 0, 1742 Streesit_node_descendant_for_range, 3, 4, 0,
1733 doc: /* Return the smallest node that covers BEG to END. 1743 doc: /* Return the smallest node that covers buffer positions BEG to END.
1734 1744
1735The returned node is a descendant of NODE. POS is a position. Return 1745The returned node is a descendant of NODE.
1736nil if there isn't any. If NAMED is non-nil, look for named child 1746Return nil if there is no such node.
1737only. NAMED defaults to nil. If NODE is nil, return nil. */) 1747If NAMED is non-nil, look for named child only. NAMED defaults to nil.
1748If NODE is nil, return nil. */)
1738 (Lisp_Object node, Lisp_Object beg, Lisp_Object end, Lisp_Object named) 1749 (Lisp_Object node, Lisp_Object beg, Lisp_Object end, Lisp_Object named)
1739{ 1750{
1740 if (NILP (node)) return Qnil; 1751 if (NILP (node)) return Qnil;
@@ -1815,8 +1826,7 @@ PATTERN can be
1815 _ 1826 _
1816 \"TYPE\" 1827 \"TYPE\"
1817 1828
1818Consult Info node `(elisp)Pattern Matching' form detailed 1829See Info node `(elisp)Pattern Matching' for detailed explanation. */)
1819explanation. */)
1820 (Lisp_Object pattern) 1830 (Lisp_Object pattern)
1821{ 1831{
1822 if (EQ (pattern, intern_c_string (":anchor"))) 1832 if (EQ (pattern, intern_c_string (":anchor")))
@@ -1865,8 +1875,7 @@ A PATTERN in QUERY can be
1865 _ 1875 _
1866 \"TYPE\" 1876 \"TYPE\"
1867 1877
1868Consult Info node `(elisp)Pattern Matching' form detailed 1878See Info node `(elisp)Pattern Matching' for detailed explanation. */)
1869explanation. */)
1870 (Lisp_Object query) 1879 (Lisp_Object query)
1871{ 1880{
1872 return Fmapconcat (intern_c_string ("treesit-pattern-expand"), 1881 return Fmapconcat (intern_c_string ("treesit-pattern-expand"),
@@ -2056,15 +2065,15 @@ DEFUN ("treesit-query-compile",
2056 Streesit_query_compile, 2, 3, 0, 2065 Streesit_query_compile, 2, 3, 0,
2057 doc: /* Compile QUERY to a compiled query. 2066 doc: /* Compile QUERY to a compiled query.
2058 2067
2059Querying a compiled query is much faster than an uncompiled one. 2068Querying with a compiled query is much faster than an uncompiled one.
2060LANGUAGE is the language this query is for. 2069LANGUAGE is the language this query is for.
2061 2070
2062If EAGER is non-nil, immediately load LANGUAGE and compile the query. 2071If EAGER is non-nil, immediately load LANGUAGE and compile the query.
2063Otherwise defer until the query is first used. 2072Otherwise defer the compilation until the query is first used.
2064 2073
2065Signals treesit-query-error if QUERY is malformed or something else 2074Signals treesit-query-error if QUERY is malformed or something else
2066goes wrong. (This of course would only happen if EAGER is non-nil.) 2075goes wrong. (This only happens if EAGER is non-nil.)
2067You can use `treesit-query-validate' to debug the query. */) 2076You can use `treesit-query-validate' to validate and debug a query. */)
2068 (Lisp_Object language, Lisp_Object query, Lisp_Object eager) 2077 (Lisp_Object language, Lisp_Object query, Lisp_Object eager)
2069{ 2078{
2070 if (NILP (Ftreesit_query_p (query))) 2079 if (NILP (Ftreesit_query_p (query)))
@@ -2104,21 +2113,24 @@ assigned to the node in PATTERN. NODE is the captured node.
2104 2113
2105QUERY is either a string query, a sexp query, or a compiled query. 2114QUERY is either a string query, a sexp query, or a compiled query.
2106See Info node `(elisp)Pattern Matching' for how to write a query in 2115See Info node `(elisp)Pattern Matching' for how to write a query in
2107either string or s-expression form. When using repeatedly, a compiled 2116either string or sexp form. When using repeatedly, a compiled query
2108query is much faster than a string or sexp one, so it is recommend to 2117is much faster than a string or sexp one, so it is recommend to
2109compile your queries if it will be used over and over. 2118compile your query if it will be used repeatedly.
2110 2119
2111BEG and END, if both non-nil, specifies the range in which the query 2120BEG and END, if both non-nil, specify the region of buffer positions
2112is executed. If NODE-ONLY is non-nil, return a list of nodes. 2121in which the query is executed.
2113 2122
2114Besides a node, NODE can also be a parser, then the root node of that 2123If NODE-ONLY is non-nil, return a list of nodes.
2115parser is used; NODE can be a language symbol, then the root node of a 2124
2125Besides a node, NODE can also be a parser, in which case the root node
2126of that parser is used.
2127NODE can also be a language symbol, in which case the root node of a
2116parser for that language is used. If such a parser doesn't exist, it 2128parser for that language is used. If such a parser doesn't exist, it
2117is created. 2129is created.
2118 2130
2119Signals treesit-query-error if QUERY is malformed or something else 2131Signal `treesit-query-error' if QUERY is malformed or something else
2120goes wrong. You can use `treesit-query-validate' to debug the 2132goes wrong. You can use `treesit-query-validate' to validate and debug
2121query. */) 2133the query. */)
2122 (Lisp_Object node, Lisp_Object query, 2134 (Lisp_Object node, Lisp_Object query,
2123 Lisp_Object beg, Lisp_Object end, Lisp_Object node_only) 2135 Lisp_Object beg, Lisp_Object end, Lisp_Object node_only)
2124{ 2136{
@@ -2403,16 +2415,16 @@ ts_search_forward (TSNode *start, Lisp_Object pred, Lisp_Object parser,
2403DEFUN ("treesit-search-subtree", 2415DEFUN ("treesit-search-subtree",
2404 Ftreesit_search_subtree, 2416 Ftreesit_search_subtree,
2405 Streesit_search_subtree, 2, 5, 0, 2417 Streesit_search_subtree, 2, 5, 0,
2406 doc: /* Traverse the parse tree depth-first. 2418 doc: /* Traverse the parse tree of NODE depth-first using PREDICATE.
2407 2419
2408Traverse the subtree of NODE, and match PREDICATE with each node along 2420Traverse the subtree of NODE, and match PREDICATE with each node along
2409the way. PREDICATE is a regexp string that matches against each 2421the way. PREDICATE is a regexp string that matches against each
2410node's type case-insensitively, or a function that takes a node and 2422node's type case-insensitively, or a function that takes a node and
2411returns nil/non-nil. 2423returns nil/non-nil.
2412 2424
2413By default, only traverse named nodes, if ALL is non-nil, traverse all 2425By default, only traverse named nodes, but if ALL is non-nil, traverse
2414nodes. If BACKWARD is non-nil, traverse backwards. If LIMIT is 2426all nodes. If BACKWARD is non-nil, traverse backwards. If LIMIT is
2415non-nil, we only traverse that number of levels down in the tree. 2427non-nil, only traverse nodes up to that number of levels down in the tree.
2416 2428
2417Return the first matched node, or nil if none matches. */) 2429Return the first matched node, or nil if none matches. */)
2418 (Lisp_Object node, Lisp_Object predicate, Lisp_Object all, 2430 (Lisp_Object node, Lisp_Object predicate, Lisp_Object all,
@@ -2448,20 +2460,20 @@ Return the first matched node, or nil if none matches. */)
2448DEFUN ("treesit-search-forward", 2460DEFUN ("treesit-search-forward",
2449 Ftreesit_search_forward, 2461 Ftreesit_search_forward,
2450 Streesit_search_forward, 2, 5, 0, 2462 Streesit_search_forward, 2, 5, 0,
2451 doc: /* Search for node in the parse tree. 2463 doc: /* Search for node matching PREDICATE in the parse tree of START.
2452 2464
2453Start traversing the tree from node START, and match PREDICATE with 2465Start traversing the tree from node START, and match PREDICATE with
2454each node along the way (except START). PREDICATE is a regexp string 2466each node (except START itself) along the way. PREDICATE is a regexp
2455that matches against each node's type case-insensitively, or a 2467string that matches against each node's type case-insensitively, or a
2456function that takes a node and returns nil/non-nil. 2468function that takes a node and returns non-nil if it matches.
2457 2469
2458By default, only search for named nodes, if ALL is non-nil, search for 2470By default, only search for named nodes, but if ALL is non-nil, search
2459all nodes. If BACKWARD is non-nil, search backwards. 2471for all nodes. If BACKWARD is non-nil, search backwards.
2460 2472
2461Return the first matched node, or nil if none matches. 2473Return the first matched node, or nil if none matches.
2462 2474
2463For a tree like the below where START is marked 1, traverse as 2475For a tree like below, where START is marked by 1, traverse in the
2464numbered: 2476order of numbers:
2465 16 2477 16
2466 | 2478 |
2467 3--------4-----------8 2479 3--------4-----------8
@@ -2472,8 +2484,8 @@ numbered:
2472 | | | | | 2484 | | | | |
2473 10 11 13 14 15 2485 10 11 13 14 15
2474 2486
2475If UP is non-nil, only traverse to siblings and parents. In that 2487If UP is non-nil, only traverse siblings and parents of START. In that
2476case, only 1 3 4 8 16 would be traversed. */) 2488case, only the nodes 1, 3, 4, 8, and 16 would be traversed. */)
2477 (Lisp_Object start, Lisp_Object predicate, Lisp_Object all, 2489 (Lisp_Object start, Lisp_Object predicate, Lisp_Object all,
2478 Lisp_Object backward, Lisp_Object up) 2490 Lisp_Object backward, Lisp_Object up)
2479{ 2491{
@@ -2550,7 +2562,7 @@ DEFUN ("treesit-induce-sparse-tree",
2550 Streesit_induce_sparse_tree, 2, 4, 0, 2562 Streesit_induce_sparse_tree, 2, 4, 0,
2551 doc: /* Create a sparse tree of ROOT's subtree. 2563 doc: /* Create a sparse tree of ROOT's subtree.
2552 2564
2553Basically, take the subtree under ROOT, and comb it so only the nodes 2565This takes the subtree under ROOT, and combs it so only the nodes
2554that match PREDICATE are left, like picking out grapes on the vine. 2566that match PREDICATE are left, like picking out grapes on the vine.
2555PREDICATE is a regexp string that matches against each node's type 2567PREDICATE is a regexp string that matches against each node's type
2556case-insensitively. 2568case-insensitively.
@@ -2570,17 +2582,20 @@ PREDICATE is "is letter", the returned tree is the one on the right.
2570 | | | 2582 | | |
2571 e 5 e 2583 e 5 e
2572 2584
2573If PROCESS-FN is non-nil, instead of returning the matched nodes, pass 2585If PROCESS-FN is non-nil, it should be a function of one argument. In
2574each node to PROCESS-FN use the return value instead. If non-nil, 2586that case, instead of returning the matched nodes, pass each node to
2575LIMIT is the number of levels to go down from ROOT. 2587PROCESS-FN, and use its return value instead.
2588
2589If non-nil, LIMIT is the number of levels to go down the tree from ROOT.
2576 2590
2577Each node in the returned tree looks like (NODE . (CHILD ...)). The 2591Each node in the returned tree looks like (NODE . (CHILD ...)). The
2578root of this tree might be nil, if ROOT doesn't match PREDICATE. If 2592root of this tree might be nil, if ROOT doesn't match PREDICATE.
2579no node matches PRED, return nil. 2593
2594If no node matches PREDICATE, return nil.
2580 2595
2581PREDICATE can also be a function that takes a node and returns 2596PREDICATE can also be a function that takes a node and returns
2582nil/non-nil, but it is slower and more memory consuming than 2597nil/non-nil, but it is slower and more memory consuming than using
2583regexp. */) 2598a regexp. */)
2584 (Lisp_Object root, Lisp_Object predicate, Lisp_Object process_fn, 2599 (Lisp_Object root, Lisp_Object predicate, Lisp_Object process_fn,
2585 Lisp_Object limit) 2600 Lisp_Object limit)
2586{ 2601{
@@ -2700,23 +2715,24 @@ By default, Emacs assumes the dynamic library for LANG is
2700libtree-sitter-LANG.EXT, where EXT is the OS specific extension for 2715libtree-sitter-LANG.EXT, where EXT is the OS specific extension for
2701dynamic libraries. Emacs also assumes that the name of the C function 2716dynamic libraries. Emacs also assumes that the name of the C function
2702the library provides is tree_sitter_LANG. If that is not the case, 2717the library provides is tree_sitter_LANG. If that is not the case,
2703add an entry 2718you can add an entry
2704 2719
2705 (LANG LIBRARY-BASE-NAME FUNCTION-NAME) 2720 (LANG LIBRARY-BASE-NAME FUNCTION-NAME)
2706 2721
2707to this list, where LIBRARY-BASE-NAME is the filename of the dynamic 2722to this list, where LIBRARY-BASE-NAME is the filename of the dynamic
2708library without extension, FUNCTION-NAME is the function provided by 2723library without the file-name extension, and FUNCTION-NAME is the
2709the library. */); 2724function provided by the library. */);
2710 Vtreesit_load_name_override_list = Qnil; 2725 Vtreesit_load_name_override_list = Qnil;
2711 2726
2712 DEFVAR_LISP ("treesit-extra-load-path", 2727 DEFVAR_LISP ("treesit-extra-load-path",
2713 Vtreesit_extra_load_path, 2728 Vtreesit_extra_load_path,
2714 doc: 2729 doc:
2715 /* Extra load paths of tree-sitter language definitions. 2730 /* Additional directories to look for tree-sitter language definitions.
2731The value should be a list of directories.
2716When trying to load a tree-sitter language definition, 2732When trying to load a tree-sitter language definition,
2717Emacs looks at directories in this variable, 2733Emacs first looks in the directories mentioned in in this variable,
2718`user-emacs-directory'/tree-sitter, and system default locations for 2734then in the `tree-sitter' subdirectory of `user-emacs-directory', and
2719dynamic libraries, in that order. */); 2735then in the system default locations for dynamic libraries, in that order. */);
2720 Vtreesit_extra_load_path = Qnil; 2736 Vtreesit_extra_load_path = Qnil;
2721 2737
2722 defsubr (&Streesit_language_available_p); 2738 defsubr (&Streesit_language_available_p);