开发者

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

Emacs doesn't properly indent C++ class definitions for allocators that have initializers with colons in them. I think that this is because lines with colons are left-indented in many cases.

I would like to fix this.

Here is an example of what I am talking about.

EMACS indents the code like this:

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

But it should really indent it lik开发者_StackOverflow中文版e this:

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

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

Thanks!


Emacs (at least version 23) doesn't do this in C mode, but it does in C++ mode since in C the part before the colon can only be a label. Make sure you're in C++ mode (M-x c++-mode).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜