5

如果我的 .emacs 为空或仅包含行

(require 'cc-mode)
(add-to-list 'c-offsets-alist '(annotation-top-cont .0))

(add-hook 'java-mode-hook
          '(lambda () (c-set-offset 'annotation-top-cont 0)))

然后而不是保护与@Override 对齐

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

protected 出来,而不是相对于 @Override 缩进

@Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

我应该对我的 .emacs 进行哪些更改,以便缩进成为上面的顶部示例?

4

2 回答 2

0

Look to annotation-top-cont style for c-offsets-alist definition. To make no identing you need to set it to 0. More information in CC-mode manual.

于 2012-12-07T18:25:17.133 回答
0

我在 EMACS 邮件列表中找到了这个解决方案:

(add-hook 'java-mode-hook
      '(lambda ()
         "Treat Java 1.5 @-style annotations as comments."
         (setq c-comment-start-regexp 
           "\\(@\\|/\\(/\\|[*][*]?\\)\\)")
         (modify-syntax-entry ?@ "< b" 
                  java-mode-syntax-table)))

它将@annotations 视为注释,这将导致它正确缩进。

来源: http: //lists.gnu.org/archive/html/help-gnu-emacs/2011-04/msg00262.html

于 2013-10-22T06:21:31.053 回答