From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.bugs Subject: bug#23312: 25.0.92; C++: Incorrect indentation of enum values inside a class Date: Mon, 25 Apr 2016 10:20:57 +0200 Message-ID: References: <20160422200208.40627.qmail@mail.muc.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c123cfa2c9db305314adba0 X-Trace: ger.gmane.org 1461572541 6949 80.91.229.3 (25 Apr 2016 08:22:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Apr 2016 08:22:21 +0000 (UTC) Cc: 23312@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 25 10:22:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aubmX-00064d-IN for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Apr 2016 10:22:13 +0200 Original-Received: from localhost ([::1]:58488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aubmW-0003ay-Nq for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Apr 2016 04:22:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aubmS-0003YQ-DM for bug-gnu-emacs@gnu.org; Mon, 25 Apr 2016 04:22:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aubmQ-0007ty-Tq for bug-gnu-emacs@gnu.org; Mon, 25 Apr 2016 04:22:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aubmM-0007qO-44; Mon, 25 Apr 2016 04:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1aubmL-0008TR-VT; Mon, 25 Apr 2016 04:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Anders Lindgren Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 25 Apr 2016 08:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23312 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 23312-submit@debbugs.gnu.org id=B23312.146157246732502 (code B ref 23312); Mon, 25 Apr 2016 08:22:01 +0000 Original-Received: (at 23312) by debbugs.gnu.org; 25 Apr 2016 08:21:07 +0000 Original-Received: from localhost ([127.0.0.1]:45582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aublT-0008SA-0P for submit@debbugs.gnu.org; Mon, 25 Apr 2016 04:21:07 -0400 Original-Received: from mail-yw0-f176.google.com ([209.85.161.176]:33298) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aublP-0008RJ-Ee for 23312@debbugs.gnu.org; Mon, 25 Apr 2016 04:21:04 -0400 Original-Received: by mail-yw0-f176.google.com with SMTP id t10so195324762ywa.0 for <23312@debbugs.gnu.org>; Mon, 25 Apr 2016 01:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=UrgFXBg+zp57MnpxEgeqrOMGgwt9nYNLReobNUo86OU=; b=RWKl7PDYIlLPeNftTLN/cK//9ZY2owdiFb/xKwY/kEMXMLg93H3r4wcKJoxPY+/Yg5 gUqkSpF2OAJY4U08ciJHOgb1TugYnkYsPi+BpX1qAp07zAVaFh3n+M75rCwJeG3sBzbG MdnaZqODAaFbYE38+c7rGBr/ypvZK97rsj20GW5Ege/UlATDNw+Log0gARAxGYjlxLxC BhKdU3TAwy43pEvI2QplDoVrohk5OuVfH3QjRGIc6vf8rw8D6NH/s10t5y8PRcqrwdDw +oZ1/J5YtsXOmcprd5lPKhHV6QdUkooeDTcPendoOu11OtIu7vz9fS25uphEnC0hIW7F hPhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=UrgFXBg+zp57MnpxEgeqrOMGgwt9nYNLReobNUo86OU=; b=H5jCrjw4BbRE7RELVOxmj4hFun3aJzmN/vdav2FGc7aMhvz9nLPH+bK+GQb57Yb38E RsUL7ntwf0w+RYKUgO75BZ7ORsJdeO8u1KYonRnWWoKUeR8p7lQXMvuE3rlcOiPTEtlI JNrznTngVwsdwFUGfXzatT0JyF9THCJUG031Vr55r6Za6PKYYQIi/y6+wOELy0zIAtUF KuZUJAZT7Y+VvVKWsbnGKU8cFER/clzerSab02fm8bC7/eWTB/Sw8/tpyNYxisSlwVwr R/+pvZQVT4TvJQNRH0MOstdL4lBEvGLY3nCAV7DeXCVFkwe2IttMOP5xbZn3ZnVnVNyn y/Jw== X-Gm-Message-State: AOPr4FUfH1jEUlQlvs8AW32O4qT9B9/0+NAP68nyj0auiXK+pX5jpFQnL2LcjXt+kX/UmFGOTXrbj1sfh8CD5A== X-Received: by 10.159.39.33 with SMTP id a30mr11191010uaa.59.1461572458026; Mon, 25 Apr 2016 01:20:58 -0700 (PDT) Original-Received: by 10.31.214.131 with HTTP; Mon, 25 Apr 2016 01:20:57 -0700 (PDT) In-Reply-To: <20160422200208.40627.qmail@mail.muc.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:116794 Archived-At: --94eb2c123cfa2c9db305314adba0 Content-Type: text/plain; charset=UTF-8 Hi! I can confirm that the patch fix the problems I've seen regarding indentation of enums in C++ classes. I would recommend that this patch is installed in Emacs 25.1, as there is a big C++ community using Emacs. Alan, thanks for fixing this! -- Anders On Fri, Apr 22, 2016 at 10:02 PM, Alan Mackenzie wrote: > Hello, Anders. > > In article you wrote: > > [-- text/plain, encoding 7bit, charset: UTF-8, 101 lines --] > > > In C++ mode in Emacs 25.0.92, enums inside classes are incorrectly > indented. > > > For example (emacs -Q): > > > class MyClass > > { > > public: > > enum Id > > { > > kAlpha, > > kBeta // Incorrect indentation. > > > In Emacs 24.5, the "kAlpha" and "kBeta" were aligned, as expected. > > This was caused by an enhancement (for C++ typed enums) which failed > properly to check its occurrence. > > I think the following patch fixes the bug. Would you please try it out > in real code, and either confirm it works properly, or tell me what is > still faulty. Thanks! > > > > diff --git a/.gitignore b/.gitignore > index 7c8b743..c1d9067 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -261,7 +261,10 @@ ChangeLog > [0-9]*.txt > .dir-locals?.el > /vc-dwim-log-* > +*.diff > > +.gitattributes > +*.acm > # Built by 'make install'. > etc/emacs.tmpdesktop > > diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el > index 62bc236..1be438f 100644 > --- a/lisp/progmodes/cc-engine.el > +++ b/lisp/progmodes/cc-engine.el > @@ -8928,11 +8928,11 @@ c-cheap-inside-bracelist-p > (not (looking-at "="))))) > b-pos))) > > -(defun c-backward-colon-prefixed-type () > - ;; We're at the token after what might be a type prefixed with a > colon. Try > - ;; moving backward over this type and the colon. On success, return t > and > - ;; leave point before colon; on failure, leave point unchanged. Will > clobber > - ;; match data. > +(defun c-backward-typed-enum-colon () > + ;; We're at a "{" which might be the opening brace of a enum which is > + ;; strongly typed (by a ":" followed by a type). If this is the case, > leave > + ;; point before the colon and return t. Otherwise leave point > unchanged and return nil. > + ;; Match data will be clobbered. > (let ((here (point)) > (colon-pos nil)) > (save-excursion > @@ -8941,7 +8941,10 @@ c-backward-colon-prefixed-type > (or (not (looking-at "\\s)")) > (c-go-up-list-backward)) > (cond > - ((eql (char-after) ?:) > + ((and (eql (char-after) ?:) > + (save-excursion > + (c-backward-syntactic-ws) > + (c-on-identifier))) > (setq colon-pos (point)) > (forward-char) > (c-forward-syntactic-ws) > @@ -8965,7 +8968,7 @@ c-backward-over-enum-header > (let ((here (point)) > up-sexp-pos before-identifier) > (when c-recognize-post-brace-list-type-p > - (c-backward-colon-prefixed-type)) > + (c-backward-typed-enum-colon)) > (while > (and > (eq (c-backward-token-2) 0) > > > > -- Anders Lindgren > > > > > In GNU Emacs 25.0.92.1 (i686-w64-mingw32) > > of 2016-03-21 built on LAPHROAIG > > Windowing system distributor 'Microsoft Corp.', version 6.1.7601 > > Configured using: > > 'configure --host=i686-w64-mingw32 --without-dbus > > --without-compress-install CFLAGS=-static' > > -- > Alan Mackenzie (Nuremberg, Germany). > > --94eb2c123cfa2c9db305314adba0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi!

I can confirm that the patch fix th= e problems I've seen regarding indentation of enums in C++ classes.

I would recommend that this patch is installed in Ema= cs 25.1, as there is a big C++ community using Emacs.

<= div>Alan, thanks for fixing this!

=C2=A0 =C2=A0 --= Anders


On Fri, Apr 22, 2016 at 10:02 PM, Alan Mackenzie <acm@muc.de= > wrote:
Hello, Anders.

In article <mailman.648.1461058386.7477.bug-gnu-emacs@gnu.org> you wrot= e:
> [-- text/plain, encoding 7bit, charset: UTF-8, 101 lines --]

> In C++ mode in Emacs 25.0.92, enums inside classes are incorrectly ind= ented.

> For example (emacs -Q):

> class MyClass
> {
> public:
>=C2=A0 =C2=A0enum Id
>=C2=A0 =C2=A0{
>=C2=A0 =C2=A0 =C2=A0kAlpha,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0kBeta=C2=A0 =C2=A0 =C2=A0// Incorrect indent= ation.

> In Emacs 24.5, the "kAlpha" and "kBeta" were align= ed, as expected.

This was caused by an enhancement (for C++ typed enums) which failed
properly to check its occurrence.

I think the following patch fixes the bug.=C2=A0 Would you please try it ou= t
in real code, and either confirm it works properly, or tell me what is
still faulty.=C2=A0 Thanks!



diff --git a/.gitignore b/.gitignore
index 7c8b743..c1d9067 100644
--- a/.gitignore
+++ b/.gitignore
@@ -261,7 +261,10 @@ ChangeLog
=C2=A0[0-9]*.txt
=C2=A0.dir-locals?.el
=C2=A0/vc-dwim-log-*
+*.diff

+.gitattributes
+*.acm
=C2=A0# Built by 'make install'.
=C2=A0etc/emacs.tmpdesktop

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 62bc236..1be438f 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -8928,11 +8928,11 @@ c-cheap-inside-bracelist-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (not (looking-at "=3D")))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0b-pos)))

-(defun c-backward-colon-prefixed-type ()
-=C2=A0 ;; We're at the token after what might be a type prefixed with = a colon.=C2=A0 Try
-=C2=A0 ;; moving backward over this type and the colon.=C2=A0 On success, = return t and
-=C2=A0 ;; leave point before colon; on failure, leave point unchanged.=C2= =A0 Will clobber
-=C2=A0 ;; match data.
+(defun c-backward-typed-enum-colon ()
+=C2=A0 ;; We're at a "{" which might be the opening brace of= a enum which is
+=C2=A0 ;; strongly typed (by a ":" followed by a type).=C2=A0 If= this is the case, leave
+=C2=A0 ;; point before the colon and return t.=C2=A0 Otherwise leave point= unchanged and return nil.
+=C2=A0 ;; Match data will be clobbered.
=C2=A0 =C2=A0(let ((here (point))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (colon-pos nil))
=C2=A0 =C2=A0 =C2=A0(save-excursion
@@ -8941,7 +8941,10 @@ c-backward-colon-prefixed-type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(or (not (looking-at= "\\s)"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(c-go-= up-list-backward))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cond
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((eql (char-after) = ?:)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((and (eql (char-af= ter) ?:)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(save-excursion
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(c-backward-syntactic-ws)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(c-on-identifier)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq colon-p= os (point))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(forward-char= )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(c-forward-sy= ntactic-ws)
@@ -8965,7 +8968,7 @@ c-backward-over-enum-header
=C2=A0 =C2=A0(let ((here (point))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 up-sexp-pos before-identifier)
=C2=A0 =C2=A0 =C2=A0(when c-recognize-post-brace-list-type-p
-=C2=A0 =C2=A0 =C2=A0 (c-backward-colon-prefixed-type))
+=C2=A0 =C2=A0 =C2=A0 (c-backward-typed-enum-colon))
=C2=A0 =C2=A0 =C2=A0(while
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (and
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(eq (c-backward-token-2) 0)


>=C2=A0 =C2=A0 =C2=A0-- Anders Lindgren



> In GNU Emacs 25.0.92.1 (i686-w64-mingw32)
>=C2=A0 of 2016-03-21 built on LAPHROAIG
> Windowing system distributor 'Microsoft Corp.', version 6.1.76= 01
> Configured using:
>=C2=A0 'configure --host=3Di686-w64-mingw32 --without-dbus
>=C2=A0 --without-compress-install CFLAGS=3D-static'

--
Alan Mackenzie (Nuremberg, Germany).


--94eb2c123cfa2c9db305314adba0--