From: Yuan Fu Date: Thu, 1 Aug 2024 06:45:26 +0000 (-0700) Subject: Fix c++-ts-mode indentation for templace (bug#72263) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0bad43e6c0b1a27bf86764c60172bf8971a22f0a;p=emacs.git 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) --- 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)