From unknown Mon Jun 23 13:13:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14008: Better autoindent for C++11 code? Resent-From: Andrew Pennebaker Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Mar 2013 15:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14008 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 14008@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.136379405817743 (code B ref -1); Wed, 20 Mar 2013 15:41:01 +0000 Received: (at submit) by debbugs.gnu.org; 20 Mar 2013 15:40:58 +0000 Received: from localhost ([127.0.0.1]:37798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UIL8L-0004c7-5b for submit@debbugs.gnu.org; Wed, 20 Mar 2013 11:40:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45999) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UIL8J-0004c0-16 for submit@debbugs.gnu.org; Wed, 20 Mar 2013 11:40:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIL6a-0008OO-44 for submit@debbugs.gnu.org; Wed, 20 Mar 2013 11:39:09 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-101.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID,USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:60097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIL6a-0008OK-1v for submit@debbugs.gnu.org; Wed, 20 Mar 2013 11:39:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIL6U-0005bm-Oi for bug-gnu-emacs@gnu.org; Wed, 20 Mar 2013 11:39:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIL6R-0008Mo-DD for bug-gnu-emacs@gnu.org; Wed, 20 Mar 2013 11:39:02 -0400 Received: from mail-ia0-x232.google.com ([2607:f8b0:4001:c02::232]:61163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIL6R-0008MT-9I for bug-gnu-emacs@gnu.org; Wed, 20 Mar 2013 11:38:59 -0400 Received: by mail-ia0-f178.google.com with SMTP id r13so474614iar.9 for ; Wed, 20 Mar 2013 08:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=LE2VCbonnVxQhB7CWDVTeUZbDVyk9MoqUSqojicnrRU=; b=irQQzsS54T72fSm/h4zzLLEnmNG5gqRm39cC2gY4jBWuIxvXhIV4UNO7yNW8ofixhL f+g3vDGSmW3+VTWKVAotQwnOPmnBrBECwOWaOl/P/qgDxKdmEyQ3hRl4aMeETNPMtqs0 v0L27MHhM7f9wE8ehsoiRljKKRIz4Jp4jNfNvlTR9ZvrmWml4XAu7LWD865YlKTuJqwG KoW0BbkrmWrJLPdqSY0n6dQaAlyPHdG489HNsFVklfwI761h1fcT/JVIibqIKvb+5pld TwSmMUA+4uDDGWq3o1VXEipvhrsBxavC+j1qaMPhW37c0MakuvGs3LBH3jsXaWSqblkn zO9Q== MIME-Version: 1.0 X-Received: by 10.50.236.100 with SMTP id ut4mr1781363igc.86.1363793938244; Wed, 20 Mar 2013 08:38:58 -0700 (PDT) Received: by 10.42.110.194 with HTTP; Wed, 20 Mar 2013 08:38:58 -0700 (PDT) Date: Wed, 20 Mar 2013 11:38:58 -0400 Message-ID: From: Andrew Pennebaker Content-Type: multipart/alternative; boundary=14dae9399de33c848a04d85d05c5 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) --14dae9399de33c848a04d85d05c5 Content-Type: text/plain; charset=ISO-8859-1 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...`. 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? -- Cheers, Andrew Pennebaker www.yellosoft.us --14dae9399de33c848a04d85d05c5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
C++11 introduced lambda syntax []() { ... } and other= strange things that Emacs indents strangely.

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

I would like the final line `});` to ha= ve the same indentation level as the first line `for_each...`.

Here's another example:

for_each(range.begin(), range.end(), [&= amp;](int i) {
=A0 = =A0 =A0 =A0 =A0 =A0 =A0std::async(
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 launch::async,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 [&]() { stri= ngs[i] =3D fizzy(i); }
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 );
=A0 });

The arguments to std::async and its closing parenthesis are indente= d much too far; I would like them indented only one level further than wher= e std::async is itself indented. Any tips for achieving this?

--
Cheers,

Andrew Pennebak= er
--14dae9399de33c848a04d85d05c5-- From unknown Mon Jun 23 13:13:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14008: Better autoindent for C++11 code? References: In-Reply-To: Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 13 Oct 2019 08:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14008 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: Andrew Pennebaker Cc: Alan Mackenzie , 14008@debbugs.gnu.org Received: via spool by 14008-submit@debbugs.gnu.org id=B14008.157095385414177 (code B ref 14008); Sun, 13 Oct 2019 08:05:01 +0000 Received: (at 14008) by debbugs.gnu.org; 13 Oct 2019 08:04:14 +0000 Received: from localhost ([127.0.0.1]:34879 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iJYrO-0003gb-4k for submit@debbugs.gnu.org; Sun, 13 Oct 2019 04:04:14 -0400 Received: from mail-pf1-f176.google.com ([209.85.210.176]:45468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iJYrM-0003gM-D7 for 14008@debbugs.gnu.org; Sun, 13 Oct 2019 04:04:13 -0400 Received: by mail-pf1-f176.google.com with SMTP id y72so8585335pfb.12 for <14008@debbugs.gnu.org>; Sun, 13 Oct 2019 01:04:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=iWnOwYb2TUn0U03O1PLxL+1o4QT89GXmLaz6+5gZVMM=; b=dHwXdtNdCk6ZzQojnS45/NWmr1E6wKdK4AV1xMeqt4v2Mog5yjpOr5YC0EOSvmHD+Y KcfjXb60/uOMqBaz2S8K6Eym/1zK7CBowgyAFU5ic9WFWJ8HNoKAXoGFyXTfYfm5hlmG mnz95uoZGLcoPnoBrJ13xpx2Xp3aRZaNr4oZpYkn5+Ths0ikMdqtLt5j2DCj6F/tVNJm 92KbGtKOv5E0Xb1JLJfAb0ihPJlsw+3AekIXna9hOfZgsYh1KqzXGSVlxnmCY4Wz29Uy aLHFF1WxVP1I34P0Qopjbwvnht4BR+oGoU+TVN3cJghmDLrYfNyUUHEu1cCeLb/6VbvS mneA== X-Gm-Message-State: APjAAAVe7WUSepyQQg0711qbar2a0ytHVJCE6ooc59hjwTT15SElFw9s jPySjvziHfC5yAW12ks7gBA++X9m3M6o28EGeLU= X-Google-Smtp-Source: APXvYqwET+62rz5KTKfcoKeK+nTsWscbTzn8IXI0EQ9aE5/kbKSDV9Huh2tWPjeh0zUjplFWbMb9og6f9FIYnvDW0nw= X-Received: by 2002:a63:1c03:: with SMTP id c3mr25737735pgc.198.1570953846562; Sun, 13 Oct 2019 01:04:06 -0700 (PDT) MIME-Version: 1.0 From: Stefan Kangas Date: Sun, 13 Oct 2019 10:03:00 +0200 Message-ID: Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.2 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Andrew Pennebaker 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 From unknown Mon Jun 23 13:13:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14008: Better autoindent for C++11 code? Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 13 Oct 2019 18:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14008 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: Stefan Kangas Cc: Andrew Pennebaker , 14008@debbugs.gnu.org Received: via spool by 14008-submit@debbugs.gnu.org id=B14008.157099019732619 (code B ref 14008); Sun, 13 Oct 2019 18:10:02 +0000 Received: (at 14008) by debbugs.gnu.org; 13 Oct 2019 18:09:57 +0000 Received: from localhost ([127.0.0.1]:36889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iJiJZ-0008U3-1U for submit@debbugs.gnu.org; Sun, 13 Oct 2019 14:09:57 -0400 Received: from colin.muc.de ([193.149.48.1]:54531 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1iJiJW-0008Ts-Gb for 14008@debbugs.gnu.org; Sun, 13 Oct 2019 14:09:55 -0400 Received: (qmail 91338 invoked by uid 3782); 13 Oct 2019 18:09:52 -0000 Received: from acm.muc.de (p2E5D5B34.dip0.t-ipconnect.de [46.93.91.52]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 13 Oct 2019 20:09:50 +0200 Received: (qmail 12802 invoked by uid 1000); 13 Oct 2019 18:09:50 -0000 Date: Sun, 13 Oct 2019 18:09:49 +0000 Message-ID: <20191013180949.GE10125@ACM> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Stefan and Andrew. On Sun, Oct 13, 2019 at 10:03:00 +0200, Stefan Kangas wrote: > Andrew Pennebaker 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. > 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. I'm surprised about the two spaces too, I don't understand how it could have happened, unless there's been some disruption in the copying from Emacs screen to email. > > 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". For the first possibility, I'd recommend trying out, say styles "bsd" or "linux". For the second, there are several ways to set symbols' offsets (see page "Config Basics" in the CC Mode manual). A good way is by using a hook function. To find out what syntactic symbols you need to change, put point on a pertinent line and type C-c C-s. For example on the "launch::async" line you'd see something like "((arglist-intro 394 404))", the two numbers being the "anchor points" from which the indentation is done. To see (and change temporarily) the "offset" for a symbol, type C-c C-o. The "gnu" style setting of the "offset" for arglist-intro is the function c-lineup-arglist-intro-after-paren, which does pretty much what its name says. I think you want a simple extra level of indentation from point 394, so you could construct your hook function something like this: (defun my-c-indent () (c-set-offset 'arglist-intro '+) ;; Add any further syntactic symbols here. ) (add-hook 'c-mode-common-hook #'my-c-indent) ; c++-mode-hook could also ; be used Again, I strongly recommend reading the relevant pages in the CC Mode manual. > 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? A bit of a mixture of both, I think. > Best regards, > Stefan Kangas -- Alan Mackenzie (Nuremberg, Germany). From unknown Mon Jun 23 13:13:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14008: Better autoindent for C++11 code? Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 03 Nov 2019 13:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14008 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: Alan Mackenzie Cc: Andrew Pennebaker , 14008@debbugs.gnu.org Received: via spool by 14008-submit@debbugs.gnu.org id=B14008.157278776411973 (code B ref 14008); Sun, 03 Nov 2019 13:30:02 +0000 Received: (at 14008) by debbugs.gnu.org; 3 Nov 2019 13:29:24 +0000 Received: from localhost ([127.0.0.1]:33493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iRFwa-000373-HV for submit@debbugs.gnu.org; Sun, 03 Nov 2019 08:29:24 -0500 Received: from host.gofardesign.uk ([208.79.239.190]:55933) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iRFwY-00036o-FW for 14008@debbugs.gnu.org; Sun, 03 Nov 2019 08:29:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=marxist.se; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TLaxJhXLXpDFN62rinvh3XWQuLzZx/n0TW3F5xl/1l8=; b=me5DI7i6mwHya+yENUMJVKtYkn HAwpqIu+SmAVFIdSdDTAECM7Xo51xbi6eF2DX5I2tXvapgr6x9e189youJfQtt2Sk/8PWqark+x7y uN9ZwZAzc/O+cPMDRtp5EQG3GIHj/D7Ls4iEWfA+mhbqoBb4EEEmSGzmtTD2zDOFWC1E=; Received: from h-70-69.a785.priv.bahnhof.se ([155.4.70.69]:39232 helo=localhost) by host.gofardesign.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iRFwQ-0003sZ-W2; Sun, 03 Nov 2019 07:29:16 -0600 From: Stefan Kangas In-Reply-To: <20191013180949.GE10125@ACM> (Alan Mackenzie's message of "Sun, 13 Oct 2019 18:09:49 +0000") References: <20191013180949.GE10125@ACM> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Date: Sun, 03 Nov 2019 14:29:13 +0100 Message-ID: <87blttdr6e.fsf@marxist.se> MIME-Version: 1.0 Content-Type: text/plain X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.gofardesign.uk X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - marxist.se X-Get-Message-Sender-Via: host.gofardesign.uk: authenticated_id: stefan@marxist.se X-Authenticated-Sender: host.gofardesign.uk: stefan@marxist.se X-Source: X-Source-Args: X-Source-Dir: X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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? Best regards, Stefan Kangas From unknown Mon Jun 23 13:13:15 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14008: Better autoindent for C++11 code? 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 X-GNU-PR-Keywords: To: Stefan Kangas Cc: Andrew Pennebaker , 14008@debbugs.gnu.org Received: via spool by 14008-submit@debbugs.gnu.org id=B14008.157315078519037 (code B ref 14008); Thu, 07 Nov 2019 18:20:02 +0000 Received: (at 14008) by debbugs.gnu.org; 7 Nov 2019 18:19:45 +0000 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 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 Received: (qmail 89804 invoked by uid 3782); 7 Nov 2019 18:19:42 -0000 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 Received: (qmail 9331 invoked by uid 1000); 7 Nov 2019 18:19:40 -0000 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 Content-Disposition: inline In-Reply-To: <87blttdr6e.fsf@marxist.se> User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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). From unknown Mon Jun 23 13:13:15 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Andrew Pennebaker Subject: bug#14008: closed (Re: bug#14008: Better autoindent for C++11 code?) Message-ID: References: <87ftizz23i.fsf@marxist.se> X-Gnu-PR-Message: they-closed 14008 X-Gnu-PR-Package: emacs,cc-mode Reply-To: 14008@debbugs.gnu.org Date: Thu, 07 Nov 2019 23:42:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1573170121-26201-1" This is a multi-part message in MIME format... ------------=_1573170121-26201-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14008: Better autoindent for C++11 code? which was filed against the emacs,cc-mode package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 14008@debbugs.gnu.org. --=20 14008: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14008 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1573170121-26201-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 14008-done) by debbugs.gnu.org; 7 Nov 2019 23:41:37 +0000 Received: from localhost ([127.0.0.1]:44130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iSrPE-0006ns-Cn for submit@debbugs.gnu.org; Thu, 07 Nov 2019 18:41:36 -0500 Received: from host.gofardesign.uk ([208.79.239.190]:56443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iSrPA-0006nd-SN for 14008-done@debbugs.gnu.org; Thu, 07 Nov 2019 18:41:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=marxist.se; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=cqC9A/+K/kc0N+4yMoqe/Juq+L4saFF8tkJel3UZ1t8=; b=qWz7+kUvypAGBgJGq7QJG34wXX KFsRVrqxpdU6oilZdZ6wKTwKnM6lsSP+D5aTtbpMccjH5ftxhh8l5uB7aeTOcz2AB/t7/Z/uWjwp3 Wo1UijLLjKXUM4jD8O0QoZIedfr+ccaPd7hVFQIXs6LpIx9kT5hYH8YoB0dDIHVYLi8Y=; Received: from h-70-69.a785.priv.bahnhof.se ([155.4.70.69]:37068 helo=localhost) by host.gofardesign.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iSrP1-0001w2-RI; Thu, 07 Nov 2019 17:41:24 -0600 From: Stefan Kangas To: Alan Mackenzie Subject: Re: bug#14008: Better autoindent for C++11 code? In-Reply-To: <20191107181940.GA4846@ACM> (Alan Mackenzie's message of "Thu, 7 Nov 2019 18:19:40 +0000") References: <20191013180949.GE10125@ACM> <87blttdr6e.fsf@marxist.se> <20191107181940.GA4846@ACM> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Date: Fri, 08 Nov 2019 00:41:21 +0100 Message-ID: <87ftizz23i.fsf@marxist.se> MIME-Version: 1.0 Content-Type: text/plain X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.gofardesign.uk X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - marxist.se X-Get-Message-Sender-Via: host.gofardesign.uk: authenticated_id: stefan@marxist.se X-Authenticated-Sender: host.gofardesign.uk: stefan@marxist.se X-Source: X-Source-Args: X-Source-Dir: X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 14008-done Cc: Andrew Pennebaker , 14008-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Alan Mackenzie writes: >> Do you think there is anything more to do here, or should this bug be >> closed? > > I think the bug should now be closed. Thanks, I'm therefore closing this bug now. Best regards, Stefan Kangas ------------=_1573170121-26201-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 20 Mar 2013 15:40:58 +0000 Received: from localhost ([127.0.0.1]:37798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UIL8L-0004c7-5b for submit@debbugs.gnu.org; Wed, 20 Mar 2013 11:40:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45999) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UIL8J-0004c0-16 for submit@debbugs.gnu.org; Wed, 20 Mar 2013 11:40:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIL6a-0008OO-44 for submit@debbugs.gnu.org; Wed, 20 Mar 2013 11:39:09 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-101.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID,USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:60097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIL6a-0008OK-1v for submit@debbugs.gnu.org; Wed, 20 Mar 2013 11:39:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIL6U-0005bm-Oi for bug-gnu-emacs@gnu.org; Wed, 20 Mar 2013 11:39:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIL6R-0008Mo-DD for bug-gnu-emacs@gnu.org; Wed, 20 Mar 2013 11:39:02 -0400 Received: from mail-ia0-x232.google.com ([2607:f8b0:4001:c02::232]:61163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIL6R-0008MT-9I for bug-gnu-emacs@gnu.org; Wed, 20 Mar 2013 11:38:59 -0400 Received: by mail-ia0-f178.google.com with SMTP id r13so474614iar.9 for ; Wed, 20 Mar 2013 08:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=LE2VCbonnVxQhB7CWDVTeUZbDVyk9MoqUSqojicnrRU=; b=irQQzsS54T72fSm/h4zzLLEnmNG5gqRm39cC2gY4jBWuIxvXhIV4UNO7yNW8ofixhL f+g3vDGSmW3+VTWKVAotQwnOPmnBrBECwOWaOl/P/qgDxKdmEyQ3hRl4aMeETNPMtqs0 v0L27MHhM7f9wE8ehsoiRljKKRIz4Jp4jNfNvlTR9ZvrmWml4XAu7LWD865YlKTuJqwG KoW0BbkrmWrJLPdqSY0n6dQaAlyPHdG489HNsFVklfwI761h1fcT/JVIibqIKvb+5pld TwSmMUA+4uDDGWq3o1VXEipvhrsBxavC+j1qaMPhW37c0MakuvGs3LBH3jsXaWSqblkn zO9Q== MIME-Version: 1.0 X-Received: by 10.50.236.100 with SMTP id ut4mr1781363igc.86.1363793938244; Wed, 20 Mar 2013 08:38:58 -0700 (PDT) Received: by 10.42.110.194 with HTTP; Wed, 20 Mar 2013 08:38:58 -0700 (PDT) Date: Wed, 20 Mar 2013 11:38:58 -0400 Message-ID: Subject: Better autoindent for C++11 code? From: Andrew Pennebaker To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary=14dae9399de33c848a04d85d05c5 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) --14dae9399de33c848a04d85d05c5 Content-Type: text/plain; charset=ISO-8859-1 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...`. 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? -- Cheers, Andrew Pennebaker www.yellosoft.us --14dae9399de33c848a04d85d05c5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
C++11 introduced lambda syntax []() { ... } and other= strange things that Emacs indents strangely.

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

I would like the final line `});` to ha= ve the same indentation level as the first line `for_each...`.

Here's another example:

for_each(range.begin(), range.end(), [&= amp;](int i) {
=A0 = =A0 =A0 =A0 =A0 =A0 =A0std::async(
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 launch::async,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 [&]() { stri= ngs[i] =3D fizzy(i); }
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 );
=A0 });

The arguments to std::async and its closing parenthesis are indente= d much too far; I would like them indented only one level further than wher= e std::async is itself indented. Any tips for achieving this?

--
Cheers,

Andrew Pennebak= er
--14dae9399de33c848a04d85d05c5-- ------------=_1573170121-26201-1--