From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 27 14:14:49 2017 Received: (at submit) by debbugs.gnu.org; 27 Sep 2017 18:14:49 +0000 Received: from localhost ([127.0.0.1]:35302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxGrA-0004ks-A5 for submit@debbugs.gnu.org; Wed, 27 Sep 2017 14:14:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxGTq-00048c-9O for submit@debbugs.gnu.org; Wed, 27 Sep 2017 13:50:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxGTj-0005Bz-Ez for submit@debbugs.gnu.org; Wed, 27 Sep 2017 13:50:36 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:48141) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxGTi-0005Bl-W0 for submit@debbugs.gnu.org; Wed, 27 Sep 2017 13:50:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxGTh-0004Oe-8Q for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 13:50:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxGTf-0005AD-QX for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 13:50:33 -0400 Received: from mail-it0-x232.google.com ([2607:f8b0:4001:c0b::232]:49959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dxGTf-00059G-A5 for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 13:50:31 -0400 Received: by mail-it0-x232.google.com with SMTP id c195so8218304itb.4 for ; Wed, 27 Sep 2017 10:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unitn-it.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=2y4c8wbaxzFOoz36giyK2bMkv6/hvfddkHCN8eurZUs=; b=MOCFl1S8br+JzxNEgcQNOepCYfGT8ehXeizXz6VCFT4Ed96JnVrqdmvpKHrQhvTung teHEKe/yZ4VrbyjPp0LcaVHEse11vHGlWQ6GriIs+w2R0EI0Ql59HnzCRjPLNHgFL8q/ KM0TaqrwCmUmg3jgllRq5C/wW300cpsS27XaChEB3pdjj0xkXesSuL8sqLgx2NLYXLyV agPyJpioWBiSKvOOyVQT4MASwzAwoO4kLIgBveOoR60Iq2xuY8znQ6SUaOJ2PkWfDvq4 XSmH+mkhpa1yCUqWevIjID9NZnkAXcuPdwDsF9MQROMQXUDY2sEoUwpVHFzFXiF50Nmx Sm2w== 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; bh=2y4c8wbaxzFOoz36giyK2bMkv6/hvfddkHCN8eurZUs=; b=t7hayLVeR35aJasSAxL7NsKxoQfQSMQhSG+MkZnR7FGO2GP+VK0oN11ivvV5PQ/up8 6C0+fiF/u7Ys23ESQqarglOy/irZKlOijBhtPubvSWeGJywh3wLdiaKYXtG2+aXpJKKN VMqZvbnfZMEAf9C33yUbq1lHz+dUN2gkjXf0FGtm1NpXZH6Jao1eRkORLRV8pBPhf4d+ nDAVkIpqEvMUV7Ng61QEEN9wvK03HFiyspGwbikUHAwRMnJD3YUWeiJNgA9gs/kjaX13 QA/eI5YVrSGvJZkCVrTHIz7srYcXf8Qsg6bjAg3tfDzdK9vRkKfs+zAt3qIwznY+CLOE gN7Q== X-Gm-Message-State: AHPjjUj8DP8B7VzIRphXoUHmXyHdktxcUdOkP7fI3SMRMAYjhxv5hKSw 4rNYR3HDLxOQnVsWjK9QsQbHQxLuW4f1BWxcGoiq42zA9A== X-Google-Smtp-Source: AOwi7QA/GMkuFYlggyFhQFxSspybNCPJ3Iz9xUc4oQzOTypdETpNRz37BBgtcS0hhE2w+/Bcnb3rhx0/TIDnSP5Cclc= X-Received: by 10.36.121.202 with SMTP id z193mr1936561itc.110.1506534628468; Wed, 27 Sep 2017 10:50:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.10.197 with HTTP; Wed, 27 Sep 2017 10:49:57 -0700 (PDT) From: Tadeus Prastowo Date: Wed, 27 Sep 2017 19:49:57 +0200 Message-ID: Subject: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list To: bug-gnu-emacs@gnu.org Content-Type: multipart/mixed; boundary="001a114ac5505f77b2055a2f6d5c" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 27 Sep 2017 14:14:45 -0400 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: -4.0 (----) --001a114ac5505f77b2055a2f6d5c Content-Type: text/plain; charset="UTF-8" The following C++14 source code, which is also attached as `mwe.cpp', shows the indentation problem: --8<------------------------------ #include #include static std::vector> fn(std::vector> data) { return { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, }; } static std::vector> fn(unsigned n, std::vector> data) { return { {n + 1, n + 2, n + 3}, {n + 4, n + 5, n + 6}, {n + 7, n + 8, n + 9}, }; } int main() { /* Expected indentation */ fn({ {1, 2, 3}, {3, 4, 5}, {6, 7, 8}, }); for (const auto &v : fn({ {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, })) { for (const auto &a : v) { std::cout << a << '\n'; } } /* End: Expected indentation */ /* Problem */ fn(20, { {1, 2, 3}, {3, 4, 5}, {6, 7, 8}, }); for (const auto &v : fn(20, { {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, })) { for (const auto &a : v) { std::cout << a << '\n'; } } /* End: Problem */ } --8<------------------------------ To fix the problem, I make the following patch: --8<------------------------------ diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 05b391a..077e9c9 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -10387,6 +10387,7 @@ comment at the start of cc-engine.el for more info." (eq (char-after) ?\()) (setq braceassignp 'c++-noassign)) ((looking-at c-pre-id-bracelist-key)) + ((looking-at ",\\s *")) ((looking-at c-return-key)) ((and (looking-at c-symbol-start) (not (looking-at c-keywords-regexp))) @@ -10398,6 +10399,7 @@ comment at the start of cc-engine.el for more info." (and (c-go-up-list-backward nil lim) ; FIXME!!! Check `lim' 2016-07-12. (eq (char-after) ?\())) ((looking-at c-pre-id-bracelist-key)) + ((looking-at ",\\s *")) ((looking-at c-return-key)) (t (setq after-type-id-pos (point)) nil)))) --8<------------------------------ Any better suggestion as to how to fix the problem? Thanks. In GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2017-09-27 built on lgw01-amd64-052 Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 System Description: Ubuntu 16.04.3 LTS Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Making completion list... Quit Configured using: 'configure --build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib --program-suffix=-snapshot --with-modules=yes --with-x=yes --with-x-toolkit=gtk3 --with-xwidgets=yes 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS LIBSYSTEMD LCMS2 Important settings: value of $LC_MONETARY: en_US.UTF-8 value of $LC_NUMERIC: en_US.UTF-8 value of $LC_TIME: en_US.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: C++//l Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting xwidget-internal move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 115959 7786) (symbols 48 22648 1) (miscs 40 46 140) (strings 32 34019 980) (string-bytes 1 1013691) (vectors 16 17237) (vector-slots 8 521799 8627) (floats 8 50 155) (intervals 56 397 1) (buffers 992 13) (heap 1024 40263 1174)) -- Best regards, Tadeus --001a114ac5505f77b2055a2f6d5c Content-Type: text/x-c++src; charset="US-ASCII"; name="mwe.cpp" Content-Disposition: attachment; filename="mwe.cpp" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j83bkayb0 I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RhdGljIHN0ZDo6dmVjdG9y PHN0ZDo6dmVjdG9yPHVuc2lnbmVkPj4KZm4oc3RkOjp2ZWN0b3I8c3RkOjp2ZWN0b3I8dW5zaWdu ZWQ+PiBkYXRhKSB7CiAgcmV0dXJuIHsKICAgICAgICAgIHsxLCAyLCAzfSwKICAgICAgICAgIHs0 LCA1LCA2fSwKICAgICAgICAgIHs3LCA4LCA5fSwKICB9Owp9CgpzdGF0aWMgc3RkOjp2ZWN0b3I8 c3RkOjp2ZWN0b3I8dW5zaWduZWQ+Pgpmbih1bnNpZ25lZCBuLCBzdGQ6OnZlY3RvcjxzdGQ6OnZl Y3Rvcjx1bnNpZ25lZD4+IGRhdGEpIHsKICByZXR1cm4gewogICAgICAgICAge24gKyAxLCBuICsg MiwgbiArIDN9LAogICAgICAgICAge24gKyA0LCBuICsgNSwgbiArIDZ9LAogICAgICAgICAge24g KyA3LCBuICsgOCwgbiArIDl9LAogIH07Cn0KCmludCBtYWluKCkgewogIC8qIEV4cGVjdGVkIGlu ZGVudGF0aW9uICovCiAgZm4oewogICAgICB7MSwgMiwgM30sCiAgICAgIHszLCA0LCA1fSwKICAg ICAgezYsIDcsIDh9LAogICAgfSk7CiAgZm9yIChjb25zdCBhdXRvICZ2IDogZm4oewogICAgICAg ICAgICAgICAgICAgICAgICAgICB7MywgNCwgNX0sCiAgICAgICAgICAgICAgICAgICAgICAgICAg IHs2LCA3LCA4fSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgezksIDEwLCAxMX0sCiAgICAg IH0pKSB7CiAgICBmb3IgKGNvbnN0IGF1dG8gJmEgOiB2KSB7CiAgICAgIHN0ZDo6Y291dCA8PCBh IDw8ICdcbic7CiAgICB9CiAgfQogIC8qIEVuZDogRXhwZWN0ZWQgaW5kZW50YXRpb24gKi8KCiAg LyogUHJvYmxlbSAqLwogIGZuKDIwLCB7CiAgICAgIHsxLCAyLCAzfSwKICAgICAgICB7MywgNCwg NX0sCiAgICAgICAgICB7NiwgNywgOH0sCiAgICAgICAgICAgIH0pOwogIGZvciAoY29uc3QgYXV0 byAmdiA6IGZuKDIwLCB7CiAgICAgICAgezMsIDQsIDV9LAogICAgICAgICAgezYsIDcsIDh9LAog ICAgICAgICAgICB7OSwgMTAsIDExfSwKICAgICAgICAgICAgICB9KSkgewogICAgZm9yIChjb25z dCBhdXRvICZhIDogdikgewogICAgICBzdGQ6OmNvdXQgPDwgYSA8PCAnXG4nOwogICAgfQogIH0K ICAvKiBFbmQ6IFByb2JsZW0gKi8KfQo= --001a114ac5505f77b2055a2f6d5c-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 27 15:31:57 2017 Received: (at 28623) by debbugs.gnu.org; 27 Sep 2017 19:31:57 +0000 Received: from localhost ([127.0.0.1]:35404 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxI3o-0000AD-Ri for submit@debbugs.gnu.org; Wed, 27 Sep 2017 15:31:57 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:56580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxI3m-0000A0-Nb for 28623@debbugs.gnu.org; Wed, 27 Sep 2017 15:31:55 -0400 Received: by mail-pf0-f169.google.com with SMTP id g65so7735182pfe.13 for <28623@debbugs.gnu.org>; Wed, 27 Sep 2017 12:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:date:message-id:references :user-agent:mime-version; bh=io9u2IVsayb5QHZHtfG3o6J6iya70KW2i5a+rEj6P7I=; b=OxcaJ13k14CClMyrM2XL7pHVHUAOxxFUNOvCjBwzlChVJE7AWI/hLzA5liaVbiuL4p o2s6uJ9F9Nwxd7I3vXtsFP+eq8nXLM3yUT1fYmZlXxoM4OqbGs7exdmiNWTdyr4N8UF6 +UvanYWqYwtbawGm/PwO4CuI23xcVcrjQmUbeDKrmKa1yOf+ohD7aVPuq51/6en3MpWI a0Wm//zoW7uolxGP/y6+/uKutbROhRcwgHrFo862XuzVU2fQKJSMqAVrImPOb7JAmXmf yFftSyxp3AcWM+01Nm4mGIIUnxsFI2Ce8bP0w9B/N1Ld/QPgdW7IUOZvKAL/0OJLxfsP 16HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:date:message-id :references:user-agent:mime-version; bh=io9u2IVsayb5QHZHtfG3o6J6iya70KW2i5a+rEj6P7I=; b=Wq1nTdyUUQ2EHl5WQYwEFvRT5i3ZeMUeYQ5HijDNBggjzAaf9t7IpwZ+9WIxndcebV /dya4GZeZgnoswVhlsXINFJ9GDMCpXMXVh7XRRUnaJVEUL1LiijXfcfKsqm1WGT76a5B 8mmg7t9g02mdcah3B4dIQ7zzS8LrJqIlIWwrVtxvhhFGyuZhFodNYYQRMsZIIfUbtNI9 n7sXvdx1SC9+QLA+0VNbKDqFCX6B3ftQTVwAltzHp/ish7ru82GhAjHm7xGjaQthJGVL 0Qi+7ir7PxZ/8fviEVuQPSzCHtr0Uf+eCLdECNYkztBqFYIwk02bV4KmVZ6c3wVC0rhU nY8A== X-Gm-Message-State: AHPjjUjdEH3v1y+snx/y60wXiwOkzXs7MgbXnQVOBeos2s67adyEEqC0 fz6MfKTVmkChs5gc4gQIqi9MVQHg X-Google-Smtp-Source: AOwi7QDS0Z/A+mJ24JJQ2gUb7bHGpy8E1sCgP+CWwUpyrL+ny4ifmyDVFSLfOcD/hiJFiUSdqArXwQ== X-Received: by 10.98.69.136 with SMTP id n8mr2193446pfi.291.1506540708656; Wed, 27 Sep 2017 12:31:48 -0700 (PDT) Received: from Vulcan.local (76-234-69-149.lightspeed.frokca.sbcglobal.net. [76.234.69.149]) by smtp.gmail.com with ESMTPSA id a1sm23796708pgu.47.2017.09.27.12.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 12:31:47 -0700 (PDT) From: John Wiegley X-Google-Original-From: "John Wiegley" Received: by Vulcan.local (Postfix, from userid 501) id EFF46935ABF8; Wed, 27 Sep 2017 12:31:46 -0700 (PDT) To: Tadeus Prastowo Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list In-Reply-To: (Tadeus Prastowo's message of "Wed, 27 Sep 2017 19:49:57 +0200") Date: Wed, 27 Sep 2017 12:31:39 -0700 Message-ID: References: User-Agent: Gnus/5.130016 (Ma Gnus v0.16) Emacs/26.0 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 28623 Cc: Alan Mackenzie , 28623@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: -2.8 (--) >>>>> "TP" == Tadeus Prastowo writes: PT> The following C++14 source code, which is also attached as `mwe.cpp', PT> shows the indentation problem: Pinging Alan for this one. -- John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 04 14:25:16 2017 Received: (at 28623) by debbugs.gnu.org; 4 Oct 2017 18:25:16 +0000 Received: from localhost ([127.0.0.1]:49187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzoM6-0002kD-Kk for submit@debbugs.gnu.org; Wed, 04 Oct 2017 14:25:16 -0400 Received: from ocolin.muc.de ([193.149.48.4]:29835 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1dzoM3-0002k4-Tk for 28623@debbugs.gnu.org; Wed, 04 Oct 2017 14:25:12 -0400 Received: (qmail 25920 invoked by uid 3782); 4 Oct 2017 18:25:06 -0000 Received: from acm.muc.de (p548C6F55.dip0.t-ipconnect.de [84.140.111.85]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 04 Oct 2017 20:25:06 +0200 Received: (qmail 15600 invoked by uid 1000); 4 Oct 2017 18:15:53 -0000 Date: Wed, 4 Oct 2017 18:15:53 +0000 To: Tadeus Prastowo Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list Message-ID: <20171004181552.GA15562@ACM> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 28623 Cc: John Wiegley , 28623@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: -0.0 (/) Hello, Tadeus. On Wed, Sep 27, 2017 at 19:49:57 +0200, Tadeus Prastowo wrote: > The following C++14 source code, which is also attached as `mwe.cpp', > shows the indentation problem: > --8<------------------------------ > #include > #include > static std::vector> > fn(std::vector> data) { > return { > {1, 2, 3}, > {4, 5, 6}, > {7, 8, 9}, > }; > } > static std::vector> > fn(unsigned n, std::vector> data) { > return { > {n + 1, n + 2, n + 3}, > {n + 4, n + 5, n + 6}, > {n + 7, n + 8, n + 9}, > }; > } > int main() { > /* Expected indentation */ > fn({ > {1, 2, 3}, > {3, 4, 5}, > {6, 7, 8}, > }); > for (const auto &v : fn({ > {3, 4, 5}, > {6, 7, 8}, > {9, 10, 11}, > })) { > for (const auto &a : v) { > std::cout << a << '\n'; > } > } > /* End: Expected indentation */ > /* Problem */ > fn(20, { > {1, 2, 3}, > {3, 4, 5}, > {6, 7, 8}, > }); > for (const auto &v : fn(20, { > {3, 4, 5}, > {6, 7, 8}, > {9, 10, 11}, > })) { > for (const auto &a : v) { > std::cout << a << '\n'; > } > } > /* End: Problem */ > } > --8<------------------------------ Yes. > To fix the problem, I make the following patch: > --8<------------------------------ > diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el > index 05b391a..077e9c9 100644 > --- a/lisp/progmodes/cc-engine.el > +++ b/lisp/progmodes/cc-engine.el > @@ -10387,6 +10387,7 @@ comment at the start of cc-engine.el for more info." > (eq (char-after) ?\()) > (setq braceassignp 'c++-noassign)) > ((looking-at c-pre-id-bracelist-key)) > + ((looking-at ",\\s *")) > ((looking-at c-return-key)) > ((and (looking-at c-symbol-start) > (not (looking-at c-keywords-regexp))) > @@ -10398,6 +10399,7 @@ comment at the start of cc-engine.el for more info." > (and (c-go-up-list-backward nil lim) ; FIXME!!! Check > `lim' 2016-07-12. > (eq (char-after) ?\())) > ((looking-at c-pre-id-bracelist-key)) > + ((looking-at ",\\s *")) > ((looking-at c-return-key)) > (t (setq after-type-id-pos (point)) > nil)))) > --8<------------------------------ > Any better suggestion as to how to fix the problem? Hey, I just love it when people diagnose and fix their own bugs, particularly in some of the more involved bits of CC Mode. :-) Just one tiny, tiny, nitpick. in (looking-at ",\\s *"), isn't the "any amount of space" bit redundant, since we don't use match-end to get the precise position? In fact, I'm tending towards the simpler (eq (char-after) ?,). But, as I say, that's a tiny point in a great piece of debugging. I will commit this (to the Emacs-26 branch of savannah) soon (from where it will find its way to the master branch due to some public spirited person who arranges these things). Many thanks! > Thanks. > In GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) > of 2017-09-27 built on lgw01-amd64-052 > Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 > System Description: Ubuntu 16.04.3 LTS [ .... ] > Major mode: C++//l [ .... ] > -- > Best regards, > Tadeus -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 05 23:00:34 2017 Received: (at 28623) by debbugs.gnu.org; 6 Oct 2017 03:00:34 +0000 Received: from localhost ([127.0.0.1]:51983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0IsM-0003YD-8n for submit@debbugs.gnu.org; Thu, 05 Oct 2017 23:00:34 -0400 Received: from mail-it0-f44.google.com ([209.85.214.44]:47142) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0IsJ-0003Xz-Bg for 28623@debbugs.gnu.org; Thu, 05 Oct 2017 23:00:32 -0400 Received: by mail-it0-f44.google.com with SMTP id p138so3739452itp.2 for <28623@debbugs.gnu.org>; Thu, 05 Oct 2017 20:00:31 -0700 (PDT) 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=q2461kmW9QMGU+SGzr4Y1+UM/BcmtR83BwLUGkhUDCY=; b=if3ra+ZkekQ5WzTSutsDKXYvQMztamryy54iqURvfO5sGSAn+iL+nv/r44dm9gLYjP CoAhN3qpAB/lXbTSQDxBbKcIiGzxIe8TloXR+URNy/AY0f2QOUmbKCu0iA4UFtpeu2qZ LLN5xNfDhYaEHVY684xo2j6yJePVJih2bwUnG1vS3R3Zp/GLqozywSmEx5FMKo5Rpwg0 XXx0le32qwxGIJFlOCHkwE/0Vp1ZK7pAtPr2LbiufB6PFQXGWdPUIuEb7BJRV6qtFQjU i6UpYMgbWcqmEy1aqJR02ULKjFJdgJFQvkEFgZ49RG6pD2mG96npRxb7YE5NUWWDhU5s ZRgg== 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=q2461kmW9QMGU+SGzr4Y1+UM/BcmtR83BwLUGkhUDCY=; b=d0r1kkB7N9sgvHxClm8ZjmfaxBWuEmzrww1J1Hft5NXxaZgFnlok3qZzrPYr7LLWVP KhmBHCTTaqKLtC70MFhpASqrmOL6rVaxwBZKeFjVGNkHeUyIoa6CmrlJH18Ng1YCtEyy c24mDDyFeLfkUuCUlx4dD5mAldkzibnji/JUQisgO3AYgkW5xLIuyGRPDX3iamMubcSQ VrYAqcI7jcllAwRXu04uF9px5DMJimnAdrPdqw4E/Tx9//lh7aynJzL9Z8QkBGER5NZ4 +7kLo3KWfLiwZ/1i6hVxiQfXPcHqAs+TDwr59d9Bw1jcSopf1C7curdHNc3vAEI1VHra RLuw== X-Gm-Message-State: AMCzsaXcTKxpH6Kh9YJzOCagDAoXBBnHv52Kjf5ACE/UZVKdfzu5sLKi w8XJxkMGRDkMgpgDEzh+S97dDUGrphpz8eiq7gHv X-Google-Smtp-Source: AOwi7QAyQGfPUC4tADIUNVOciktzqVtkM1+rysRTmw2ioxu92txjd5CAEA5pSqXwBucKAOumacpQRmQOaegVyVJKu7A= X-Received: by 10.36.120.142 with SMTP id p136mr769882itc.55.1507258825461; Thu, 05 Oct 2017 20:00:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.6.2 with HTTP; Thu, 5 Oct 2017 19:59:55 -0700 (PDT) In-Reply-To: <20171004181552.GA15562@ACM> References: <20171004181552.GA15562@ACM> From: Tadeus Prastowo Date: Fri, 6 Oct 2017 04:59:55 +0200 Message-ID: Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 28623 Cc: John Wiegley , 28623@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: 0.5 (/) On Wed, Oct 4, 2017 at 8:15 PM, Alan Mackenzie wrote: > Hello, Tadeus. Hi Alan! [...] >> Any better suggestion as to how to fix the problem? > > Hey, I just love it when people diagnose and fix their own bugs, > particularly in some of the more involved bits of CC Mode. :-) To make the maintainer's life easier :-) > Just one tiny, tiny, nitpick. in (looking-at ",\\s *"), isn't the "any > amount of space" bit redundant, since we don't use match-end to get the > precise position? In fact, I'm tending towards the simpler (eq > (char-after) ?,). That is surely better. Please go with that solution. > But, as I say, that's a tiny point in a great piece of debugging. I > will commit this (to the Emacs-26 branch of savannah) soon (from where > it will find its way to the master branch due to some public spirited > person who arranges these things). Thank you very much for your review. > Many thanks! No problem. I'm glad to help. -- Best regards, Tadeus From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 11 16:34:27 2017 Received: (at 28623) by debbugs.gnu.org; 11 Oct 2017 20:34:27 +0000 Received: from localhost ([127.0.0.1]:34546 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2Nhz-0007IF-A6 for submit@debbugs.gnu.org; Wed, 11 Oct 2017 16:34:27 -0400 Received: from ocolin.muc.de ([193.149.48.4]:19487 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1e2Nhx-0007I7-HZ for 28623@debbugs.gnu.org; Wed, 11 Oct 2017 16:34:26 -0400 Received: (qmail 8948 invoked by uid 3782); 11 Oct 2017 20:34:23 -0000 Received: from acm.muc.de (p548C7002.dip0.t-ipconnect.de [84.140.112.2]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 11 Oct 2017 22:34:21 +0200 Received: (qmail 7617 invoked by uid 1000); 11 Oct 2017 20:32:21 -0000 Date: Wed, 11 Oct 2017 20:32:21 +0000 To: Tadeus Prastowo Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list Message-ID: <20171011203221.GB7384@ACM> References: <20171004181552.GA15562@ACM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 28623 Cc: John Wiegley , 28623@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: -0.0 (/) Hello, Tadeus. On Fri, Oct 06, 2017 at 04:59:55 +0200, Tadeus Prastowo wrote: > On Wed, Oct 4, 2017 at 8:15 PM, Alan Mackenzie wrote: > Hi Alan! > [...] > >> Any better suggestion as to how to fix the problem? > > Hey, I just love it when people diagnose and fix their own bugs, > > particularly in some of the more involved bits of CC Mode. :-) > To make the maintainer's life easier :-) > > Just one tiny, tiny, nitpick. in (looking-at ",\\s *"), isn't the "any > > amount of space" bit redundant, since we don't use match-end to get the > > precise position? In fact, I'm tending towards the simpler (eq > > (char-after) ?,). > That is surely better. Please go with that solution. > > But, as I say, that's a tiny point in a great piece of debugging. I > > will commit this (to the Emacs-26 branch of savannah) soon (from where > > it will find its way to the master branch due to some public spirited > > person who arranges these things). > Thank you very much for your review. > > Many thanks! > No problem. I'm glad to help. I'm sorry is been a week without any communication from me. The reason is I've run into problems with other related cases. For example, in 1. auto bad4 = f <3> ( 2. {3, 4}, L2 needs to be parsed as an arglist-intro and indented as shown. It's actually being parsed as a brace-list-open with anchor point on "auto". What's confusing me is the confusion between a brace list being recognised by its context (which is what c-looking-at-or-maybe-in-bracelist mostly does) and by its content. The {3, 4} above is a brace list by its content but not by its context. However, it's being wrongly recognised as a by-context brace list, hence is being parsed and indented wrongly. I'm not going to have much time to sort this out over the next week or two, so please bear with me. I haven't forgotten about this. > -- > Best regards, > Tadeus -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 12 07:39:36 2017 Received: (at 28623) by debbugs.gnu.org; 12 Oct 2017 11:39:36 +0000 Received: from localhost ([127.0.0.1]:34935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2bpu-0004Yg-Qt for submit@debbugs.gnu.org; Thu, 12 Oct 2017 07:39:35 -0400 Received: from mail-it0-f45.google.com ([209.85.214.45]:51851) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2bps-0004YO-Lb for 28623@debbugs.gnu.org; Thu, 12 Oct 2017 07:39:33 -0400 Received: by mail-it0-f45.google.com with SMTP id o135so6517675itb.0 for <28623@debbugs.gnu.org>; Thu, 12 Oct 2017 04:39:32 -0700 (PDT) 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=8zwcNnzHFDjOabB+6Mz3yXB4cQdU3hzeOw/u5UWV/GM=; b=uU3LAAyZQO2cxH56/IM7gqKScUvBkr+2Y7kDo9u3EW2RLjOos7bKoo6xv7f+o+kmNm WoDPOKOXuhgWiqqtHnO0y5lN3gRUddubomTiTbhf2oiZiOO0Rt0eLrB6W2etgK0FJuDT 0bJyYy45NxfGLDRYmonaJv2GEfY/P2HgmS+EnfaW/oC1qH5lxBq+Wo/nBqzPymJaK+EQ ivc20MTzSVxmo1BorTzTTRY0mt1gz27s8OwLqo+Mw9hU7k0F7zHI+SNx0PAuD7JXjl1T DmT/F5tohrq6Y6PUOXMeal55IxsxbvqbhfYJz2n7gRPfvTp3wcgnsRWrvkQnsXBd3kyt VPBw== 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=8zwcNnzHFDjOabB+6Mz3yXB4cQdU3hzeOw/u5UWV/GM=; b=pra+VvBp/p19LwEUHM/WTqO+rE4TbyiZFH7Ip23zhDqYWyc4riqwmJXHzlCGLR21aH 9As18DUDLXNw5Je/hzO11+MlOHpUyrUqzNxeenvZl7lV+qvmJD6kABhvfHmNmdOMfwdA Uv1IoOnM3EsC+ZnBqcIBuly4zwm1VfgaLYsLNx7es+I9hMQVsRORuviK061qMKufbh2R /+HeJyGyE60GtmR0/8u63h68m0sMw/OR/yVsehQdfjEQousTmhniIj7sSXTbd0krFhqw 41yNXOrx6nqiGXu9m4uc3YUpJQjvcYBLgdfsGv2VGCZ99KRYlcaXhLVaRq4NmgY0PZ0c Tz/A== X-Gm-Message-State: AMCzsaW0aIXp8drIu7Lqhf6PJz6fHWV4FXioVflC0qy9oSlCbrJJgDys 3omB5AtJpWeDgFwitkfMDegW+bXGChUuPfrukR8O X-Google-Smtp-Source: AOwi7QCdfQp+PhdAYv4/8SUVoNCevqoEfYXdTWWLkGql3STF/lok1QdJdQP3tTwEHhlG+G04NtM3Nj6+8p0xdIo6cMI= X-Received: by 10.36.246.76 with SMTP id u73mr2957082ith.55.1507808366723; Thu, 12 Oct 2017 04:39:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.6.2 with HTTP; Thu, 12 Oct 2017 04:38:56 -0700 (PDT) In-Reply-To: <20171011203221.GB7384@ACM> References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> From: Tadeus Prastowo Date: Thu, 12 Oct 2017 13:38:56 +0200 Message-ID: Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 28623 Cc: John Wiegley , 28623@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: 0.5 (/) Hi Alan! On Wed, Oct 11, 2017 at 10:32 PM, Alan Mackenzie wrote: > Hello, Tadeus. [...] > I'm sorry is been a week without any communication from me. The reason > is I've run into problems with other related cases. For example, in > > 1. auto bad4 = f <3> ( > 2. {3, 4}, > > L2 needs to be parsed as an arglist-intro and indented as shown. It's > actually being parsed as a brace-list-open with anchor point on "auto". > > What's confusing me is the confusion between a brace list being > recognised by its context (which is what > c-looking-at-or-maybe-in-bracelist mostly does) and by its content. The > {3, 4} above is a brace list by its content but not by its context. > However, it's being wrongly recognised as a by-context brace list, hence > is being parsed and indented wrongly. > > I'm not going to have much time to sort this out over the next week or > two, so please bear with me. I haven't forgotten about this. Thanks for sharing the problem with me. I will also look into the matter during this weekend. Hopefully I can come up with a good solution :) > -- > Alan Mackenzie (Nuremberg, Germany). -- Best regards, Tadeus From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 04 16:03:51 2017 Received: (at 28623) by debbugs.gnu.org; 4 Nov 2017 20:03:51 +0000 Received: from localhost ([127.0.0.1]:50960 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eB4fX-0006Pb-3H for submit@debbugs.gnu.org; Sat, 04 Nov 2017 16:03:51 -0400 Received: from ocolin.muc.de ([193.149.48.4]:45125 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1eB4fV-0006PS-Q6 for 28623@debbugs.gnu.org; Sat, 04 Nov 2017 16:03:50 -0400 Received: (qmail 36597 invoked by uid 3782); 4 Nov 2017 20:03:48 -0000 Received: from acm.muc.de (p548C71A6.dip0.t-ipconnect.de [84.140.113.166]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 04 Nov 2017 21:03:46 +0100 Received: (qmail 5927 invoked by uid 1000); 4 Nov 2017 19:56:39 -0000 Date: Sat, 4 Nov 2017 19:56:39 +0000 To: Tadeus Prastowo Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list Message-ID: <20171104195639.GA5384@ACM> References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 28623 Cc: John Wiegley , 28623@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: -0.0 (/) Hello, Tadeus. On Thu, Oct 12, 2017 at 13:38:56 +0200, Tadeus Prastowo wrote: > Hi Alan! > On Wed, Oct 11, 2017 at 10:32 PM, Alan Mackenzie wrote: > > Hello, Tadeus. > [...] > > I'm sorry is been a week without any communication from me. The reason > > is I've run into problems with other related cases. For example, in > > 1. auto bad4 = f <3> ( > > 2. {3, 4}, > > L2 needs to be parsed as an arglist-intro and indented as shown. It's > > actually being parsed as a brace-list-open with anchor point on "auto". > > What's confusing me is the confusion between a brace list being > > recognised by its context (which is what > > c-looking-at-or-maybe-in-bracelist mostly does) and by its content. The > > {3, 4} above is a brace list by its content but not by its context. > > However, it's being wrongly recognised as a by-context brace list, hence > > is being parsed and indented wrongly. > > I'm not going to have much time to sort this out over the next week or > > two, so please bear with me. I haven't forgotten about this. > Thanks for sharing the problem with me. I will also look into the > matter during this weekend. Hopefully I can come up with a good > solution :) I think I've solved this, though it's been perhaps the most difficult bug in CC Mode for some years. Each time I thought I'd nailed it, some awkward test case would misbehave. Anyhow, would you please try the patch below, which should apply cleanly to either the emacs-26 branch or master. It is not finished; for example I've still got to amend several comments. Nevertheless I think it's working. I look forward to hearing of any problems which are still in this patch, or of a report that it seems to be working. 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. Here's the patch: have fun! diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 6f39cc6433..2da9e98345 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -10426,17 +10426,20 @@ c-looking-at-or-maybe-in-bracelist (and (c-major-mode-is 'pike-mode) c-decl-block-key)) (braceassignp 'dontknow) - inexpr-brace-list bufpos macro-start res pos after-type-id-pos) + inexpr-brace-list bufpos macro-start res pos after-type-id-pos + in-paren) (setq res (c-backward-token-2 1 t lim)) ;; Checks to do only on the first sexp before the brace. ;; Have we a C++ initialization, without an "="? (if (and (c-major-mode-is 'c++-mode) (cond - ((and (not (eq res 0)) + ((and (or (not (eq res 0)) + (eq (char-after) ?,)) (c-go-up-list-backward nil lim) ; FIXME!!! Check ; `lim' 2016-07-12. (eq (char-after) ?\()) - (setq braceassignp 'c++-noassign)) + (setq braceassignp 'c++-noassign + in-paren 'in-paren)) ((looking-at c-pre-id-bracelist-key)) ((looking-at c-return-key)) ((and (looking-at c-symbol-start) @@ -10445,9 +10448,11 @@ c-looking-at-or-maybe-in-bracelist (t nil)) (save-excursion (cond - ((not (eq res 0)) + ((or (not (eq res 0)) + (eq (char-after) ?,)) (and (c-go-up-list-backward nil lim) ; FIXME!!! Check `lim' 2016-07-12. - (eq (char-after) ?\())) + (eq (char-after) ?\() + (setq in-paren 'in-paren))) ((looking-at c-pre-id-bracelist-key)) ((looking-at c-return-key)) (t (setq after-type-id-pos (point)) @@ -10486,7 +10491,7 @@ c-looking-at-or-maybe-in-bracelist (c-backward-syntactic-ws) (eq (char-before) ?\())) ;; Single identifier between '(' and '{'. We have a bracelist. - (cons after-type-id-pos nil)) + (cons after-type-id-pos 'in-paren)) (t (goto-char pos) @@ -10544,7 +10549,7 @@ c-looking-at-or-maybe-in-bracelist (braceassignp ;; We've hit the beginning of the aggregate list. (c-beginning-of-statement-1 containing-sexp) - (cons (point) inexpr-brace-list)) + (cons (point) (or in-paren inexpr-brace-list))) ((and after-type-id-pos (save-excursion (when (eq (char-after) ?\;) @@ -10569,7 +10574,7 @@ c-looking-at-or-maybe-in-bracelist nil nil)) (and (consp res) (eq (car res) after-type-id-pos)))))) - (cons bufpos inexpr-brace-list)) + (cons bufpos (or in-paren inexpr-brace-list))) ((eq (char-after) ?\;) ;; Brace lists can't contain a semicolon, so we're done. ;; (setq containing-sexp nil) @@ -10593,7 +10598,7 @@ c-looking-at-or-maybe-in-bracelist (t t)))) ;; The caller can go up one level. ))) -(defun c-inside-bracelist-p (containing-sexp paren-state) +(defun c-inside-bracelist-p (containing-sexp paren-state by-content) ;; return the buffer position of the beginning of the brace list ;; statement if we're inside a brace list, otherwise return nil. ;; CONTAINING-SEXP is the buffer pos of the innermost containing @@ -10632,14 +10637,22 @@ c-inside-bracelist-p ;; containing sexp, so that c-looking-at-inexpr-block ;; doesn't check for an identifier before it. (setq bufpos nil) - (when (or (not (eq (char-after) ?{)) - (eq (setq bufpos (c-looking-at-or-maybe-in-bracelist - next-containing lim)) - t)) - (setq containing-sexp next-containing - lim nil - next-containing nil)))) - (and (consp bufpos) (car bufpos)))))) + (if (not (eq (char-after) ?{)) + (setq bufpos nil) + (when (eq (setq bufpos (c-looking-at-or-maybe-in-bracelist + next-containing lim)) + t) + (setq containing-sexp next-containing + lim nil + next-containing nil))))) + (cond + ((eq bufpos t) + (and containing-sexp + (not (c-looking-at-statement-block)))) + ((consp bufpos) + (and (or by-content (not (eq (cdr bufpos) 'in-paren))) + (car bufpos))) + (t nil)))))) (defun c-looking-at-special-brace-list (&optional _lim) ;; If we're looking at the start of a pike-style list, i.e., `({ })', @@ -11506,6 +11519,7 @@ c-guess-basic-syntax ;; The paren state outside `containing-sexp', or at ;; `indent-point' if `containing-sexp' is nil. (paren-state (c-parse-state)) + (state-cache (copy-tree paren-state)) ;; There's always at most one syntactic element which got ;; an anchor pos. It's stored in syntactic-relpos. syntactic-relpos @@ -11668,7 +11682,7 @@ c-guess-basic-syntax (not (c-at-vsemi-p before-ws-ip)) (not (memq char-after-ip '(?\) ?\] ?,))) (or (not (eq char-before-ip ?})) - (c-looking-at-inexpr-block-backward c-state-cache)) + (c-looking-at-inexpr-block-backward state-cache)) (> (point) (progn ;; Ought to cache the result from the @@ -11746,7 +11760,7 @@ c-guess-basic-syntax (if containing-sexp (progn (goto-char containing-sexp) - (setq lim (c-most-enclosing-brace c-state-cache + (setq lim (c-most-enclosing-brace state-cache containing-sexp)) (c-backward-to-block-anchor lim) (c-add-stmt-syntax 'case-label nil t lim paren-state)) @@ -11772,7 +11786,7 @@ c-guess-basic-syntax (containing-sexp (goto-char containing-sexp) - (setq lim (c-most-enclosing-brace c-state-cache + (setq lim (c-most-enclosing-brace state-cache containing-sexp)) (save-excursion (setq tmpsymbol @@ -11816,7 +11830,7 @@ c-guess-basic-syntax (goto-char (cdr placeholder)) (back-to-indentation) (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state) (unless (eq (point) (cdr placeholder)) (c-add-syntax (car placeholder)))) @@ -12239,11 +12253,11 @@ c-guess-basic-syntax (and (eq (char-before) ?}) (save-excursion (let ((start (point))) - (if (and c-state-cache - (consp (car c-state-cache)) - (eq (cdar c-state-cache) (point))) + (if (and state-cache + (consp (car state-cache)) + (eq (cdar state-cache) (point))) ;; Speed up the backward search a bit. - (goto-char (caar c-state-cache))) + (goto-char (caar state-cache))) (c-beginning-of-decl-1 containing-sexp) ; Can't use `lim' here. (setq placeholder (point)) (if (= start (point)) @@ -12400,7 +12414,8 @@ c-guess-basic-syntax ((and (eq char-after-ip ?{) (progn (setq placeholder (c-inside-bracelist-p (point) - paren-state)) + paren-state + nil)) (if placeholder (setq tmpsymbol '(brace-list-open . inexpr-class)) (setq tmpsymbol '(block-open . inexpr-statement) @@ -12482,7 +12497,7 @@ c-guess-basic-syntax (skip-chars-forward " \t")) (goto-char placeholder)) (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state)) ;; CASE 7G: we are looking at just a normal arglist @@ -12523,7 +12538,7 @@ c-guess-basic-syntax (save-excursion (goto-char containing-sexp) (c-looking-at-special-brace-list))) - (c-inside-bracelist-p containing-sexp paren-state)))) + (c-inside-bracelist-p containing-sexp paren-state t)))) (cond ;; CASE 9A: In the middle of a special brace list opener. @@ -12571,7 +12586,7 @@ c-guess-basic-syntax (= (point) containing-sexp))) (if (eq (point) (c-point 'boi)) (c-add-syntax 'brace-list-close (point)) - (setq lim (c-most-enclosing-brace c-state-cache (point))) + (setq lim (c-most-enclosing-brace state-cache (point))) (c-beginning-of-statement-1 lim nil nil t) (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) @@ -12597,7 +12612,7 @@ c-guess-basic-syntax (goto-char containing-sexp)) (if (eq (point) (c-point 'boi)) (c-add-syntax 'brace-list-intro (point)) - (setq lim (c-most-enclosing-brace c-state-cache (point))) + (setq lim (c-most-enclosing-brace state-cache (point))) (c-beginning-of-statement-1 lim) (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) @@ -12619,7 +12634,7 @@ c-guess-basic-syntax ((and (not (memq char-before-ip '(?\; ?:))) (not (c-at-vsemi-p before-ws-ip)) (or (not (eq char-before-ip ?})) - (c-looking-at-inexpr-block-backward c-state-cache)) + (c-looking-at-inexpr-block-backward state-cache)) (> (point) (save-excursion (c-beginning-of-statement-1 containing-sexp) @@ -12750,10 +12765,10 @@ c-guess-basic-syntax (if (>= (point) placeholder) (progn (forward-char) - (skip-chars-forward " \t")) + (skip-chars-forward " \t")) (goto-char placeholder)) (c-add-stmt-syntax 'template-args-cont (list containing-<) t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state)) ;; CASE 17: Statement or defun catchall. @@ -12827,7 +12842,7 @@ c-guess-basic-syntax (goto-char (cdr placeholder)) (back-to-indentation) (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state) (if (/= (point) (cdr placeholder)) (c-add-syntax (car placeholder)))) > -- > Best regards, > Tadeus -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 06 17:47:06 2017 Received: (at 28623) by debbugs.gnu.org; 6 Nov 2017 22:47:06 +0000 Received: from localhost ([127.0.0.1]:54807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBqAb-0005Ok-PG for submit@debbugs.gnu.org; Mon, 06 Nov 2017 17:47:06 -0500 Received: from mail-io0-f177.google.com ([209.85.223.177]:55502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBqAY-0005O8-Pb for 28623@debbugs.gnu.org; Mon, 06 Nov 2017 17:47:03 -0500 Received: by mail-io0-f177.google.com with SMTP id p186so95467ioe.12 for <28623@debbugs.gnu.org>; Mon, 06 Nov 2017 14:47:02 -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=AhpF7xU889wLy/uKXlMfjlk9IqHy9QYzI63Tr0j2Yss=; b=X0UlS+GwjiRUDMLGkujsYLQ56iREPcuhJMeb2mKR2YBlWtSP5fUEbjOmLKbBOx1oOB RajxGklpgzPp35DC0RR1AGGu5nYv9TzgRaz5Er/8c+ukO22zrZEffFodFcpD0D7L5gRh +yqqxdaM1kVMtjQE1EU8Y8EoOQFBk5T27vmD9lTT+4nWTvBs8nT9LCIsoWxoa6M/Wuoh o73nBs2ZgkGmhpnwCimmQM7BGbusS74ZIQfqz4r/+1tPuia3ZNZKUefV+adF99+A4Qqv OzFb6lsF7zFVwiAP+WNhwdU0DmEMl4RISRcXZZYhQwrEBt8bGIIjhqo9yH7L1jgYawNt iFqw== 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=AhpF7xU889wLy/uKXlMfjlk9IqHy9QYzI63Tr0j2Yss=; b=e3SnqpDD8DRMFfvUA/ImFs5/hp20bqPUNljNnlcBwxpPYsZuRkv6Rfab6xe1cVEz5V Ns83R2HW+QAekOOjpVV6K3KM5DL6J1I979rjkF1MQAIqGYAw/hof8F3P/yyhm3/PT3+2 t1WPsIlO1ZQkeAHLOCZ+tPJVGZJ1lECPBRXouE1aWsM4oZVynaR90vOEFQVbbeXLjms6 oeA6yOv/UYK/K1qBaQw1NHDx8TfQk7n8s3M0ls+gEOlnIdtahlqlu6tejp9mMrb9UKej /k4/GZpiD4TxGLn3aDj3kDCGL6wwEIPk0C2zPtrxqhjJEK+q8OJAFKjdXUbbY6IMWHqk g2qg== X-Gm-Message-State: AJaThX4Vkd8I6ulMHbcQwWEquIvDgu0ggvnxRUslrCKYB5wsglXoB+z7 69DZvq68fQgWP/NzB+4gtxFGXCUudfaSbTa1BjLb X-Google-Smtp-Source: ABhQp+Qr129DTaTGGy9C8d/mN7sE93abwgksbjsxTM3/je41k540Ln3IqB1fS59+zxQyAJDwr3fm8LlPQdJrmo69mKs= X-Received: by 10.107.82.6 with SMTP id g6mr21137295iob.253.1510008416549; Mon, 06 Nov 2017 14:46:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.6.2 with HTTP; Mon, 6 Nov 2017 14:46:26 -0800 (PST) In-Reply-To: <20171104195639.GA5384@ACM> References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> <20171104195639.GA5384@ACM> From: Tadeus Prastowo Date: Mon, 6 Nov 2017 23:46:26 +0100 Message-ID: Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28623 Cc: John Wiegley , 28623@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: -2.3 (--) Hi Alan! On Sat, Nov 4, 2017 at 8:56 PM, Alan Mackenzie wrote: > Hello, Tadeus. > > On Thu, Oct 12, 2017 at 13:38:56 +0200, Tadeus Prastowo wrote: >> Hi Alan! > >> On Wed, Oct 11, 2017 at 10:32 PM, Alan Mackenzie wrote: >> > Hello, Tadeus. > >> [...] > >> > I'm sorry is been a week without any communication from me. The reason >> > is I've run into problems with other related cases. For example, in > >> > 1. auto bad4 = f <3> ( >> > 2. {3, 4}, > >> > L2 needs to be parsed as an arglist-intro and indented as shown. It's >> > actually being parsed as a brace-list-open with anchor point on "auto". > >> > What's confusing me is the confusion between a brace list being >> > recognised by its context (which is what >> > c-looking-at-or-maybe-in-bracelist mostly does) and by its content. The >> > {3, 4} above is a brace list by its content but not by its context. >> > However, it's being wrongly recognised as a by-context brace list, hence >> > is being parsed and indented wrongly. > >> > I'm not going to have much time to sort this out over the next week or >> > two, so please bear with me. I haven't forgotten about this. > >> Thanks for sharing the problem with me. I will also look into the >> matter during this weekend. Hopefully I can come up with a good >> solution :) Sorry that I did not manage to spare the last three weekends to look into the problem :( > I think I've solved this, though it's been perhaps the most difficult bug > in CC Mode for some years. Each time I thought I'd nailed it, some > awkward test case would misbehave. Thank you very much for working on it. > Anyhow, would you please try the patch below, which should apply cleanly > to either the emacs-26 branch or master. It is not finished; for example > I've still got to amend several comments. Nevertheless I think it's > working. I look forward to hearing of any problems which are still in > this patch, or of a report that it seems to be working. The patch applied to master cleanly. Against the mwe.cpp I sent the other day, the patch works fine. But, it does not work with the following one: -- 8< ---------------------------------- int main() { /* Indentation produced by my patch the other day */ 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 my patch the other day */ /* Problem observed using your 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: Problem observed using your patch */ } -- 8< ---------------------------------- 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. > 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. [...] > -- > Alan Mackenzie (Nuremberg, Germany). -- Best regards, Tadeus From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 08 14:25:03 2017 Received: (at 28623) by debbugs.gnu.org; 8 Nov 2017 19:25:03 +0000 Received: from localhost ([127.0.0.1]:58903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCVyA-0001DV-Qz for submit@debbugs.gnu.org; Wed, 08 Nov 2017 14:25:03 -0500 Received: from ocolin.muc.de ([193.149.48.4]:47213 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1eCVy8-0001Cq-1I for 28623@debbugs.gnu.org; Wed, 08 Nov 2017 14:25:00 -0500 Received: (qmail 21678 invoked by uid 3782); 8 Nov 2017 19:24:56 -0000 Received: from acm.muc.de (p548C6D8A.dip0.t-ipconnect.de [84.140.109.138]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 08 Nov 2017 20:24:55 +0100 Received: (qmail 5248 invoked by uid 1000); 8 Nov 2017 19:23:58 -0000 Date: Wed, 8 Nov 2017 19:23:58 +0000 To: Tadeus Prastowo Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list Message-ID: <20171108192358.GA4582@ACM> References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> <20171104195639.GA5384@ACM> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 28623 Cc: John Wiegley , 28623@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: -0.0 (/) Hello again, Tadeus. On Mon, Nov 06, 2017 at 23:46:26 +0100, Tadeus Prastowo wrote: > Hi Alan! > On Sat, Nov 4, 2017 at 8:56 PM, Alan Mackenzie wrote: > > Hello, Tadeus. [ .... ] > Sorry that I did not manage to spare the last three weekends to look > into the problem :( > > I think I've solved this, though it's been perhaps the most difficult bug > > in CC Mode for some years. Each time I thought I'd nailed it, some > > awkward test case would misbehave. > Thank you very much for working on it. > > Anyhow, would you please try the patch below, which should apply cleanly > > to either the emacs-26 branch or master. It is not finished; for example > > I've still got to amend several comments. Nevertheless I think it's > > working. I look forward to hearing of any problems which are still in > > this patch, or of a report that it seems to be working. > The patch applied to master cleanly. > Against the mwe.cpp I sent the other day, the patch works fine. But, > it does not work with the following one: 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. 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. > -- 8< ---------------------------------- > int main() { > /* Indentation produced by my patch the other day */ > 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 my patch the other day */ > /* Problem observed using your 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: Problem observed using your patch */ > } > -- 8< ---------------------------------- > 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. > > 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. > [...] Here's the amended patch: diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 6f39cc6433..982be3bb3b 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -10407,16 +10407,20 @@ c-backward-over-enum-header (defun c-looking-at-or-maybe-in-bracelist (&optional containing-sexp lim) ;; Point is at an open brace. If this starts a brace list, return a list ;; whose car is the buffer position of the start of the construct which - ;; introduces the list, and whose cdr is t if we have parsed a keyword - ;; matching `c-opt-inexpr-brace-list-key' (e.g. Java's "new"), nil - ;; otherwise. Otherwise, if point might be inside an enclosing brace list, - ;; return t. If point is definitely neither at nor in a brace list, return - ;; nil. + ;; introduces the list, and whose cdr is the symbol `in-paren' if the brace + ;; is directly enclosed in a parenthesis form (i.e. an arglist), t if we + ;; have parsed a keyword matching `c-opt-inexpr-brace-list-key' (e.g. Java's + ;; "new"), nil otherwise. Otherwise, if point might be inside an enclosing + ;; brace list, return t. If point is definitely neither at nor in a brace + ;; list, return nil. ;; ;; CONTAINING-SEXP is the position of the brace/paren/bracket enclosing ;; POINT, or nil if there is no such position, or we do not know it. LIM is ;; a backward search limit. ;; + ;; The determination of whether the brace starts a brace list is solely by + ;; the context of the brace, not by its contents. + ;; ;; Here, "brace list" does not include the body of an enum. (save-excursion (let ((start (point)) @@ -10426,17 +10430,20 @@ c-looking-at-or-maybe-in-bracelist (and (c-major-mode-is 'pike-mode) c-decl-block-key)) (braceassignp 'dontknow) - inexpr-brace-list bufpos macro-start res pos after-type-id-pos) + inexpr-brace-list bufpos macro-start res pos after-type-id-pos + in-paren) (setq res (c-backward-token-2 1 t lim)) ;; Checks to do only on the first sexp before the brace. ;; Have we a C++ initialization, without an "="? (if (and (c-major-mode-is 'c++-mode) (cond - ((and (not (eq res 0)) + ((and (or (not (eq res 0)) + (eq (char-after) ?,)) (c-go-up-list-backward nil lim) ; FIXME!!! Check ; `lim' 2016-07-12. (eq (char-after) ?\()) - (setq braceassignp 'c++-noassign)) + (setq braceassignp 'c++-noassign + in-paren 'in-paren)) ((looking-at c-pre-id-bracelist-key)) ((looking-at c-return-key)) ((and (looking-at c-symbol-start) @@ -10445,9 +10452,11 @@ c-looking-at-or-maybe-in-bracelist (t nil)) (save-excursion (cond - ((not (eq res 0)) + ((or (not (eq res 0)) + (eq (char-after) ?,)) (and (c-go-up-list-backward nil lim) ; FIXME!!! Check `lim' 2016-07-12. - (eq (char-after) ?\())) + (eq (char-after) ?\() + (setq in-paren 'in-paren))) ((looking-at c-pre-id-bracelist-key)) ((looking-at c-return-key)) (t (setq after-type-id-pos (point)) @@ -10486,7 +10495,7 @@ c-looking-at-or-maybe-in-bracelist (c-backward-syntactic-ws) (eq (char-before) ?\())) ;; Single identifier between '(' and '{'. We have a bracelist. - (cons after-type-id-pos nil)) + (cons after-type-id-pos 'in-paren)) (t (goto-char pos) @@ -10544,7 +10553,7 @@ c-looking-at-or-maybe-in-bracelist (braceassignp ;; We've hit the beginning of the aggregate list. (c-beginning-of-statement-1 containing-sexp) - (cons (point) inexpr-brace-list)) + (cons (point) (or in-paren inexpr-brace-list))) ((and after-type-id-pos (save-excursion (when (eq (char-after) ?\;) @@ -10569,7 +10578,7 @@ c-looking-at-or-maybe-in-bracelist nil nil)) (and (consp res) (eq (car res) after-type-id-pos)))))) - (cons bufpos inexpr-brace-list)) + (cons bufpos (or in-paren inexpr-brace-list))) ((eq (char-after) ?\;) ;; Brace lists can't contain a semicolon, so we're done. ;; (setq containing-sexp nil) @@ -10593,12 +10602,16 @@ c-looking-at-or-maybe-in-bracelist (t t)))) ;; The caller can go up one level. ))) -(defun c-inside-bracelist-p (containing-sexp paren-state) +(defun c-inside-bracelist-p (containing-sexp paren-state accept-in-paren) ;; return the buffer position of the beginning of the brace list ;; statement if we're inside a brace list, otherwise return nil. ;; CONTAINING-SEXP is the buffer pos of the innermost containing ;; paren. PAREN-STATE is the remainder of the state of enclosing - ;; braces + ;; braces. ACCEPT-IN-PAREN is non-nil iff we will accept as a brace + ;; list a brace directly enclosed in a parenthesis. + ;; + ;; The "brace list" here is recognized solely by its context, not by + ;; its contents. ;; ;; N.B.: This algorithm can potentially get confused by cpp macros ;; placed in inconvenient locations. It's a trade-off we make for @@ -10613,17 +10626,11 @@ c-inside-bracelist-p ;; this will pick up array/aggregate init lists, even if they are nested. (save-excursion (let ((bufpos t) - lim next-containing) + next-containing) (while (and (eq bufpos t) containing-sexp) (when paren-state - (if (consp (car paren-state)) - (setq lim (cdr (car paren-state)) - paren-state (cdr paren-state)) - (setq lim (car paren-state))) - (when paren-state - (setq next-containing (car paren-state) - paren-state (cdr paren-state)))) + (setq next-containing (c-pull-open-brace paren-state))) (goto-char containing-sexp) (if (c-looking-at-inexpr-block next-containing next-containing) @@ -10632,14 +10639,16 @@ c-inside-bracelist-p ;; containing sexp, so that c-looking-at-inexpr-block ;; doesn't check for an identifier before it. (setq bufpos nil) - (when (or (not (eq (char-after) ?{)) - (eq (setq bufpos (c-looking-at-or-maybe-in-bracelist - next-containing lim)) - t)) - (setq containing-sexp next-containing - lim nil - next-containing nil)))) - (and (consp bufpos) (car bufpos)))))) + (if (not (eq (char-after) ?{)) + (setq bufpos nil) + (when (eq (setq bufpos (c-looking-at-or-maybe-in-bracelist + next-containing next-containing)) + t) + (setq containing-sexp next-containing + next-containing nil))))) + (and (consp bufpos) + (or accept-in-paren (not (eq (cdr bufpos) 'in-paren))) + (car bufpos)))))) (defun c-looking-at-special-brace-list (&optional _lim) ;; If we're looking at the start of a pike-style list, i.e., `({ })', @@ -11506,6 +11515,7 @@ c-guess-basic-syntax ;; The paren state outside `containing-sexp', or at ;; `indent-point' if `containing-sexp' is nil. (paren-state (c-parse-state)) + (state-cache (copy-tree paren-state)) ;; There's always at most one syntactic element which got ;; an anchor pos. It's stored in syntactic-relpos. syntactic-relpos @@ -11668,7 +11678,7 @@ c-guess-basic-syntax (not (c-at-vsemi-p before-ws-ip)) (not (memq char-after-ip '(?\) ?\] ?,))) (or (not (eq char-before-ip ?})) - (c-looking-at-inexpr-block-backward c-state-cache)) + (c-looking-at-inexpr-block-backward state-cache)) (> (point) (progn ;; Ought to cache the result from the @@ -11746,7 +11756,7 @@ c-guess-basic-syntax (if containing-sexp (progn (goto-char containing-sexp) - (setq lim (c-most-enclosing-brace c-state-cache + (setq lim (c-most-enclosing-brace state-cache containing-sexp)) (c-backward-to-block-anchor lim) (c-add-stmt-syntax 'case-label nil t lim paren-state)) @@ -11772,7 +11782,7 @@ c-guess-basic-syntax (containing-sexp (goto-char containing-sexp) - (setq lim (c-most-enclosing-brace c-state-cache + (setq lim (c-most-enclosing-brace state-cache containing-sexp)) (save-excursion (setq tmpsymbol @@ -11816,7 +11826,7 @@ c-guess-basic-syntax (goto-char (cdr placeholder)) (back-to-indentation) (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state) (unless (eq (point) (cdr placeholder)) (c-add-syntax (car placeholder)))) @@ -12239,11 +12249,11 @@ c-guess-basic-syntax (and (eq (char-before) ?}) (save-excursion (let ((start (point))) - (if (and c-state-cache - (consp (car c-state-cache)) - (eq (cdar c-state-cache) (point))) + (if (and state-cache + (consp (car state-cache)) + (eq (cdar state-cache) (point))) ;; Speed up the backward search a bit. - (goto-char (caar c-state-cache))) + (goto-char (caar state-cache))) (c-beginning-of-decl-1 containing-sexp) ; Can't use `lim' here. (setq placeholder (point)) (if (= start (point)) @@ -12400,7 +12410,8 @@ c-guess-basic-syntax ((and (eq char-after-ip ?{) (progn (setq placeholder (c-inside-bracelist-p (point) - paren-state)) + paren-state + nil)) (if placeholder (setq tmpsymbol '(brace-list-open . inexpr-class)) (setq tmpsymbol '(block-open . inexpr-statement) @@ -12482,7 +12493,7 @@ c-guess-basic-syntax (skip-chars-forward " \t")) (goto-char placeholder)) (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state)) ;; CASE 7G: we are looking at just a normal arglist @@ -12523,7 +12534,7 @@ c-guess-basic-syntax (save-excursion (goto-char containing-sexp) (c-looking-at-special-brace-list))) - (c-inside-bracelist-p containing-sexp paren-state)))) + (c-inside-bracelist-p containing-sexp paren-state t)))) (cond ;; CASE 9A: In the middle of a special brace list opener. @@ -12571,7 +12582,7 @@ c-guess-basic-syntax (= (point) containing-sexp))) (if (eq (point) (c-point 'boi)) (c-add-syntax 'brace-list-close (point)) - (setq lim (c-most-enclosing-brace c-state-cache (point))) + (setq lim (c-most-enclosing-brace state-cache (point))) (c-beginning-of-statement-1 lim nil nil t) (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) @@ -12597,7 +12608,7 @@ c-guess-basic-syntax (goto-char containing-sexp)) (if (eq (point) (c-point 'boi)) (c-add-syntax 'brace-list-intro (point)) - (setq lim (c-most-enclosing-brace c-state-cache (point))) + (setq lim (c-most-enclosing-brace state-cache (point))) (c-beginning-of-statement-1 lim) (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) @@ -12619,7 +12630,7 @@ c-guess-basic-syntax ((and (not (memq char-before-ip '(?\; ?:))) (not (c-at-vsemi-p before-ws-ip)) (or (not (eq char-before-ip ?})) - (c-looking-at-inexpr-block-backward c-state-cache)) + (c-looking-at-inexpr-block-backward state-cache)) (> (point) (save-excursion (c-beginning-of-statement-1 containing-sexp) @@ -12753,7 +12764,7 @@ c-guess-basic-syntax (skip-chars-forward " \t")) (goto-char placeholder)) (c-add-stmt-syntax 'template-args-cont (list containing-<) t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state)) ;; CASE 17: Statement or defun catchall. @@ -12827,7 +12838,7 @@ c-guess-basic-syntax (goto-char (cdr placeholder)) (back-to-indentation) (c-add-stmt-syntax tmpsymbol nil t - (c-most-enclosing-brace c-state-cache (point)) + (c-most-enclosing-brace state-cache (point)) paren-state) (if (/= (point) (cdr placeholder)) (c-add-syntax (car placeholder)))) > -- > Best regards, > Tadeus -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 09 04:28:35 2017 Received: (at 28623) by debbugs.gnu.org; 9 Nov 2017 09:28:35 +0000 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 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 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) MIME-Version: 1.0 Received: by 10.2.6.2 with HTTP; Thu, 9 Nov 2017 01:27:55 -0800 (PST) In-Reply-To: <20171108192358.GA4582@ACM> References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> <20171104195639.GA5384@ACM> <20171108192358.GA4582@ACM> From: Tadeus Prastowo Date: Thu, 9 Nov 2017 10:27:55 +0100 Message-ID: Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 28623 Cc: John Wiegley , 28623@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: -2.8 (--) 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 From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 09 13:55:09 2017 Received: (at 28623-done) by debbugs.gnu.org; 9 Nov 2017 18:55:09 +0000 Received: from localhost ([127.0.0.1]:60780 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCryn-0003nL-L8 for submit@debbugs.gnu.org; Thu, 09 Nov 2017 13:55:09 -0500 Received: from ocolin.muc.de ([193.149.48.4]:20306 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1eCryl-0003nC-Ax for 28623-done@debbugs.gnu.org; Thu, 09 Nov 2017 13:55:07 -0500 Received: (qmail 32206 invoked by uid 3782); 9 Nov 2017 18:55:05 -0000 Received: from acm.muc.de (p548C6A35.dip0.t-ipconnect.de [84.140.106.53]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 09 Nov 2017 19:55:04 +0100 Received: (qmail 15116 invoked by uid 1000); 9 Nov 2017 18:53:54 -0000 Date: Thu, 9 Nov 2017 18:53:54 +0000 To: Tadeus Prastowo Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list Message-ID: <20171109185354.GA15085@ACM> References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> <20171104195639.GA5384@ACM> <20171108192358.GA4582@ACM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 28623-done Cc: John Wiegley , 28623-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: -0.0 (/) Hello, Tadeus. On Thu, Nov 09, 2017 at 10:27:55 +0100, Tadeus Prastowo wrote: > On Wed, Nov 8, 2017 at 8:23 PM, Alan Mackenzie wrote: [...] > > 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. I've committed the patch to the canonical places, including the emacs-26 branch at savannah (whence it will find it's way into master), and I'm closing the bug. [ .... ] > 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? There are two such functions, c-forward-decl-or-cast-1 and c-guess-basic-syntax. Both of them have LOTS of local variables which would have to be passed into smaller individual functions, and sometimes those functions would have to alter the "more global" version of the variable. Doing this would indeed be slower, but probably not very much. I suspect all the parameter passing would be awkward. But it's worth stating that my predecessor, Martin Stjernholm, extracted c-guess-continued-construct from c-guess-basic-syntax, which shows that it is possible. > -- > Best regards, > Tadeus -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 10 07:08:31 2017 Received: (at 28623-done) by debbugs.gnu.org; 10 Nov 2017 12:08:31 +0000 Received: from localhost ([127.0.0.1]:33255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eD86n-00061x-KQ for submit@debbugs.gnu.org; Fri, 10 Nov 2017 07:08:31 -0500 Received: from mail-io0-f175.google.com ([209.85.223.175]:51545) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eD86m-00061i-7Z for 28623-done@debbugs.gnu.org; Fri, 10 Nov 2017 07:08:28 -0500 Received: by mail-io0-f175.google.com with SMTP id b186so13348516iof.8 for <28623-done@debbugs.gnu.org>; Fri, 10 Nov 2017 04:08:28 -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=gxaDrOVVw0vS9NUxTqp2z3S/DuJqzQ1eZGLJSpTjhD8=; b=PjrZu43mByRODMNOlgroaeWyhgO2fNpaUDf0td681q2yYg1eJqA6L0stf+dva2rK0d OCAFW4oVNaQmjfZpGJtc1L0dHyHy/Olnrxa+u9YPlEv3X+yQyOA0M/79XGTEDexhNKrW 17al9niYrcVKW/0OLVIW6O0b6DWszLqRAdGj5x3dVPIVwiYsIta6zs5PrEKiguHfDhGa JwSOaIqFO5tOFRAnq/53a9q1UsqtVJTYLgkbxEJL6XYdbD3mPwtfgKFKpW8lroAKEYdj TIbB9+L4Z/1SdDKoS/eLbCDGHxWybgH0oFMCbpXXdF5b8i5MRiMORtRUHRh/TSmy3x5M E7TQ== 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=gxaDrOVVw0vS9NUxTqp2z3S/DuJqzQ1eZGLJSpTjhD8=; b=lbi9uCH6Jme8utRMlvkELrNzJSc1IrzJPh9N51uONVGlL4SMXUvxwfv39fVP4oKdj/ zEgYbO4ZK+zh0WhHcvnWNSwrfr16rDS0Y9Nks28sR8M8bQD7ln6/1T46EKmEYRuHFcrl iqu5i4zy7mmDusxa2U03Id7aanGmEruPhOWULG4k/FWMg47xzzuzEH28rngHVbo89e+L nWynxcLzGaotAEjgiZHbOUUZak0D7wqgH62Ua3PovMfSlwR+KnYxao3V9s3nPkqSFYHq /+xoJttEHfXNz8x4jHQ1WaBhO3G+vkDRBM7GnGJIfV7MZxnTYgZE67/NqGLPyr5WRV0X lM7Q== X-Gm-Message-State: AJaThX5hJIr3eERmEAeNJO0O+5BE8uD6jGj1UnXXwhkvNnJ+DnhgT8ga vjApvcPRQIf0uH8Z1V42JOHS39GSLVi2qy6r6IJ2 X-Google-Smtp-Source: AGs4zMbrOpkuV5laPpXPwQl127xvOY+VSul2mdnC4A6uOD5SfcJwN7OlU+mAleuo0rd5O4k9WOMQWLMs1RFMMqhqPXM= X-Received: by 10.107.129.149 with SMTP id l21mr123304ioi.193.1510315702377; Fri, 10 Nov 2017 04:08:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.6.2 with HTTP; Fri, 10 Nov 2017 04:07:51 -0800 (PST) In-Reply-To: <20171109185354.GA15085@ACM> References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> <20171104195639.GA5384@ACM> <20171108192358.GA4582@ACM> <20171109185354.GA15085@ACM> From: Tadeus Prastowo Date: Fri, 10 Nov 2017 13:07:51 +0100 Message-ID: Subject: Re: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list To: Alan Mackenzie Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 28623-done Cc: John Wiegley , 28623-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: -2.8 (--) Hi Alan! On Thu, Nov 9, 2017 at 7:53 PM, Alan Mackenzie wrote: > Hello, Tadeus. > > On Thu, Nov 09, 2017 at 10:27:55 +0100, Tadeus Prastowo wrote: [...] > I've committed the patch to the canonical places, including the emacs-26 > branch at savannah (whence it will find it's way into master), and I'm > closing the bug. Thank you very much. >> 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? > > There are two such functions, c-forward-decl-or-cast-1 and > c-guess-basic-syntax. Both of them have LOTS of local variables which > would have to be passed into smaller individual functions, and sometimes > those functions would have to alter the "more global" version of the > variable. > > Doing this would indeed be slower, but probably not very much. I suspect > all the parameter passing would be awkward. But it's worth stating that > my predecessor, Martin Stjernholm, extracted c-guess-continued-construct > from c-guess-basic-syntax, which shows that it is possible. I see. Thank you very much for kindly explaining that to me. > -- > Alan Mackenzie (Nuremberg, Germany). -- Best regards, Tadeus From unknown Thu Aug 14 21:51:12 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 08 Dec 2017 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator