aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/parsing.texi32
1 files changed, 27 insertions, 5 deletions
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 20b1085b46c..9fe828d8512 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -1553,7 +1553,11 @@ The ``things'' feature in Emacs is independent of the pattern matching
1553feature of tree-sitter, and comparatively less powerful, but more 1553feature of tree-sitter, and comparatively less powerful, but more
1554suitable for navigation and traversing the parse tree. 1554suitable for navigation and traversing the parse tree.
1555 1555
1556You can define things with @code{treesit-thing-settings}. 1556@findex treesit-thing-definition
1557@findex treesit-thing-defined-p
1558You can define things with @var{treesit-thing-settings}, retrieve the
1559predicate of a defined thing with @code{treesit-thing-definition}, and
1560test if a thing is defined with @code{treesit-thing-defined-p}.
1557 1561
1558@defvar treesit-thing-settings 1562@defvar treesit-thing-settings
1559This is an alist of thing definitions for each language. The key of 1563This is an alist of thing definitions for each language. The key of
@@ -1609,6 +1613,25 @@ functions listed elsewhere also utilize the thing feature, e.g.,
1609tree-traversing functions like @code{treesit-search-forward}, 1613tree-traversing functions like @code{treesit-search-forward},
1610@code{treesit-induce-sparse-tree}, etc. @xref{Retrieving Nodes}. 1614@code{treesit-induce-sparse-tree}, etc. @xref{Retrieving Nodes}.
1611 1615
1616@defun treesit-node-match-p node thing &optional ignore-missing
1617This function checks whether @var{node} is a @var{thing}.
1618
1619If @var{node} is a @var{thing}, return non-@code{nil}, otherwise return
1620@code{nil}. For convenience, if @code{node} is @code{nil}, this
1621function just returns @code{nil}.
1622
1623The @var{thing} can be either a thing symbol like @code{defun}, or
1624simply a predicate that defines a thing, like
1625@code{"function_definition"}, or @w{@code{(or comment string)}}.
1626
1627By default, if @var{thing} is undefined or malformed, this function
1628signals @code{treesit-invalid-predicate} error. If @var{ignore-missing}
1629is @code{t}, this function doesn't signal the error when @var{thing} is
1630undefined and just returns @code{nil}; but it still signals the error if
1631@var{thing} is a malformed predicate.
1632
1633@end defun
1634
1612@defun treesit-thing-prev position thing 1635@defun treesit-thing-prev position thing
1613This function returns the first node before @var{position} that is the 1636This function returns the first node before @var{position} that is the
1614specified @var{thing}. If no such node exists, it returns @code{nil}. 1637specified @var{thing}. If no such node exists, it returns @code{nil}.
@@ -1616,8 +1639,7 @@ It's guaranteed that, if a node is returned, the node's end position is
1616less or equal to @var{position}. In other words, this function never 1639less or equal to @var{position}. In other words, this function never
1617returns a node that encloses @var{position}. 1640returns a node that encloses @var{position}.
1618 1641
1619@var{thing} can be either a thing symbol like @code{defun}, or simply a 1642Again, @var{thing} can be either a symbol or a predicate.
1620thing definition like @code{"function_definition"}.
1621@end defun 1643@end defun
1622 1644
1623@defun treesit-thing-next position thing 1645@defun treesit-thing-next position thing
@@ -1641,7 +1663,7 @@ A positive @var{arg} means moving forward that many instances of
1641@code{end}, stop at the end of @var{thing}. 1663@code{end}, stop at the end of @var{thing}.
1642 1664
1643Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol 1665Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol
1644defined in @code{treesit-thing-settings}, or a thing definition. 1666defined in @code{treesit-thing-settings}, or a predicate.
1645 1667
1646@var{tactic} determines how this function moves between things. It can 1668@var{tactic} determines how this function moves between things. It can
1647be @code{nested}, @code{top-level}, @code{restricted}, or @code{nil}. 1669be @code{nested}, @code{top-level}, @code{restricted}, or @code{nil}.
@@ -1668,7 +1690,7 @@ i.e., start position must be strictly greater than @var{position}, and end
1668position must be strictly less than @var{position}. 1690position must be strictly less than @var{position}.
1669 1691
1670@var{thing} can be either a thing symbol defined in 1692@var{thing} can be either a thing symbol defined in
1671@code{treesit-thing-settings}, or a thing definition. 1693@code{treesit-thing-settings}, or a predicate.
1672@end defun 1694@end defun
1673 1695
1674@findex treesit-beginning-of-thing 1696@findex treesit-beginning-of-thing