Subject: bug#72263: 31.0.50; Wrong indentation c++-ts-mode

From: Yuan Fu <[email-masked]>
Date: Thu, 1 Aug 2024 00:03:52 -0700

Pushed a fix for the original bug to emacs-30. Now it indents like this:

namespace A {

  T myfunction1(const char *fname)
  {
  }

  template <class T>
  T myfunction2(const char *fname)
  {
  }
}

> On Jul 31, 2024, at 10:06 PM, Eli Zaretskii <[email-masked]> wrote:
> 
>> Date: Wed, 31 Jul 2024 23:09:53 +0200
>> From: Ergus <[email-masked]>
>> CC: [email-masked]
>> 
>> I found another indentation issue in if-else conditions without
>> parenthesis:
>> 
>> if (pid == 0)
>>   print "hello from the child"
>>   else
>>   print "hello from the parent"
>> 
>> The else is not indented properly:
> 
> The above is not valid C++ code, AFAIU, so I don't understand why you
> expect c++-ts-mode to handle it properly (and what exactly is "proper"
> indentation in that case?).

As Eli said, if you add the trailing semicolon then it indents fine. If the code isn’t grammatically correct it’s hard for tree-sitter modes to indent the code.

Yuan