aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorYuan Fu2024-12-01 11:22:48 -0800
committerYuan Fu2024-12-01 11:35:06 -0800
commitcf4f1387a6561be7cd7387b766df4386a0fa472f (patch)
tree886dab7daa3a759e60f5e0d5ebb075e160609dd4 /doc
parent3c7687c1dd136fa535e22262f78fdfadbbf73105 (diff)
downloademacs-cf4f1387a6561be7cd7387b766df4386a0fa472f.tar.gz
emacs-cf4f1387a6561be7cd7387b766df4386a0fa472f.zip
; Update tree-sitter manual
* doc/lispref/parsing.texi (User-defined Things): Add manual entry for treesit-node-match-p, treesit-thing-defined-p, treesit-thing-definition. Change wording for some functions.
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 8f3c2b4a366..f8bf0b20a7c 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -1536,7 +1536,11 @@ The ``things'' feature in Emacs is independent of the pattern matching
1536feature of tree-sitter, and comparatively less powerful, but more 1536feature of tree-sitter, and comparatively less powerful, but more
1537suitable for navigation and traversing the parse tree. 1537suitable for navigation and traversing the parse tree.
1538 1538
1539You can define things with @code{treesit-thing-settings}. 1539@findex treesit-thing-definition
1540@findex treesit-thing-defined-p
1541You can define things with @var{treesit-thing-settings}, retrieve the
1542predicate of a defined thing with @code{treesit-thing-definition}, and
1543test if a thing is defined with @code{treesit-thing-defined-p}.
1540 1544
1541@defvar treesit-thing-settings 1545@defvar treesit-thing-settings
1542This is an alist of thing definitions for each language. The key of 1546This is an alist of thing definitions for each language. The key of
@@ -1592,6 +1596,25 @@ functions listed elsewhere also utilize the thing feature, e.g.,
1592tree-traversing functions like @code{treesit-search-forward}, 1596tree-traversing functions like @code{treesit-search-forward},
1593@code{treesit-induce-sparse-tree}, etc. @xref{Retrieving Nodes}. 1597@code{treesit-induce-sparse-tree}, etc. @xref{Retrieving Nodes}.
1594 1598
1599@defun treesit-node-match-p node thing &optional ignore-missing
1600This function checks whether @var{node} is a @var{thing}.
1601
1602If @var{node} is a @var{thing}, return non-@code{nil}, otherwise return
1603@code{nil}. For convenience, if @code{node} is @code{nil}, this
1604function just returns @code{nil}.
1605
1606The @var{thing} can be either a thing symbol like @code{defun}, or
1607simply a predicate that defines a thing, like
1608@code{"function_definition"}, or @w{@code{(or comment string)}}.
1609
1610By default, if @var{thing} is undefined or malformed, this function
1611signals @code{treesit-invalid-predicate} error. If @var{ignore-missing}
1612is @code{t}, this function doesn't signal the error when @var{thing} is
1613undefined and just returns @code{nil}; but it still signals the error if
1614@var{thing} is a malformed predicate.
1615
1616@end defun
1617
1595@defun treesit-thing-prev position thing 1618@defun treesit-thing-prev position thing
1596This function returns the first node before @var{position} that is the 1619This function returns the first node before @var{position} that is the
1597specified @var{thing}. If no such node exists, it returns @code{nil}. 1620specified @var{thing}. If no such node exists, it returns @code{nil}.
@@ -1599,8 +1622,7 @@ It's guaranteed that, if a node is returned, the node's end position is
1599less or equal to @var{position}. In other words, this function never 1622less or equal to @var{position}. In other words, this function never
1600returns a node that encloses @var{position}. 1623returns a node that encloses @var{position}.
1601 1624
1602@var{thing} can be either a thing symbol like @code{defun}, or simply a 1625Again, @var{thing} can be either a symbol or a predicate.
1603thing definition like @code{"function_definition"}.
1604@end defun 1626@end defun
1605 1627
1606@defun treesit-thing-next position thing 1628@defun treesit-thing-next position thing
@@ -1624,7 +1646,7 @@ A positive @var{arg} means moving forward that many instances of
1624@code{end}, stop at the end of @var{thing}. 1646@code{end}, stop at the end of @var{thing}.
1625 1647
1626Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol 1648Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol
1627defined in @code{treesit-thing-settings}, or a thing definition. 1649defined in @code{treesit-thing-settings}, or a predicate.
1628 1650
1629@var{tactic} determines how this function moves between things. It can 1651@var{tactic} determines how this function moves between things. It can
1630be @code{nested}, @code{top-level}, @code{restricted}, or @code{nil}. 1652be @code{nested}, @code{top-level}, @code{restricted}, or @code{nil}.
@@ -1651,7 +1673,7 @@ i.e., start position must be strictly greater than @var{position}, and end
1651position must be strictly less than @var{position}. 1673position must be strictly less than @var{position}.
1652 1674
1653@var{thing} can be either a thing symbol defined in 1675@var{thing} can be either a thing symbol defined in
1654@code{treesit-thing-settings}, or a thing definition. 1676@code{treesit-thing-settings}, or a predicate.
1655@end defun 1677@end defun
1656 1678
1657@findex treesit-beginning-of-thing 1679@findex treesit-beginning-of-thing