I want correct indentation with my C++ code.

The following piece of code indents properly. It nicely indents the access label and the member declaration independently.

class Test : public Base {
  int a;

However if I add a final keyword, the public won't indent half-ways anymore.

class Test final : public Base {
  int a;

If I go check with C-c C-s, in the first case the line with public returns ((inclass 1011) (access-label 1011)). But for the second case it returns ((label 1011)). Looks like c++-mode is not able to detect that the second case is also a class definition, not a function definition.

I wonder if I have to do something to c++-mode for it to support C++11 syntax.

  • M-x report-emacs-bug? – PythonNut Jul 21 '15 at 16:38
  • @PythonNut Well, haha I never knew there is a function like that. Since C++11 is around for soooo long, my guess is that this feature is implemented somewhere else I don't know. – Hot.PxL Jul 21 '15 at 16:42
  • C++11 is so large and complex that tools like Emacs are slowly, incrementally adding support. You definitely might want to look into filing a bug. I doubt there's a magic enable C++11 switch. – PythonNut Jul 21 '15 at 17:28
  • As far as I can tell, this has been fixed in Emacs 25.1. – Xaldew Feb 25 '16 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.