From 0bad43e6c0b1a27bf86764c60172bf8971a22f0a Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 31 Jul 2024 23:45:26 -0700 Subject: [PATCH] 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. (cherry picked from commit cb421286d2e9834d90d29288c932a6c6e03a555f) --- lisp/progmodes/c-ts-mode.el | 3 +- .../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 b2fe847d306..ad3e99b5d1f 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -466,7 +466,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 +T myfunction2(const char *fname) +{ +} +} +=-= +namespace A { + + T myfunction1(const char *fname) + { + } + + template + T myfunction2(const char *fname) + { + } +} +=-=-= + Code: (lambda () (c-ts-mode) -- 2.39.2