;; If the start of the previous sibling isn't at the
;; beginning of a line, something's probably not quite
;; right, go a step further. (E.g., comment after a
- ;; statement.)
+ ;; statement.) If the previous sibling is the first named
+ ;; node then anchor to that, e.g. when returning an aggregate
+ ;; and starting the items on the same line as {.
(_ (goto-char (treesit-node-start prev-sibling))
- (if (looking-back (rx bol (* whitespace))
- (line-beginning-position))
+ (if (or (looking-back (rx bol (* whitespace))
+ (line-beginning-position)))
+ (null (treesit-node-prev-sibling prev-sibling t))
(setq continue nil)
(setq prev-sibling
(treesit-node-prev-sibling prev-sibling)))))))
}
=-=-=
+Name: Return Compund Literal
+
+=-=
+struct pair { int fst, snd; };
+struct pair
+make_pair(int long_identifier_a[], int long_identifier_b[],
+ int offset_a, int offset_b)
+{
+ int base_offset = 10;
+ return (struct pair) { long_identifier_a[base_offset + offset_b],
+ long_identifier_b[base_offset + offset_b] };
+}
+
+=-=-=
+
Name: Switch-Case statement
=-=
}
=-=-=
+Name: Return Aggregate Initialized Struct
+
+=-=
+struct pair { int x, y; }
+pair
+make_pair(int long_identifier_a[], int long_identifier_b[],
+ int offset_a, int offset_b)
+{
+ int base_offset = 10;
+ return { long_identifier_a[base_offset + offset_b],
+ long_identifier_b[base_offset + offset_b] };
+}
+=-=
+struct pair { int x, y; }
+pair
+make_pair(int long_identifier_a[], int long_identifier_b[],
+ int offset_a, int offset_b)
+{
+ int base_offset = 10;
+ return { long_identifier_a[base_offset + offset_b],
+ long_identifier_b[base_offset + offset_b] };
+}
+=-=-=
+
Code:
(lambda ()
(c-ts-mode)