emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 d68ff6016d 1/3: Fix c-ts-mode indentation (bug#61291)


From: Yuan Fu
Subject: emacs-29 d68ff6016d 1/3: Fix c-ts-mode indentation (bug#61291)
Date: Mon, 6 Feb 2023 21:29:53 -0500 (EST)

branch: emacs-29
commit d68ff6016d0ca011b5bf0fd05578fe1abb2e53a9
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Fix c-ts-mode indentation (bug#61291)
    
    Fix indentation for the semicolon in
    
    while (str_a[i++] == str_b[j++])
      ;
    
    * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): New rule.
    * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
---
 lisp/progmodes/c-ts-mode.el                         |  2 ++
 test/lisp/progmodes/c-ts-mode-resources/indent.erts | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 9381608166..1737b8c571 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -285,6 +285,8 @@ MODE is either `c' or `cpp'."
            ((node-is "}") point-min c-ts-common-statement-offset)
            ;; Opening bracket.
            ((node-is "compound_statement") point-min 
c-ts-common-statement-offset)
+           ;; Bug#61291.
+           ((match "expression_statement" nil "body") point-min 
c-ts-common-statement-offset)
 
            ,@(when (eq mode 'cpp)
                `(((node-is "field_initializer_list") parent-bol ,(* 
c-ts-mode-indent-offset 2)))))))
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts 
b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
index 6f64e1e795..2750526f89 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
@@ -144,6 +144,17 @@ int f2(int x,
 };
 =-=-=
 
+Name: Semi-colon in While Loop (bug#61291)
+
+=-=
+while (true)
+  ;
+for (int i = 0;
+     i < 5;
+     i++)
+  ;
+=-=-=
+
 Name: Multiline Block Comments 1 (bug#60270)
 
 =-=



reply via email to

[Prev in Thread] Current Thread [Next in Thread]