From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#48992: cc-mode initialize list indentation bug Date: Sat, 21 Aug 2021 17:57:33 +0000 Message-ID: References: <56c9cab5.165.17a028f7978.Coremail.binbowang1987@163.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="RUMZjV8vpP1ew5RT" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21128"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 48992@debbugs.gnu.org To: =?UTF-8?Q?=E7=8E=8B=E6=96=8C=E6=B3=A2?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 21 19:58:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHVFx-0005OP-TB for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Aug 2021 19:58:09 +0200 Original-Received: from localhost ([::1]:32942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHVFw-0004Ks-Au for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Aug 2021 13:58:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHVFq-0004Kk-8x for bug-gnu-emacs@gnu.org; Sat, 21 Aug 2021 13:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54533) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHVFp-0006KM-Vh; Sat, 21 Aug 2021 13:58:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mHVFp-0000gk-QE; Sat, 21 Aug 2021 13:58:01 -0400 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: Sat, 21 Aug 2021 17:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48992 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 48992-submit@debbugs.gnu.org id=B48992.16295686642620 (code B ref 48992); Sat, 21 Aug 2021 17:58:01 +0000 Original-Received: (at 48992) by debbugs.gnu.org; 21 Aug 2021 17:57:44 +0000 Original-Received: from localhost ([127.0.0.1]:37846 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHVFX-0000gC-Tw for submit@debbugs.gnu.org; Sat, 21 Aug 2021 13:57:44 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:24489 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1mHVFV-0000fx-UQ for 48992@debbugs.gnu.org; Sat, 21 Aug 2021 13:57:42 -0400 Original-Received: (qmail 88519 invoked by uid 3782); 21 Aug 2021 17:57:34 -0000 Original-Received: from acm.muc.de (p4fe15b48.dip0.t-ipconnect.de [79.225.91.72]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 21 Aug 2021 19:57:34 +0200 Original-Received: (qmail 11061 invoked by uid 1000); 21 Aug 2021 17:57:33 -0000 Content-Disposition: inline In-Reply-To: <56c9cab5.165.17a028f7978.Coremail.binbowang1987@163.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:212386 Archived-At: --RUMZjV8vpP1ew5RT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello, Binbowang. On Sun, Jun 13, 2021 at 07:29:55 +0800, 王斌波 wrote: > class A { > public: > static std::set setA; > }; > std::set A::setA { > 1, > 2, > 3 > } > The indentation in setA initialize list is not correct. I want it like the following. > class A { > public: > static std::set setA; > }; > std::set A::setA { > 1, > 2, > 3 > } The indentation was indeed incorrect. CC Mode was mis-analysing the brace list as a function. I think the patch attached should fix this. Would you please apply the patch to your CC Mode (in directory ..../emacs/lisp/progmodes), byte compile that file, load it into your Emacs and try it out on your real C++ source code. Then please let me know if the bug is indeed fixed. (If you would like any help with the patching or byte compilation, feel free to send me private email.) > In GNU Emacs 27.1 (build 1, x86_64-w64-mingw32) > of 2020-08-22 built on CIRROCUMULUS > Repository revision: 86d8d76aa36037184db0b2897c434cdaab1a9ae8 > Repository branch: HEAD > Windowing system distributor 'Microsoft Corp.', version 10.0.19042 > System Description: Microsoft Windows 10 Pro (v10.0.2009.19042.1052) [ .... ] -- Alan Mackenzie (Nuremberg, Germany). --RUMZjV8vpP1ew5RT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="diff.20210821.diff" diff -r 92a4592886a1 cc-engine.el --- a/cc-engine.el Sun Apr 25 17:26:38 2021 +0000 +++ b/cc-engine.el Sat Aug 21 17:38:30 2021 +0000 @@ -11882,12 +11882,15 @@ pos2 in-paren parens-before-brace paren-state paren-pos) - (setq res (c-backward-token-2 1 t lim)) + (setq res + (or (progn (c-backward-syntactic-ws) + (c-back-over-compound-identifier)) + (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 (or (not (eq res 0)) + ((and (or (not (memq res '(t 0))) (eq (char-after) ?,)) (setq paren-state (c-parse-state)) (setq paren-pos (c-pull-open-brace paren-state)) @@ -11911,7 +11914,7 @@ (t nil)) (save-excursion (cond - ((or (not (eq res 0)) + ((or (not (memq res '(t 0))) (eq (char-after) ?,)) (and (setq paren-state (c-parse-state)) (setq paren-pos (c-pull-open-brace paren-state)) --RUMZjV8vpP1ew5RT--