emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/tree-sitter 6a2399c55e 1/3: ; Resolve FIXME's in tree-sitter man


From: Yuan Fu
Subject: feature/tree-sitter 6a2399c55e 1/3: ; Resolve FIXME's in tree-sitter manual sections
Date: Sun, 23 Oct 2022 19:19:31 -0400 (EDT)

branch: feature/tree-sitter
commit 6a2399c55e9505be06cb98ffbe1a3878f9e96fb2
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    ; Resolve FIXME's in tree-sitter manual sections
    
    * doc/lispref/modes.texi (Parser-based Indentation):
    * doc/lispref/parsing.texi (Retrieving Node): Resolve FIXME's.
    * src/treesit.c: Update tree graph in docstring.
---
 doc/lispref/modes.texi   | 11 +++++------
 doc/lispref/parsing.texi | 30 ++++++++++++++++--------------
 src/treesit.c            | 23 ++++++++++++-----------
 3 files changed, 33 insertions(+), 31 deletions(-)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index c6269b46ba..d73c443b4c 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -4820,12 +4820,11 @@ available default functions are:
 
 @ftable @code
 @item no-node
-@c FIXME: How many arguments does no-node accept, and what are thos
-@c arguments?
-This matcher is a function that matches the case where @var{node} is
-@code{nil}, i.e., there is no node that starts at @var{bol}.  This is
-the case when @var{bol} is on an empty line or inside a multi-line
-string, etc.
+This matcher is a function that is called with 3 arguments:
+@var{node}, @var{parent}, and @var{bol}, and returns non-@code{nil},
+indicating a match, if @var{node} is @code{nil}, i.e., there is no
+node that starts at @var{bol}.  This is the case when @var{bol} is on
+an empty line or inside a multi-line string, etc.
 
 @item parent-is
 This matcher is a function of one argument, @var{type}; it returns a
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index aaa8f0f64d..ec6cd2757d 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -655,19 +655,19 @@ Like @code{treesit-search-subtree}, this function also 
traverses the
 parse tree and matches each node with @var{predicate} (except for
 @var{start}), where @var{predicate} can be a (case-insensitive) regexp
 or a function.  For a tree like the below where @var{start} is marked
-1, this function traverses as numbered:
+S, this function traverses as numbered from 1 to 12:
 
 @example
 @group
-              16
+              12
               |
-     3--------7-----------15
-     |        |           |
-o--1-+--2  4--+--6    10--+-----14
-|  |             |    |         |
-o  o             5  +-+-+    +--+--+
-                    |   |    |  |  |
-                    8   9    11 12 13
+     S--------3----------11
+     |        |          |
+o--o-+--o  1--+--2    6--+-----10
+|  |                  |        |
+o  o                +-+-+   +--+--+
+                    |   |   |  |  |
+                    4   5   7  8  9
 @end group
 @end example
 
@@ -679,12 +679,14 @@ named nodes by default, but if @var{all} is 
non-@code{nil}, it
 searches for all nodes.  If @var{backward} is non-@code{nil}, it
 searches backwards.
 
-@c FIXME: Still not very clear: the difference between ``traverse
-@c a subtree of a node'' and ``traverse every node that comes after
-@c it''.
 While @code{treesit-search-subtree} traverses the subtree of a node,
-this function usually starts with a leaf node and traverses every node
-that comes after it in the buffer position order.  It is useful for
+this function starts with node @var{start} and traverses every node
+that comes after it in the buffer position order, i.e., nodes with
+start positions greater than the end position of @var{start}.
+
+In the tree shown above, @code{treesit-search-subtree} traverses node
+S (@var{start}) and nodes marked with @code{o}, where this function
+traverses the nodes marked with numbers.  This function is useful for
 answering questions like ``what is the first node after @var{start} in
 the buffer that satisfies some condition?''
 @end defun
diff --git a/src/treesit.c b/src/treesit.c
index b4dac587b1..a23ac7510d 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -2548,17 +2548,18 @@ for all nodes.  If BACKWARD is non-nil, search 
backwards.
 
 Return the first matched node, or nil if none matches.
 
-For a tree like below, where START is marked by 1, traverse as
-numbered:
-                16
-                |
-       3--------7-----------15
-       |        |           |
-  o--1-+--2  4--+--6    10--+-----14
-  |  |             |    |         |
-  o  o             5  +-+-+    +--+--+
-                      |   |    |  |  |
-                      8   9    11 12 13
+For a tree like below, where START is marked by S, traverse as
+numbered from 1 to 12:
+
+               12
+               |
+       S--------3----------11
+       |        |          |
+  o--o-+--o  1--+--2    6--+-----10
+  |  |                  |        |
+  o  o                +-+-+   +--+--+
+                     |   |   |  |  |
+                     4   5   7  8  9
 
 Note that this function doesn't traverse the subtree of START, and it
 always traverse leaf nodes first, then upwards.  */)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]