From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#14008: Better autoindent for C++11 code? Date: Thu, 7 Nov 2019 18:19:40 +0000 Message-ID: <20191107181940.GA4846@ACM> References: <20191013180949.GE10125@ACM> <87blttdr6e.fsf@marxist.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="184557"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 14008@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 07 19:20:20 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iSmOJ-000lqL-TR for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Nov 2019 19:20:20 +0100 Original-Received: from localhost ([::1]:46996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSmOI-0000Am-Kp for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Nov 2019 13:20:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32850) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSmO9-00008U-QF for bug-gnu-emacs@gnu.org; Thu, 07 Nov 2019 13:20:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSmO8-0002MA-Hl for bug-gnu-emacs@gnu.org; Thu, 07 Nov 2019 13:20:09 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35065) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iSmO2-0002Kp-Sk; Thu, 07 Nov 2019 13:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iSmO2-0004xX-IE; Thu, 07 Nov 2019 13:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 07 Nov 2019 18:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14008 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 14008-submit@debbugs.gnu.org id=B14008.157315078519037 (code B ref 14008); Thu, 07 Nov 2019 18:20:02 +0000 Original-Received: (at 14008) by debbugs.gnu.org; 7 Nov 2019 18:19:45 +0000 Original-Received: from localhost ([127.0.0.1]:43886 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iSmNl-0004wz-Fg for submit@debbugs.gnu.org; Thu, 07 Nov 2019 13:19:45 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:64117 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1iSmNj-0004wp-GW for 14008@debbugs.gnu.org; Thu, 07 Nov 2019 13:19:44 -0500 Original-Received: (qmail 89804 invoked by uid 3782); 7 Nov 2019 18:19:42 -0000 Original-Received: from acm.muc.de (p4FE15AAD.dip0.t-ipconnect.de [79.225.90.173]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 07 Nov 2019 19:19:40 +0100 Original-Received: (qmail 9331 invoked by uid 1000); 7 Nov 2019 18:19:40 -0000 Content-Disposition: inline In-Reply-To: <87blttdr6e.fsf@marxist.se> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:171106 Archived-At: Hello, Stefan. On Sun, Nov 03, 2019 at 14:29:13 +0100, Stefan Kangas wrote: > Hi Alan, > Alan Mackenzie 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).