From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#30115: 25.1; cc-mode (C++) : bad indentation on function closing curly brackets Date: Fri, 19 Jan 2018 18:01:36 +0000 Message-ID: <20180119180136.GA6102__8979.08199481226$1516385324$gmane$org@ACM> References: <87r2qsc9v0.fsf@deadstar.home.uk> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1516385324 30402 195.159.176.226 (19 Jan 2018 18:08:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 19 Jan 2018 18:08:44 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: 30115@debbugs.gnu.org To: =?UTF-8?Q?Ga=C3=A9tan?= Allaert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 19 19:08:39 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecb5c-0007HH-O1 for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 Jan 2018 19:08:32 +0100 Original-Received: from localhost ([::1]:35801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecb7c-0000kM-Ph for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 Jan 2018 13:10:36 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecb6E-0008GW-ER for bug-gnu-emacs@gnu.org; Fri, 19 Jan 2018 13:09:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecb6D-0006PT-CN for bug-gnu-emacs@gnu.org; Fri, 19 Jan 2018 13:09:10 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecb66-0006Ec-3s; Fri, 19 Jan 2018 13:09:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ecb65-00008A-Ur; Fri, 19 Jan 2018 13:09:01 -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: Fri, 19 Jan 2018 18:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30115 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 30115-submit@debbugs.gnu.org id=B30115.1516385304442 (code B ref 30115); Fri, 19 Jan 2018 18:09:01 +0000 Original-Received: (at 30115) by debbugs.gnu.org; 19 Jan 2018 18:08:24 +0000 Original-Received: from localhost ([127.0.0.1]:35202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecb5U-000074-6e for submit@debbugs.gnu.org; Fri, 19 Jan 2018 13:08:24 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:33890 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ecb5T-00006r-4G for 30115@debbugs.gnu.org; Fri, 19 Jan 2018 13:08:23 -0500 Original-Received: (qmail 60376 invoked by uid 3782); 19 Jan 2018 18:08:21 -0000 Original-Received: from acm.muc.de (p548C7496.dip0.t-ipconnect.de [84.140.116.150]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 19 Jan 2018 19:08:21 +0100 Original-Received: (qmail 6149 invoked by uid 1000); 19 Jan 2018 18:01:36 -0000 Content-Disposition: inline In-Reply-To: <87r2qsc9v0.fsf@deadstar.home.uk> 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: 208.118.235.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:142298 Archived-At: Hello, Gaétam/ On Sun, Jan 14, 2018 at 23:13:23 +0000, Gaétan Allaert wrote: > It is about an indentation issue in C++. > The closing curly bracket at the end of the function is wrongly indented > when: > 1. at least one base_1 exists (the comma at the end of base_1 is > required); > 2. base_2 is the last call before the opening curly bracket of the > function; > 3. base_2 has only 1 argument that must be a symbol, not a literal or a > string. > Example: > foo_good::foo_good (int arg_1, int arg_2) : > base_1 (), > base_2 (arg_1, arg_2) { > } // good indentation > foo_bad::foo_bad (int arg_1, int arg_2) : > base_1 (), > base_2 (arg_1) { > } // bad identation > Thanks to have a look at this issue. > In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11) > of 2017-09-15, modified by Debian built on trouble > Windowing system distributor 'The X.Org Foundation', version 11.0.11902000 > System Description: Debian GNU/Linux 9.3 (stretch) [ .... ] Thanks for taking the trouble to report this bug, and thanks even more for cutting your example down to a concise, easy to work with snippet. It seems already to be fixed in the emacs-26 branch, the fix being for an entirely different symptom, but appears to fix this, too. It will be some time before Emacs 26 gets released. In the meantime, can I ask you to apply the following patch to cc-engine.el in your Emacs 25.1 (in .../emacs/lisp/progmodes), compile it, and test it with your real code. (If you want any help applying the patch or compiling the file, feel free to contact me by private mail.) Would you please let me know how well it solves the problem in your real code. Thanks. --- cc-engine.20180119.eeel 2017-10-01 17:14:49.185254672 +0000 +++ cc-engine.el 2018-01-19 17:49:09.308202347 +0000 @@ -7615,8 +7615,10 @@ ;; CASE 11 (when (and got-identifier - (not context) (looking-at c-after-suffixed-type-decl-key) + (or (eq context 'top) + (and (eq context nil) + (match-beginning 1))) (if (and got-parens (not got-prefix) (not got-suffix) @@ -8287,7 +8289,7 @@ (c-forward-objc-directive))) (setq id-start - (car-safe (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))) + (car-safe (c-forward-decl-or-cast-1 (c-point 'bosws) 'top nil))) (< id-start beg) ;; There should not be a '=' or ',' between beg and the -- Alan Mackenzie (Nuremberg, Germany).