Function: c-ts-mode--label-indent-rules
c-ts-mode--label-indent-rules is a byte-compiled function defined in
c-ts-mode.el.gz.
Signature
(c-ts-mode--label-indent-rules NODE PARENT BOL &rest ARGS)
Documentation
Handles indentation around labels.
NODE, PARENT, BOL, ARGS are as usual.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/c-ts-mode.el.gz
(defun c-ts-mode--label-indent-rules (node parent bol &rest args)
"Handles indentation around labels.
NODE, PARENT, BOL, ARGS are as usual."
(cond
;; Matches the top-level labels for GNU-style.
((and (eq c-ts-mode-indent-style 'gnu)
(treesit-node-match-p node "labeled_statement")
(treesit-node-match-p (treesit-node-parent parent)
"function_definition"))
(cons (pos-bol) 1))
;; Indent the label itself.
((treesit-node-match-p node "labeled_statement")
(cons (c-ts-mode--standalone-parent node parent bol args)
0))
;; Indent the statement below the label.
((treesit-node-match-p parent "labeled_statement")
(cons (c-ts-mode--standalone-parent node parent bol args)
c-ts-mode-indent-offset))
;; If previous sibling is a labeled_statement, align to it's
;; children, which is the previous statement.
((and (not (treesit-node-match-p node "}"))
(treesit-node-match-p (treesit-node-prev-sibling node)
"labeled_statement"))
(cons (c-ts-mode--prev-sibling node parent bol args)
0))
(t nil)))