Subject: 29.0.60; tree-sitter doc fixes

From: Juri Linkov <[email-masked]>
Date: Tue, 03 Jan 2023 20:02:23 +0200

It seems that functions like treesit-next-sibling, treesit-prev-sibling,
treesit-child-by-field-name, treesit-first-child-for-pos, treesit-child-count
were planned to implement, but their addition was postponed.  For this reason
I just commented out them, to be able to easily uncomment when they will
be implemented.  I could push other changes to emacs-29 as well:

diff --git a/admin/notes/tree-sitter/starter-guide b/admin/notes/tree-sitter/starter-guide
index a6a4c647f23..606f7891dfa 100644
--- a/admin/notes/tree-sitter/starter-guide
+++ b/admin/notes/tree-sitter/starter-guide
@@ -238,7 +238,7 @@ Concretely, something like this:
   ...
   (cond
    ;; Tree-sitter.
-   ((treesit-ready-p 'python-mode 'python)
+   ((treesit-ready-p 'python)
     (treesit-parser-create 'python)
     (setq-local treesit-font-lock-settings python--treesit-settings)
     (setq-local treesit-font-lock-feature-list
diff --git a/admin/notes/tree-sitter/html-manual/Language-Definitions.html b/admin/notes/tree-sitter/html-manual/Language-Definitions.html
index 6c17e8c3344..9b1e0021272 100644
--- a/admin/notes/tree-sitter/html-manual/Language-Definitions.html
+++ b/admin/notes/tree-sitter/html-manual/Language-Definitions.html
@@ -94,7 +94,7 @@
 </li></ul>
 
 <p>In each of these directories, Emacs looks for a file with file-name
-extensions specified by the variable <code>treesit-load-suffixes</code>.
+extensions specified by the variable <code>dynamic-library-suffixes</code>.
 </p>
 <p>If Emacs cannot find the library or has problems loading it, Emacs
 signals the <code>treesit-load-language-error</code> error.  The data of
diff --git a/admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html b/admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html
index 670f235bd20..a3fe6622162 100644
--- a/admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html
+++ b/admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html
@@ -134,7 +134,7 @@
 tree-sitter query in either the string, s-expression or compiled form.
 </p>
 <p>For each <var>query</var>, the <var>:keyword</var>/<var>value</var> pairs that
-precede it add meta information to it.  The <code>:lang</code> keyword
+precede it add meta information to it.  The <code>:language</code> keyword
 declares <var>query</var>&rsquo;s language.  The <code>:feature</code> keyword sets the
 feature name of <var>query</var>.  Users can control which features are
 enabled with <code>font-lock-maximum-decoration</code> and
diff --git a/admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html b/admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html
index 0c827b3e755..92ae14447a6 100644
--- a/admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html
+++ b/admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html
@@ -142,12 +142,12 @@
 ts_node_named_child_count               treesit-node-child-count
 ts_node_child_by_field_name             treesit-node-by-field-name
 ts_node_child_by_field_id
-ts_node_next_sibling                    treesit-next-sibling
-ts_node_prev_sibling                    treesit-prev-sibling
-ts_node_next_named_sibling              treesit-next-sibling
-ts_node_prev_named_sibling              treesit-prev-sibling
-ts_node_first_child_for_byte            treesit-first-child-for-pos
-ts_node_first_named_child_for_byte      treesit-first-child-for-pos
+ts_node_next_sibling
+ts_node_prev_sibling
+ts_node_next_named_sibling
+ts_node_prev_named_sibling
+ts_node_first_child_for_byte
+ts_node_first_named_child_for_byte
 ts_node_descendant_for_byte_range       treesit-descendant-for-range
 ts_node_descendant_for_point_range
 ts_node_named_descendant_for_byte_range treesit-descendant-for-range
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index dffd6653369..b2dd294ea28 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -4054,7 +4054,7 @@ Parser-based Font Lock
 
 @c FIXME: Cross-ref treesit-font-lock-level to user manual.
 For each @var{query}, the @var{:keyword}/@var{value} pairs that
-precede it add meta information to it.  The @code{:lang} keyword
+precede it add meta information to it.  The @code{:language} keyword
 declares @var{query}'s language.  The @code{:feature} keyword sets the
 feature name of @var{query}.  Users can control which features are
 enabled with @code{treesit-font-lock-level} and
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 19a22c121de..3edd6295bf3 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -65,7 +65,6 @@ Language Grammar
 
 @vindex treesit-extra-load-path
 @vindex treesit-load-language-error
-@vindex treesit-load-suffixes
 Tree-sitter language grammar are distributed as dynamic libraries.
 In order to use a language grammar in Emacs, you need to make sure
 that the dynamic library is installed on the system.  Emacs looks for
@@ -83,7 +82,7 @@ Language Grammar
 @end itemize
 
 In each of these directories, Emacs looks for a file with file-name
-extensions specified by the variable @code{treesit-load-suffixes}.
+extensions specified by the variable @code{dynamic-library-suffixes}.
 
 If Emacs cannot find the library or has problems loading it, Emacs
 signals the @code{treesit-load-language-error} error.  The data of
@@ -677,15 +676,15 @@ Retrieving Nodes
 @var{named} is non-@code{nil}, it retrieves only named nodes.
 @end defun
 
-@defun treesit-next-sibling node &optional named
-This function finds the next sibling of @var{node}.  If @var{named} is
-non-@code{nil}, it finds the next named sibling.
-@end defun
+@c @defun treesit-next-sibling node &optional named
+@c This function finds the next sibling of @var{node}.  If @var{named} is
+@c non-@code{nil}, it finds the next named sibling.
+@c @end defun
 
-@defun treesit-prev-sibling node &optional named
-This function finds the previous sibling of @var{node}.  If
-@var{named} is non-@code{nil}, it finds the previous named sibling.
-@end defun
+@c @defun treesit-prev-sibling node &optional named
+@c This function finds the previous sibling of @var{node}.  If
+@c @var{named} is non-@code{nil}, it finds the previous named sibling.
+@c @end defun
 
 @subheading By field name
 @cindex nodes, by field name
@@ -696,31 +695,31 @@ Retrieving Nodes
 name, field name}).  For example, a @code{function_definition} node
 could have a @code{declarator} node and a @code{body} node.
 
-@defun treesit-child-by-field-name node field-name
-This function finds the child of @var{node} whose field name is
-@var{field-name}, a string.
-
-@example
-@group
-;; Get the child that has "body" as its field name.
-(treesit-child-by-field-name node "body")
-  @result{} #<treesit-node (compound_statement) in 45-89>
-@end group
-@end example
-@end defun
+@c @defun treesit-child-by-field-name node field-name
+@c This function finds the child of @var{node} whose field name is
+@c @var{field-name}, a string.
+@c
+@c @example
+@c @group
+@c ;; Get the child that has "body" as its field name.
+@c (treesit-child-by-field-name node "body")
+@c   @result{} #<treesit-node (compound_statement) in 45-89>
+@c @end group
+@c @end example
+@c @end defun
 
 @subheading By position
 @cindex nodes, by position
 @cindex syntax tree nodes, by position
 
-@defun treesit-first-child-for-pos node pos &optional named
-This function finds the first child of @var{node} that extends beyond
-buffer position @var{pos}.  ``Extends beyond'' means the end of the
-child node is greater or equal to @var{pos}.  This function only looks
-for immediate children of @var{node}, and doesn't look in its
-grandchildren.  If @var{named} is non-@code{nil}, it looks for the
-first named child (@pxref{tree-sitter named node, named node}).
-@end defun
+@c @defun treesit-first-child-for-pos node pos &optional named
+@c This function finds the first child of @var{node} that extends beyond
+@c buffer position @var{pos}.  ``Extends beyond'' means the end of the
+@c child node is greater or equal to @var{pos}.  This function only looks
+@c for immediate children of @var{node}, and doesn't look in its
+@c grandchildren.  If @var{named} is non-@code{nil}, it looks for the
+@c first named child (@pxref{tree-sitter named node, named node}).
+@c @end defun
 
 @defun treesit-node-descendant-for-range node beg end &optional named
 This function finds the @emph{smallest} descendant node of @var{node}
@@ -1002,11 +1001,11 @@ Accessing Node Information
 could be negative, e.g., @code{-1} represents the last child.
 @end defun
 
-@defun treesit-child-count node &optional named
-This function finds the number of children of @var{node}.  If
-@var{named} is non-@code{nil}, it only counts named children
-(@pxref{tree-sitter named node, named node}).
-@end defun
+@c defun treesit-child-count node &optional named
+@c This function finds the number of children of @var{node}.  If
+@c @var{named} is non-@code{nil}, it only counts named children
+@c (@pxref{tree-sitter named node, named node}).
+@c @end defun
 
 @node Pattern Matching
 @section Pattern Matching Tree-sitter Nodes
@@ -1694,7 +1693,7 @@ Tree-sitter Major Modes
   ...
   (cond
    ;; Tree-sitter setup.
-   ((treesit-ready-p 'woomy-mode 'woomy)
+   ((treesit-ready-p 'woomy)
     (setq-local treesit-variables ...)
     (treesit-major-mode-setup))
    ;; Non-tree-sitter setup.
@@ -1706,7 +1705,7 @@ Tree-sitter Major Modes
 First, the major mode should use @code{treesit-ready-p} to determine
 whether tree-sitter can be activated in this mode.
 
-@defun treesit-ready-p mode language &optional quiet
+@defun treesit-ready-p language &optional quiet
 This function checks for conditions for activating tree-sitter.  It
 checks whether Emacs was built with tree-sitter, whether the buffer's
 size is not too large for tree-sitter to handle it, and whether the
@@ -1734,7 +1733,7 @@ Tree-sitter Major Modes
 is non-@code{nil}, it sets up fontification.
 
 @item
-If @code{treesit-simple-indent-rules} (@pxref{Parser-based Font Lock})
+If @code{treesit-simple-indent-rules} (@pxref{Parser-based Indentation})
 is non-@code{nil}, it sets up indentation.
 
 @item
@@ -1897,12 +1896,12 @@ Tree-sitter C API
 ts_node_named_child_count               treesit-node-child-count
 ts_node_child_by_field_name             treesit-node-by-field-name
 ts_node_child_by_field_id
-ts_node_next_sibling                    treesit-next-sibling
-ts_node_prev_sibling                    treesit-prev-sibling
-ts_node_next_named_sibling              treesit-next-sibling
-ts_node_prev_named_sibling              treesit-prev-sibling
-ts_node_first_child_for_byte            treesit-first-child-for-pos
-ts_node_first_named_child_for_byte      treesit-first-child-for-pos
+ts_node_next_sibling
+ts_node_prev_sibling
+ts_node_next_named_sibling
+ts_node_prev_named_sibling
+ts_node_first_child_for_byte
+ts_node_first_named_child_for_byte
 ts_node_descendant_for_byte_range       treesit-descendant-for-range
 ts_node_descendant_for_point_range
 ts_node_named_descendant_for_byte_range treesit-descendant-for-range
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 933d53082f9..c9fdaccaeb5 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1288,8 +1288,7 @@ treesit--simple-indent-eval
                         (cdr exp))))
         ;; Presets override functions, so this condition comes before
         ;; `functionp'.
-        ((alist-get exp treesit-simple-indent-presets)
-         (alist-get exp treesit-simple-indent-presets))
+        ((alist-get exp treesit-simple-indent-presets))
         ((functionp exp) exp)
         ((symbolp exp)
          (if (null exp)
@@ -2914,9 +2913,9 @@ treesit
    :eg-result-string "#<treesit-node (init_declarator) in 5-10>")

-  (treesit-first-child-for-pos
-   :no-eval (treesit-first-child-for-pos node 1)
-   :eg-result-string "#<treesit-node (primitive_type) in 1-4>")
+  ;; (treesit-first-child-for-pos
+  ;;  :no-eval (treesit-first-child-for-pos node 1)
+  ;;  :eg-result-string "#<treesit-node (primitive_type) in 1-4>")
   (treesit-node-descendant-for-range
    :no-eval (treesit-node-descendant-for-range node 2 3)
    :eg-result-string "#<treesit-node (primitive_type) in 1-4>")
@@ -2992,9 +2991,9 @@ treesit
   (treesit-field-name-for-child
    :no-eval (treesit-field-name-for-child node)
    :eg-result "body")
-  (treesit-child-count
-   :no-eval (treesit-child-count node)
-   :eg-result 3)
+  ;; (treesit-child-count
+  ;;  :no-eval (treesit-child-count node)
+  ;;  :eg-result 3)

   "Pattern matching"