GNU bug report logs - #14008
Better autoindent for C++11 code?

Previous Next

Packages: cc-mode, emacs;

Reported by: Andrew Pennebaker <andrew.pennebaker <at> gmail.com>

Date: Wed, 20 Mar 2013 15:41:01 UTC

Severity: wishlist

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Kangas <stefan <at> marxist.se>
To: Andrew Pennebaker <andrew.pennebaker <at> gmail.com>
Cc: Alan Mackenzie <acm <at> muc.de>, 14008 <at> debbugs.gnu.org
Subject: bug#14008: Better autoindent for C++11 code?
Date: Sun, 13 Oct 2019 10:03:00 +0200
Andrew Pennebaker <andrew.pennebaker <at> gmail.com> 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




This bug report was last modified 5 years and 201 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.