emacs-diffs
[Top][All Lists]
Advanced

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

emacs-30 cb421286d2e: Fix c++-ts-mode indentation for templace (bug#7226


From: Yuan Fu
Subject: emacs-30 cb421286d2e: Fix c++-ts-mode indentation for templace (bug#72263)
Date: Thu, 1 Aug 2024 03:01:39 -0400 (EDT)

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

    Fix c++-ts-mode indentation for templace (bug#72263)
    
    * lisp/progmodes/c-ts-mode.el:
    (c-ts-mode--indent-styles): Add rule for template.
    * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add test.
---
 lisp/progmodes/c-ts-mode.el                        |  3 ++-
 .../lisp/progmodes/c-ts-mode-resources/indent.erts | 28 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 2ac163d7a7e..6c406a8acd9 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -463,7 +463,8 @@ MODE is either `c' or `cpp'."
            ,@(when (eq mode 'cpp)
                '(((node-is "access_specifier") parent-bol 0)
                  ;; Indent the body of namespace definitions.
-                 ((parent-is "declaration_list") parent-bol 
c-ts-mode-indent-offset)))
+                 ((parent-is "declaration_list") parent-bol 
c-ts-mode-indent-offset)
+                 ((parent-is "template_declaration") parent-bol 0)))
 
 
            ;; int[5] a = { 0, 0, 0, 0 };
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts 
b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
index 24b244c1611..599173832b5 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
@@ -458,6 +458,34 @@ namespace test {
 }
 =-=-=
 
+Name: Namespace and template (bug#72263)
+
+=-=
+namespace A {
+
+T myfunction1(const char *fname)
+{
+}
+
+template <class T>
+T myfunction2(const char *fname)
+{
+}
+}
+=-=
+namespace A {
+
+  T myfunction1(const char *fname)
+  {
+  }
+
+  template <class T>
+  T myfunction2(const char *fname)
+  {
+  }
+}
+=-=-=
+
 Code:
   (lambda ()
     (c-ts-mode)



reply via email to

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