From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tadeus Prastowo Newsgroups: gmane.emacs.bugs Subject: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list Date: Thu, 9 Nov 2017 10:27:55 +0100 Message-ID: References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> <20171104195639.GA5384@ACM> <20171108192358.GA4582@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1510219750 31453 195.159.176.226 (9 Nov 2017 09:29:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 9 Nov 2017 09:29:10 +0000 (UTC) Cc: John Wiegley , 28623@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 09 10:29:06 2017 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 1eCj8z-0007xZ-5v for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Nov 2017 10:29:05 +0100 Original-Received: from localhost ([::1]:35890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCj96-00068q-I6 for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Nov 2017 04:29:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCj90-00068a-8C for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2017 04:29:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCj8w-0003wU-4u for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2017 04:29:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50764) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eCj8w-0003wK-0e; Thu, 09 Nov 2017 04:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eCj8v-0002nt-Nw; Thu, 09 Nov 2017 04:29:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tadeus Prastowo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 09 Nov 2017 09:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28623 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 28623-submit@debbugs.gnu.org id=B28623.151021971510744 (code B ref 28623); Thu, 09 Nov 2017 09:29:01 +0000 Original-Received: (at 28623) by debbugs.gnu.org; 9 Nov 2017 09:28:35 +0000 Original-Received: from localhost ([127.0.0.1]:59445 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCj8V-0002nE-HP for submit@debbugs.gnu.org; Thu, 09 Nov 2017 04:28:35 -0500 Original-Received: from mail-io0-f177.google.com ([209.85.223.177]:56927) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCj8S-0002mx-8w for 28623@debbugs.gnu.org; Thu, 09 Nov 2017 04:28:34 -0500 Original-Received: by mail-io0-f177.google.com with SMTP id m81so9123818ioi.13 for <28623@debbugs.gnu.org>; Thu, 09 Nov 2017 01:28:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unitn-it.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=rrzwuwApgi4HYAR5fBqqnbS5v2BX5RbvupaIrTjBtlQ=; b=NptmTIEKqpImS9Lab9AK2cM4Rqu3W45xIw0DKs3zRmyLmRVJ2JbxkwuOpQpuTsGl7i E1Ax2d+wSH4mpxFqnpHtUv1seZAoV8kVmRogmaOtKWIdLdQ36XOgXXfhgexSvytOkuel YZUgqqr42bnkWcNu98mBsB8kCYipc6E10uYz7ukoCizv0Y+trDg/CQQAt2cDWX9YiKcq /EAfSnklJ0mh1D1fU9z5qbdod36rUUaJfuwApIj+t+JU8QtMIgQc/4514vUn1KlymKF+ XsnIIQiofwBRktBClgbawJq9+T1usfKaxkWIVugzeN9pKnYxicbkz+Kt1JI0mT/K520k 9BZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=rrzwuwApgi4HYAR5fBqqnbS5v2BX5RbvupaIrTjBtlQ=; b=gePoo+uQQj7501Zwuc8UeIt5Xcpmi9r4LN10vc/6gmH9CcAVyTaW1Nx3t4TFbLMfCQ KdPEBeZ0d5nJhyvtiDe6iIBlt3XXshe7MUPvQywM9aDPtplnfiHTq+gIRqI1vFPSt0XC wVp97ivAdjKRpcrM5OrWuUQ1IkhK9s4pUYLCoyppCLYo78O6Nk2bxJQAFx2hNOw+zKVe j2nGtoMI4aLZj5UoG54rQjaPh/NKME3u3Q50+idPNtBOY4f3s7Kha6GN3pTTkLUjdiH9 gFRHrDJ2sSX2KkU3Gki7kKruAqHNBqNNZE7pTfCdLAf9NMh/fwDkHy44Fhq3sAH6fRsE YfTA== X-Gm-Message-State: AJaThX5NMIa3shtAGSgF3RWSIbt8bG99le49N/YWRk7dvEjxQLszASAB 1NCT3qfslnZA2GJYnz8bhh4sOdFP9OFFZxCb6kUD X-Google-Smtp-Source: AGs4zMZt3kgrVPT/K4oulMxU+9NO7+810td2EuwMaCr2mpExs58jgJAVfE1leCBR5T88OdbSnyD9dg0zKb5K6IVmCJU= X-Received: by 10.107.166.16 with SMTP id p16mr4169868ioe.53.1510219706317; Thu, 09 Nov 2017 01:28:26 -0800 (PST) Original-Received: by 10.2.6.2 with HTTP; Thu, 9 Nov 2017 01:27:55 -0800 (PST) In-Reply-To: <20171108192358.GA4582@ACM> 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:139661 Archived-At: On Wed, Nov 8, 2017 at 8:23 PM, Alan Mackenzie wrote: [...] > OK. The essential characteristic of your new file is: > > ({ {..}, ..., {...}}, { {..} ..... > ^ > l L > > With the critical point marked, c-inside-bracelist-p had calculated a > backward search limit at position L, which was insufficient for it to > determine its brace list characteristic. > > I've corrected c-inside-bracelist-p such that it now uses position l as > this limit. I've also taken the opportunity to simplify it quite a bit. > This now appears to work. > > So, thank you for taking the time to test this, and finding this further > bug. My pleasure. And thank you very much for looking into this last problem as well. > Could I ask you, please, to try the amended patch which I include > below. This should, again, apply cleanly to the emacs-26 branch, or > master. It is a patch "from scratch"; it is not an incremental patch on > top of the last one. Cool! Your new patch produces the following now: int main() { /* Indentation produced by your new patch */ fn({ {1, 2, 3}, {3, 4, 5}, {6, 7, 8}, }, { {1, 3}, {4, 5}, {7, 8}, }); for (const auto &v : fn({ {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, }, { {1, 3}, {4, 5}, {7, 8}, })) { for (const auto &a : v) { std::cout << a << '\n'; } } /* End: Indentation produced by your new patch */ } So, you solved the problem :) >> Additionally, I would argue that compared to the one produced by my >> patch demonstrated above, the following indentation would be even >> better: >> for (const auto &v : fn({ >> {3, 4, 5}, >> {6, 7, 8}, >> {9, 10, 11}, >> }, { >> {1, 3}, >> {4, 5}, >> {7, 8}, >> })) { >> for (const auto &a : v) { >> std::cout << a << '\n'; >> } >> } >> Please let me know what you think about that. > > I think I would agree with you. This is probably fixable by configuring > the CC Mode indentation engine, possibly by writing a Line-up function, > but I can't say for sure without looking at it more closely. I will have a look at it this weekend. >> > If you have nothing against it, I intend to put your test file (or bits >> > of it) into a new file in the CC Mode test suite. > >> Yes, that is okay. > > Thanks, I'll do that. You are welcome. And, just out of curiosity, in cc-engine, there is a long function with many inline comments in the form of CASE xxx. Why aren't those refactored into individual functions? Performance issue? > -- > Alan Mackenzie (Nuremberg, Germany). -- Best regards, Tadeus