2

Emacs 通过以下方式自动缩进 Clojure 代码:

(defn foo [x]
  (if (= 0 x)
    0
    1))

如果它像 Scheme 和 CL 那样做,我会更喜欢:

(defn foo [x]
  (if (= 0 x)
      0
      1))

如何更改我的 .el 文件以实现这一点?

4

2 回答 2

3

我并没有真正对此进行测试,但它似乎有效(在 clojure 模式下):

(put 'if 'clojure-indent-function 3)
于 2011-12-29T19:36:07.450 回答
1

因为我不能在评论中做代码块:

Elisp 没有以您提到的任何一种方式缩进:

(if (test-p foo)
    bar
  baz)

Common-lisp-mode 也以这种方式缩进。方案模式将它们全部排列起来。

于 2013-02-14T23:42:49.567 回答