diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/parsing.texi | 32 |
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 | |||
| 1553 | feature of tree-sitter, and comparatively less powerful, but more | 1553 | feature of tree-sitter, and comparatively less powerful, but more |
| 1554 | suitable for navigation and traversing the parse tree. | 1554 | suitable for navigation and traversing the parse tree. |
| 1555 | 1555 | ||
| 1556 | You can define things with @code{treesit-thing-settings}. | 1556 | @findex treesit-thing-definition |
| 1557 | @findex treesit-thing-defined-p | ||
| 1558 | You can define things with @var{treesit-thing-settings}, retrieve the | ||
| 1559 | predicate of a defined thing with @code{treesit-thing-definition}, and | ||
| 1560 | test if a thing is defined with @code{treesit-thing-defined-p}. | ||
| 1557 | 1561 | ||
| 1558 | @defvar treesit-thing-settings | 1562 | @defvar treesit-thing-settings |
| 1559 | This is an alist of thing definitions for each language. The key of | 1563 | This 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., | |||
| 1609 | tree-traversing functions like @code{treesit-search-forward}, | 1613 | tree-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 | ||
| 1617 | This function checks whether @var{node} is a @var{thing}. | ||
| 1618 | |||
| 1619 | If @var{node} is a @var{thing}, return non-@code{nil}, otherwise return | ||
| 1620 | @code{nil}. For convenience, if @code{node} is @code{nil}, this | ||
| 1621 | function just returns @code{nil}. | ||
| 1622 | |||
| 1623 | The @var{thing} can be either a thing symbol like @code{defun}, or | ||
| 1624 | simply a predicate that defines a thing, like | ||
| 1625 | @code{"function_definition"}, or @w{@code{(or comment string)}}. | ||
| 1626 | |||
| 1627 | By default, if @var{thing} is undefined or malformed, this function | ||
| 1628 | signals @code{treesit-invalid-predicate} error. If @var{ignore-missing} | ||
| 1629 | is @code{t}, this function doesn't signal the error when @var{thing} is | ||
| 1630 | undefined 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 |
| 1613 | This function returns the first node before @var{position} that is the | 1636 | This function returns the first node before @var{position} that is the |
| 1614 | specified @var{thing}. If no such node exists, it returns @code{nil}. | 1637 | specified @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 | |||
| 1616 | less or equal to @var{position}. In other words, this function never | 1639 | less or equal to @var{position}. In other words, this function never |
| 1617 | returns a node that encloses @var{position}. | 1640 | returns a node that encloses @var{position}. |
| 1618 | 1641 | ||
| 1619 | @var{thing} can be either a thing symbol like @code{defun}, or simply a | 1642 | Again, @var{thing} can be either a symbol or a predicate. |
| 1620 | thing 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 | ||
| 1643 | Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol | 1665 | Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol |
| 1644 | defined in @code{treesit-thing-settings}, or a thing definition. | 1666 | defined 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 |
| 1647 | be @code{nested}, @code{top-level}, @code{restricted}, or @code{nil}. | 1669 | be @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 | |||
| 1668 | position must be strictly less than @var{position}. | 1690 | position 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 |