Function: c-ts-common--prev-standalone-sibling

c-ts-common--prev-standalone-sibling is a byte-compiled function defined in c-ts-common.el.gz.

Signature

(c-ts-common--prev-standalone-sibling NODE)

Documentation

Return the start of the previous sibling of NODE that starts on a new line.

Return nil if no sibling 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--prev-standalone-sibling (node)
  "Return the start of the previous sibling of NODE that starts on a new line.
Return nil if no sibling 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."
  (save-excursion
    (setq node (treesit-node-prev-sibling node 'named))
    (goto-char (treesit-node-start node))
    (let (anchor)
      (while (and node
                  (goto-char (treesit-node-start node))
                  (not (setq anchor
                             (if treesit-simple-indent-standalone-predicate
                                 (funcall
                                  treesit-simple-indent-standalone-predicate
                                  node)
                               (c-ts-common--standalone-predicate node)))))
        (setq node (treesit-node-prev-sibling node 'named)))
      (if (numberp anchor) anchor (treesit-node-start node)))))