How can I fix emacs highlighting of C ++ initializers?

Emacs does not properly indent C ++ class definitions for allocators that have colon initializers. I think this is because lines with colons are in many cases the same length.

I would like to fix it.

Here is an example of what I'm talking about.

EMACS discards the code as follows:

class demo {
    int x;
    demo(){
    }
 demo(int y):x(y){
    };
};

But it should really backtrack like this:

class demo {
    int x;
    demo(){
    }
    demo(int y):x(y){
    };
};

Is there any way to fix this behavior? Presumably we need some elisp ...

Thank!

+3
source share
1 answer

Emacs ( , 23) C, ++, C . , ++ (M-x c++-mode).

+5

All Articles