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). > >