rule is applicable. Then Emacs passes the node to @var{anchor}, which
returns a buffer position. Emacs takes the column number of that
position, adds @var{offset} to it, and the result is the indentation
-column for the current line. @var{offset} can be an integer or a
-variable whose value is an integer.
+column for the current line.
The @var{matcher} and @var{anchor} are functions, and Emacs provides
convenient defaults for them.
@var{node} is @code{nil}. In that case, @var{parent} would be the
smallest node that spans that position.
-Emacs finds @var{bol}, @var{node} and @var{parent} and
-passes them to each @var{matcher} and @var{anchor}. @var{matcher}
-should return non-@code{nil} if the rule is applicable, and
-@var{anchor} should return a buffer position.
+@var{matcher} should return non-@code{nil} if the rule is applicable,
+and @var{anchor} should return a buffer position.
+
+@var{offset} can be an integer, a variable whose value is an integer,
+or a function that returns an integer. If it is a function, it is
+passed @var{node}, @var{parent}, and @var{bol}, like matchers and
+anchors.
@end defvar
@defvar treesit-simple-indent-presets
return
(let ((anchor-pos
(treesit--simple-indent-eval
- (list anchor node parent bol))))
- (cons anchor-pos (if (symbolp offset)
- (symbol-value offset)
- offset)))
+ (list anchor node parent bol)))
+ (offset-val
+ (cond ((numberp offset) offset)
+ ((and (symbolp offset)
+ (boundp offset))
+ (symbol-value offset))
+ (t (treesit--simple-indent-eval
+ (list offset node parent bol))))))
+ (cons anchor-pos offset-val))
finally return
(progn (when treesit--indent-verbose
(message "No matched rule"))