mur*_*att 6 c++ emacs indentation
即使我在.emacs文件中定义了C++头文件,我也无法为emacs中的C++头文件获取零偏移量.
下面的头文件显示了两个名称空间内的类定义,最重要的是我想要的零关联的公共关键字,如下所示.
namespace n1
{
namespace n2 // no offset
{
class SomeClass // no offset from namespace open curly
{
public: // this line with zero offset
SomeClass(); // offset 4
...
};
inline SomeClass::SomeClass() // no offset
{
}
} // n2
} // n2
Run Code Online (Sandbox Code Playgroud)
在我的.emacs文件中,我添加了这样的标签:
(c-set-offset 'label 0)
Run Code Online (Sandbox Code Playgroud)
我使用Ctrl-C Ctrl-S来找出要修改的内容.我在.emacs文件中定义的其他偏移工作正常,并且0以外的值也适用于标签.
当我为标签设置偏移0时,当击中该行的标签时,结果为1.这很奇怪,看起来像其他东西覆盖或添加至少1.
任何人都可以解释我如何实现我想要的东西,也许还可以解释目前发生的事情?
哎呀,这是我的第一个问题.谢谢 :)
更新:
感谢答案,我已经能够得到更多,但仍然没有整体解决方案,因为更改所需的东西,以获得访问者的总偏移0导致其他我不想要的东西.Thsi是我目前所处的位置:
(c-set-offset 'access-label 0)
Run Code Online (Sandbox Code Playgroud)
我还需要将.h文件作为C++进行低调,所以我补充说:
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
Run Code Online (Sandbox Code Playgroud)
仅这一点并没有消除我看到的1个偏移量,但似乎存在访问者的类别.将此值设置为0实际上会导致总偏移量为0.
(c-set-offset 'inclass 0)
Run Code Online (Sandbox Code Playgroud)
问题是,现在其他成员如成员总共0如下:
class Foo
{
public:
Foo();
~Foo();
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我将最上面的介绍更改为偏移4
(c-set-offset 'topmost-intro 4)
Run Code Online (Sandbox Code Playgroud)
这反过来导致了例如同一文件中的内联函数声明的其他更改.总而言之,我不知道如何以我想要的方式调整它.
UPDATE2:
添加了SomeClass ctor的内联声明,没有偏移.