parser; if @var{parser-or-lang} is a language, this function uses the
first parser for that language in the current buffer, or creates one
if none exists; if @var{parser-or-lang} is @code{nil}, this function
-tries to guess the language at @var{pos} by
-@code{treesit-language-at}.
+tries to guess the language at @var{pos} by calling
+@code{treesit-language-at} (@pxref{Multiple Languages}).
If this function cannot find a suitable node to return, it returns
@code{nil}.
parser; if @var{parser-or-lang} is a language, this function uses the
first parser for that language in the current buffer, or creates one
if none exists; if @var{parser-or-lang} is @code{nil}, this function
-tries to guess the language at @var{beg} by
+tries to guess the language at @var{beg} by calling
@code{treesit-language-at}.
If @var{named} is non-@code{nil}, this function looks for a named node
Currently, it sets up the following features:
@itemize
+@cindex treesit-font-lock-settings
@item
If @code{treesit-font-lock-settings} is non-@code{nil}, it sets up
fontification.
+
+@cindex treesit-simple-indent-rules
@item
If @code{treesit-simple-indent-rules} is non-@code{nil}, it sets up
indentation.
+
+@cindex treesit-defun-type-regexp
@item
If @code{treesit-defun-type-regexp} is non-@code{nil}, it sets up
navigation functions for @code{beginning-of-defun} and
@code{end-of-defun}.
+
@item
If @code{treesit-defun-name-function} is non-@code{nil}, it sets up
add-log functions used by @code{add-log-current-defun}.
@defun treesit-defun-at-point
This function returns the defun node at point, or @code{nil} if none
-is found. It respects @code{treesit-defun-tactic}: it returns the
-top-level defun if the value is @code{top-level}, and returns the
-immediate enclosing defun if the value is @code{nested}.
+is found. It respects @code{treesit-defun-tactic}: if its value is
+@code{top-level}, this function returns the top-level defun, and if
+its value is @code{nested}, it returns the immediate enclosing defun.
This function requires @code{treesit-defun-type-regexp} to work. If
it is @code{nil}, this function simply returns @code{nil}.
@code{nil} if there is no defun name for @var{node}, or if @var{node}
is not a defun node, or if @var{node} is @code{nil}.
-The defun name is names like function name, class name, struct name,
-etc.
+Depending on the language and major mode, the defun names are names
+like function name, class name, struct name, etc.
If @code{treesit-defun-name-function} is @code{nil}, this function
always returns @code{nil}.
@end defun
@defvar treesit-defun-name-function
-If non-@code{nil}, this variable should store a function that is
-called with a node and returns the defun name of it. The function
-should have the same semantic as @code{treesit-defun-name}: if the
-node is not a defun node, or the node is a defun node but doesn't have
-a name, or the node is @code{nil}, return @code{nil}.
+If non-@code{nil}, this variable's value should be a function that is
+called with a node as its argument, and returns the defun name of the
+node. The function should have the same semantic as
+@code{treesit-defun-name}: if the node is not a defun node, or the
+node is a defun node but doesn't have a name, or the node is
+@code{nil}, it should return @code{nil}.
@end defvar
@node Tree-sitter C API
If PARSER-OR-LANG is a parser, use that parser; if PARSER-OR-LANG
is a language, find the first parser for that language in the
current buffer, or create one if none exists; If PARSER-OR-LANG
-is nil, try to guess the language at POS by
-`treesit-language-at'."
+is nil, try to guess the language at POS using `treesit-language-at'."
(let* ((root (if (treesit-parser-p parser-or-lang)
(treesit-parser-root-node parser-or-lang)
(treesit-buffer-root-node
If PARSER-OR-LANG is a parser, use that parser; if PARSER-OR-LANG
is a language, find the first parser for that language in the
current buffer, or create one if none exists; If PARSER-OR-LANG
-is nil, try to guess the language at BEG by
-`treesit-language-at'."
+is nil, try to guess the language at BEG using `treesit-language-at'."
(let ((root (if (treesit-parser-p parser-or-lang)
(treesit-parser-root-node parser-or-lang)
(treesit-buffer-root-node
If the value is nil, no skipping is performed.")
(defvar-local treesit-defun-name-function nil
- "A function called with a node and returns the name of it.
-If the node is a defun node, return the defun name. E.g., the
+ "A function that is called with a node and returns its defun name or nil.
+If the node is a defun node, return the defun name, e.g., the
function name of a function. If the node is not a defun node, or
the defun node doesn't have a name, or the node is nil, return
nil.")