【问题标题】:Double indent when using Emacs php-mode使用 Emacs php-mode 时双缩进
【发布时间】:2011-11-05 21:51:46
【问题描述】:

我的问题是,在新行中使用大括号时,我得到了额外的缩进,如下面列出的代码所示。

我在 debian-lenny 上使用 emacs 22.2,我已经从 github 安装了 php-mode.el

(https://github.com/ejmr/php-mode/blob/master/php-mode.el)

我的 .emacs 只包含键绑定(不用于缩进)

if (logical condition)
       {
             avariable 
             #COMMENT 
             if (logical condition)
                 {
                     if(condition)
                          {
                               variable
................

我已经为所有 php 文件尝试了 PEAR 模式,我已经尝试了 tab 模式缩进。

请问,我做错了什么?

更新:

以上是默认的“GNU”缩进样式。对于标准 php 缩进,将以下内容添加到您的 .emacs

(setq c-default-style "linux" c-基本偏移 4)

在这里找到答案:http://www.emacswiki.org/emacs/IndentingC#toc2

【问题讨论】:

  • 您应该回答自己的问题,然后接受您的回答。此外,Emacs 22.2 可以追溯到 2008 年 3 月;您不妨考虑升级。
  • 如果你还没有,你应该尝试nxhtml模式,当你编辑包含超过php的文件(如php和html)时,这通常会更好。

标签: php emacs php-mode


【解决方案1】:

以上是默认的“GNU”缩进样式。对于标准 php 缩进,将以下内容添加到您的 .emacs

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

在这里找到答案:http://www.emacswiki.org/emacs/IndentingC#toc2

【讨论】:

    猜你喜欢
    • 2010-12-18
    • 1970-01-01
    • 2012-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-06
    相关资源
    最近更新 更多