Function: c-ts-common--standalone-parent
c-ts-common--standalone-parent is a byte-compiled function defined in
c-ts-common.el.gz.
Signature
(c-ts-common--standalone-parent PARENT)
Documentation
Find the first parent that starts on a new line.
Start searching from PARENT, so if PARENT satisfies the condition, it'll be returned. Return the starting position of the parent, return nil if no parent satisfies the condition.
Unlike simple-indent's standalone preset, this function handles method chaining like
func
.method() <-- Considered standalone even if there's a "." in
.method() front of the node.
But ff treesit-simple-indent-standalone-predicate is non-nil, use that
for determining standalone line.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/c-ts-common.el.gz
(defun c-ts-common--standalone-parent (parent)
"Find the first parent that starts on a new line.
Start searching from PARENT, so if PARENT satisfies the condition, it'll
be returned. Return the starting position of the parent, return nil if
no parent satisfies the condition.
Unlike simple-indent's standalone preset, this function handles method
chaining like
func
.method() <-- Considered standalone even if there's a \".\" in
.method() front of the node.
But ff `treesit-simple-indent-standalone-predicate' is non-nil, use that
for determining standalone line."
(let (anchor)
(save-excursion
(catch 'term
(while parent
(goto-char (treesit-node-start parent))
(when (setq anchor
(if treesit-simple-indent-standalone-predicate
(funcall treesit-simple-indent-standalone-predicate
parent)
(c-ts-common--standalone-predicate parent)))
(throw 'term (if (numberp anchor) anchor (point))))
(setq parent (treesit-node-parent parent)))))))