diff options
| author | Yuan Fu | 2024-12-01 11:22:48 -0800 |
|---|---|---|
| committer | Yuan Fu | 2024-12-01 11:35:06 -0800 |
| commit | cf4f1387a6561be7cd7387b766df4386a0fa472f (patch) | |
| tree | 886dab7daa3a759e60f5e0d5ebb075e160609dd4 /doc | |
| parent | 3c7687c1dd136fa535e22262f78fdfadbbf73105 (diff) | |
| download | emacs-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.texi | 32 |
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 | |||
| 1536 | feature of tree-sitter, and comparatively less powerful, but more | 1536 | feature of tree-sitter, and comparatively less powerful, but more |
| 1537 | suitable for navigation and traversing the parse tree. | 1537 | suitable for navigation and traversing the parse tree. |
| 1538 | 1538 | ||
| 1539 | You can define things with @code{treesit-thing-settings}. | 1539 | @findex treesit-thing-definition |
| 1540 | @findex treesit-thing-defined-p | ||
| 1541 | You can define things with @var{treesit-thing-settings}, retrieve the | ||
| 1542 | predicate of a defined thing with @code{treesit-thing-definition}, and | ||
| 1543 | test if a thing is defined with @code{treesit-thing-defined-p}. | ||
| 1540 | 1544 | ||
| 1541 | @defvar treesit-thing-settings | 1545 | @defvar treesit-thing-settings |
| 1542 | This is an alist of thing definitions for each language. The key of | 1546 | This 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., | |||
| 1592 | tree-traversing functions like @code{treesit-search-forward}, | 1596 | tree-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 | ||
| 1600 | This function checks whether @var{node} is a @var{thing}. | ||
| 1601 | |||
| 1602 | If @var{node} is a @var{thing}, return non-@code{nil}, otherwise return | ||
| 1603 | @code{nil}. For convenience, if @code{node} is @code{nil}, this | ||
| 1604 | function just returns @code{nil}. | ||
| 1605 | |||
| 1606 | The @var{thing} can be either a thing symbol like @code{defun}, or | ||
| 1607 | simply a predicate that defines a thing, like | ||
| 1608 | @code{"function_definition"}, or @w{@code{(or comment string)}}. | ||
| 1609 | |||
| 1610 | By default, if @var{thing} is undefined or malformed, this function | ||
| 1611 | signals @code{treesit-invalid-predicate} error. If @var{ignore-missing} | ||
| 1612 | is @code{t}, this function doesn't signal the error when @var{thing} is | ||
| 1613 | undefined 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 |
| 1596 | This function returns the first node before @var{position} that is the | 1619 | This function returns the first node before @var{position} that is the |
| 1597 | specified @var{thing}. If no such node exists, it returns @code{nil}. | 1620 | specified @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 | |||
| 1599 | less or equal to @var{position}. In other words, this function never | 1622 | less or equal to @var{position}. In other words, this function never |
| 1600 | returns a node that encloses @var{position}. | 1623 | returns a node that encloses @var{position}. |
| 1601 | 1624 | ||
| 1602 | @var{thing} can be either a thing symbol like @code{defun}, or simply a | 1625 | Again, @var{thing} can be either a symbol or a predicate. |
| 1603 | thing 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 | ||
| 1626 | Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol | 1648 | Like in @code{treesit-thing-prev}, @var{thing} can be a thing symbol |
| 1627 | defined in @code{treesit-thing-settings}, or a thing definition. | 1649 | defined 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 |
| 1630 | be @code{nested}, @code{top-level}, @code{restricted}, or @code{nil}. | 1652 | be @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 | |||
| 1651 | position must be strictly less than @var{position}. | 1673 | position 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 |