【问题标题】:How to alter emacs c indenting style to not indent opening brace with inline c++ methods如何使用内联 c++ 方法将 emacs c 缩进样式更改为不缩进左大括号
【发布时间】:2011-04-27 01:53:24
【问题描述】:

我现在在 emacs 中使用 bsd 样式。这是我多年前从学习 pascal 后开始使用的一种风格,我决定在新项目中使用其他风格。

然而,emacs bsd 风格有两点让我很头疼。它缩进内联方法。

1) 如何阻止它像这样缩进?

class A
{
    A()
      {
         // do stuff
      }
};

我希望大括号与这样的方法在同一行。

class A
{
    A()
    {
       // do stuff
    }
};

环顾四周,好像我需要设置 c-set-offset substatement-open'0)

但我不知道如何将它附加到 lisp 中的 bsd 样式。我试了一下,但在启动 emacs 时出现解析错误。

2) 如何让tab键插入4个空格?

【问题讨论】:

    标签: emacs


    【解决方案1】:

    我刚刚检查了我的 emacs 设置,这就是你为我描述的:

    (setq c-default-style "bsd"
          c-basic-offset 4)
    

    试试这个插入空格而不是制表符:

    (setq tab-width 4)
    (setq indent-tabs-mode nil)
    

    【讨论】:

    • 解决了部分问题。那么内联方法的缩进呢?
    • 我不确定。对我来说(setq c-default-style "bsd" .....)意图内联方法就像你需要的那样。
    • 好的,一定与我的 .emacs 中的其他内容有关,这些内容是我前段时间在其他地方抓取的。我会默认它并引入我绝对想要的部分。
    • 如果您愿意,请查看我的 .emacs,您可能会发现一些有用的东西。 github.com/rreeves/Emacs-stuff/blob/master/.emacs。说到标签,我喜欢的一件事是 smart-tab.el @github.com/genehack/smart-tab/tree/master
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多