summaryrefslogtreecommitdiff
path: root/lisp/progmodes/c-ts-mode.el
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2023-12-10 18:24:27 -0800
committerYuan Fu <casouri@gmail.com>2023-12-10 18:24:27 -0800
commit7f1bd69cd19504f2bd47e13c530a55ffca08e27d (patch)
tree6bb9aaf1a3d9969b7b757c4fa00694de618b5d86 /lisp/progmodes/c-ts-mode.el
parente23068cb9a1692fc3c50b0b386237a56cae201f4 (diff)
downloademacs-7f1bd69cd19504f2bd47e13c530a55ffca08e27d.tar.gz
emacs-7f1bd69cd19504f2bd47e13c530a55ffca08e27d.tar.bz2
emacs-7f1bd69cd19504f2bd47e13c530a55ffca08e27d.zip
Fix c-ts-mode bracketless indentation for BSD style (bug#66152)
* lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-styles): Make sure the BSD rules only apply to opening bracket (compound_statement), then bracketless statements will fallback to common rules. * test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: Copy the bracketless test from indent.erts to here.
Diffstat (limited to 'lisp/progmodes/c-ts-mode.el')
-rw-r--r--lisp/progmodes/c-ts-mode.el14
1 files changed, 7 insertions, 7 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 5606996eee2..ca831a9c5f9 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -515,13 +515,13 @@ MODE is either `c' or `cpp'."
((node-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
((parent-is "compound_statement") parent-bol c-ts-mode-indent-offset)
- ((parent-is "if_statement") parent-bol 0)
- ((parent-is "else_clause") parent-bol 0)
- ((parent-is "for_statement") parent-bol 0)
- ((parent-is "while_statement") parent-bol 0)
- ((parent-is "switch_statement") parent-bol 0)
- ((parent-is "case_statement") parent-bol 0)
- ((parent-is "do_statement") parent-bol 0)
+ ((match "compound_statement" "if_statement") standalone-parent 0)
+ ((match "compound_statement" "else_clause") standalone-parent 0)
+ ((match "compound_statement" "for_statement") standalone-parent 0)
+ ((match "compound_statement" "while_statement") standalone-parent 0)
+ ((match "compound_statement" "switch_statement") standalone-parent 0)
+ ((match "compound_statement" "case_statement") standalone-parent 0)
+ ((match "compound_statement" "do_statement") standalone-parent 0)
,@common))))
(defun c-ts-mode--top-level-label-matcher (node parent &rest _)