unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Kangas <stefan@marxist.se>
Cc: 14008@debbugs.gnu.org
Subject: bug#14008: Better autoindent for C++11 code?
Date: Thu, 7 Nov 2019 18:19:40 +0000	[thread overview]
Message-ID: <20191107181940.GA4846@ACM> (raw)
In-Reply-To: <87blttdr6e.fsf@marxist.se>

Hello, Stefan.

On Sun, Nov 03, 2019 at 14:29:13 +0100, Stefan Kangas wrote:
> Hi Alan,

> Alan Mackenzie <acm@muc.de> 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.

> > I think this is the minimum indentation imposed on all lines within "code
> > blocks" in "gnu" style.  (See the CC Mode manual for a description of CC
> > Mode's style system.)  If you indent the for_each line by, say, 4 columns
> > (put it inside braces if needed) the line with }); then gets indented
> > under the for_each.  As for_each is a function (pretty much equivalent to
> > Lisp's mapc), it's unlikely to be put at column 0 in real source code.

> Indeed.  It seems to work better when you put it in a function.

> >> > 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?

> > Configure CC Mode, either by activating a different style (with C-c ., or
> > M-x c-set-style if some minor mode is using that key binding), or by
> > directly setting syntactic symbols' "offsets".
> [...]
> > Again, I strongly recommend reading the relevant pages in the CC Mode
> > manual.
> [...]
> >> Perhaps Alan could clarify if this is a bug or if this is just a case
> >> of missing configuration?

> > A bit of a mixture of both, I think.

> Do you think there is anything more to do here, or should this bug be
> closed?

I think the bug should now be closed.

> Best regards,
> Stefan Kangas

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2019-11-07 18:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20 15:38 bug#14008: Better autoindent for C++11 code? Andrew Pennebaker
2019-10-13  8:03 ` Stefan Kangas
2019-10-13 18:09   ` Alan Mackenzie
2019-11-03 13:29     ` Stefan Kangas
2019-11-07 18:19       ` Alan Mackenzie [this message]
2019-11-07 23:41         ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191107181940.GA4846@ACM \
    --to=acm@muc.de \
    --cc=14008@debbugs.gnu.org \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).