diff options
| author | Yuan Fu | 2025-01-12 23:03:41 -0800 |
|---|---|---|
| committer | Yuan Fu | 2025-01-12 23:03:41 -0800 |
| commit | 8cfa3447b71a3586378e90e5690da6c1faaa77b6 (patch) | |
| tree | 2777013644dffe5e857952e4b7046e5b632426bc | |
| parent | 04032cd00af7617c709140f3c80b5604b05c11e8 (diff) | |
| download | emacs-8cfa3447b71a3586378e90e5690da6c1faaa77b6.tar.gz emacs-8cfa3447b71a3586378e90e5690da6c1faaa77b6.zip | |
Add special indent rule for FOR_EACH_TAIL in c-ts-mode
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--emacs-macro-rules): New function
(c-ts-mode--simple-indent-rules): Add new rule.
| -rw-r--r-- | lisp/progmodes/c-ts-mode.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 99e624412b2..d0ed110abbb 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el | |||
| @@ -445,6 +445,18 @@ NODE and PARENT are the same as other indent rules." | |||
| 445 | (cons (funcall parent-bol) | 445 | (cons (funcall parent-bol) |
| 446 | c-ts-mode-indent-offset)))))) | 446 | c-ts-mode-indent-offset)))))) |
| 447 | 447 | ||
| 448 | (defun c-ts-mode--emacs-macro-rules (_ parent &rest _) | ||
| 449 | "Rules for indenting macros in Emacs C source. | ||
| 450 | |||
| 451 | PARENT is the same as other simple-indent rules." | ||
| 452 | (cond | ||
| 453 | ((and (treesit-node-match-p parent "function_definition") | ||
| 454 | (equal (treesit-node-text | ||
| 455 | (treesit-node-child-by-field-name parent "type")) | ||
| 456 | "FOR_EACH_TAIL")) | ||
| 457 | (cons (treesit-node-start parent) | ||
| 458 | c-ts-mode-indent-offset)))) | ||
| 459 | |||
| 448 | (defun c-ts-mode--simple-indent-rules (mode style) | 460 | (defun c-ts-mode--simple-indent-rules (mode style) |
| 449 | "Return the indent rules for MODE and STYLE. | 461 | "Return the indent rules for MODE and STYLE. |
| 450 | 462 | ||
| @@ -466,6 +478,7 @@ MODE can be `c' or `cpp'. STYLE can be `gnu', `k&r', `linux', `bsd'." | |||
| 466 | c-ts-mode--label-indent-rules | 478 | c-ts-mode--label-indent-rules |
| 467 | ,@c-ts-mode--preproc-indent-rules | 479 | ,@c-ts-mode--preproc-indent-rules |
| 468 | c-ts-mode--macro-heuristic-rules | 480 | c-ts-mode--macro-heuristic-rules |
| 481 | c-ts-mode--emacs-macro-rules | ||
| 469 | 482 | ||
| 470 | ;; Make sure type and function definition components align and | 483 | ;; Make sure type and function definition components align and |
| 471 | ;; don't indent. Also takes care of GNU style opening braces. | 484 | ;; don't indent. Also takes care of GNU style opening braces. |