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.
This commit is contained in:
Yuan Fu 2024-07-31 23:45:26 -07:00
parent 1154d8aafe
commit cb421286d2
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 30 additions and 1 deletions

View file

@ -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 };

View file

@ -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)