From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#14008: Better autoindent for C++11 code? Date: Sun, 03 Nov 2019 14:29:13 +0100 Message-ID: <87blttdr6e.fsf@marxist.se> References: <20191013180949.GE10125@ACM> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="154311"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 14008@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 03 14:30:30 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 1iRFxd-000e1U-8C for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Nov 2019 14:30:29 +0100 Original-Received: from localhost ([::1]:53848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iRFxc-00026Q-1x for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Nov 2019 08:30:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33041) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iRFxG-00024K-7g for bug-gnu-emacs@gnu.org; Sun, 03 Nov 2019 08:30:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iRFxF-00033I-1D for bug-gnu-emacs@gnu.org; Sun, 03 Nov 2019 08:30:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iRFxD-00032A-09; Sun, 03 Nov 2019 08:30:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iRFxC-00038L-Oj; Sun, 03 Nov 2019 08:30:02 -0500 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 14008-submit@debbugs.gnu.org id=B14008.157278776411973 (code B ref 14008); Sun, 03 Nov 2019 13:30:02 +0000 Original-Received: (at 14008) by debbugs.gnu.org; 3 Nov 2019 13:29:24 +0000 Original-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 Original-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=; Original-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 In-Reply-To: <20191013180949.GE10125@ACM> (Alan Mackenzie's message of "Sun, 13 Oct 2019 18:09:49 +0000") 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-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:170870 Archived-At: 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