From: Anders Lindgren <andlind@gmail.com>
To: Alan Mackenzie <acm@muc.de>
Cc: 23312@debbugs.gnu.org
Subject: bug#23312: 25.0.92; C++: Incorrect indentation of enum values inside a class
Date: Mon, 25 Apr 2016 10:20:57 +0200 [thread overview]
Message-ID: <CABr8ebY_QxUpuE7jJmzzb6R8ptShP-HStMBoNsfy82zZz7JgMA@mail.gmail.com> (raw)
In-Reply-To: <20160422200208.40627.qmail@mail.muc.de>
[-- Attachment #1: Type: text/plain, Size: 3608 bytes --]
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 <acm@muc.de> wrote:
> Hello, Anders.
>
> In article <mailman.648.1461058386.7477.bug-gnu-emacs@gnu.org> 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).
>
>
[-- Attachment #2: Type: text/html, Size: 4793 bytes --]
next prev parent reply other threads:[~2016-04-25 8:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 9:32 bug#23312: 25.0.92; C++: Incorrect indentation of enum values inside a class Anders Lindgren
[not found] ` <mailman.648.1461058386.7477.bug-gnu-emacs@gnu.org>
2016-04-22 20:02 ` Alan Mackenzie
2016-04-25 8:20 ` Anders Lindgren [this message]
2016-04-29 13:42 ` Alan Mackenzie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABr8ebY_QxUpuE7jJmzzb6R8ptShP-HStMBoNsfy82zZz7JgMA@mail.gmail.com \
--to=andlind@gmail.com \
--cc=23312@debbugs.gnu.org \
--cc=acm@muc.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.