我想要的是emacs不缩进命名空间内的代码
namespace a_namespace{
// no indentation
int namespace_global_variable;
// no indentation
class Class {
// comment
Class();
//...
};
// and so on
}
当我尝试修改innamespace
变量,或者使用C-c C-o
来更改感兴趣点处的缩进时,我没有达到预期的效果(事实上后者已经消除了所有缩进在功能内部。)
我的缩进配置如下所示(从Google emacs配置中复制):
(c-offsets-alist . ((arglist-intro vista-c-lineup-expression-plus-4)
(func-decl-cont . ++)
(member-init-intro . +)
(inher-intro . ++)
(comment-intro . 0)
(arglist-close . c-lineup-arglist)
(topmost-intro . 0)
(block-open . 0)
(inline-open . 0)
(substatement-open . 0)
(statement-cont
.
(,(when (fboundp 'c-no-indent-after-java-annotations)
'c-no-indent-after-java-annotations)
,(when (fboundp 'c-lineup-assignments)
'c-lineup-assignments)
++))
(label . /)
(case-label . +)
(statement-case-open . +)
(statement-case-intro . +) ; case w/o {
(access-label . /)
(innamespace . -))))
答案 0 :(得分:13)
(defconst my-cc-style
'("cc-mode"
(c-offsets-alist . ((innamespace . [0])))))
(c-add-style "my-cc-mode" my-cc-style)
来自Jason Zhang的answer。在这里工作。