Emacs缩进C ++类方法? [英] Emacs indent for C++ class method?

查看:126
本文介绍了Emacs缩进C ++类方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



目前:

  class B 
{
public:
B()
{
}
};

但是我想要:

  class B 
{
public:
B()
{
}
};

有没有人如何使用.emacs?



谢谢!

解决方案

尝试设置 inline-open 0 。这应该放置一个大括号,在同一个缩进级别上打开一个类内嵌式方法。例如:

 (c-set-offset'inline-open'0)

还可能有其他东西,很难说。 CC-Mode 文档有更多的选项及其描述,也可能对您有帮助。



以下是我可以感兴趣的基于Linux编码风格的C ++风格的示例:

 (defun vlad-cc-style()
(c-set-stylelinux)
(c-set-offset 'innamespace'0)
(c-set-offset'inextern-lang'0)
(c-set-offset'inline-open'0)
(c-set-offset'标签'*)
(c-set-offset'case-label'*)
(c-set-offset'access-label'/)
(setq c-basic-offset 4 )
(setq tab-width 4)
(setq indent-tabs-mode nil)


(add-hook'c ++ - 模式挂钩'vlad -cc-style)

希望有帮助。祝你好运!


For some reason, my emacs indent the c++ class method wrong.

Current:

class B
{
public:
    B()
        {
        }
};

But I want:

class B
{
public:
    B()
    {
    }
};

Does anybody how to make it in .emacs?

Thanks!

解决方案

Try setting inline-open to '0. That should place a brace that opens an in-class inline method on the same indent level. For example:

(c-set-offset 'inline-open '0)

There also might be something else, it is hard to say. CC-Mode document has more options and its description that might also be helpful to you.

Below is the example of my C++ style that is based on Linux coding style that might be of interest to you:

(defun vlad-cc-style()
  (c-set-style "linux")
  (c-set-offset 'innamespace '0)
  (c-set-offset 'inextern-lang '0)
  (c-set-offset 'inline-open '0)
  (c-set-offset 'label '*)
  (c-set-offset 'case-label '*)
  (c-set-offset 'access-label '/)
  (setq c-basic-offset 4)
  (setq tab-width 4)
  (setq indent-tabs-mode nil)
)

(add-hook 'c++-mode-hook 'vlad-cc-style)

Hope it helps. Good Luck!

这篇关于Emacs缩进C ++类方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆