Subject: Re: bug#14008: Better autoindent for C++11 code?

From: Stefan Kangas <[email-masked]>
Date: Sun, 13 Oct 2019 10:03:00 +0200

Andrew Pennebaker <[email-masked]> writes:

> C++11 introduced lambda syntax []() { ... } and other strange things that Emacs indents strangely.
>
> for_each(range.begin(), range.end(), [=](int i) {
>     cout << strings[i] << endl;
>   });
>
> I would like the final line `});` to have the same indentation level as the first line `for_each...`.

I'm seeing the same thing here.

With "emacs -Q" on current master, this indents like:

for_each(range.begin(), range.end(), [=](int i) {
  cout << strings[i] << endl;
 });

However, note that I have only one space before the final "}"
character, whereas the reporter had two.  I'm not sure if this
behaviour is intentional or not, or if it could be configured.

> Here's another example:
>
> for_each(range.begin(), range.end(), [&](int i) {
>              std::async(
>                         launch::async,
>                         [&]() { strings[i] = fizzy(i); }
>                         );
>   });
>
> The arguments to std::async and its closing parenthesis are indented much too far; I would like them indented only one level further than where std::async is itself indented. Any tips for achieving this?

I'm seeing something similar here:

for_each(range.begin(), range.end(), [&](int i) {
  std::async(
         launch::async,
         [&]() { strings[i] = fizzy(i); }
         );
 });

Perhaps Alan could clarify if this is a bug or if this is just a case
of missing configuration?

Best regards,
Stefan Kangas