在Emacs中适当缩进Clojure的“匹配”

时间:2016-05-05 20:00:40

标签: emacs clojure

我使用Clojure-mode和CIDER运行Emacs 24.5,core.match中的[System.Security.SecuritySafeCritical] // auto-generated private void Dispose(bool disposing) { if (hkey != null) { if (!IsSystemKey()) { try { hkey.Dispose(); } catch (IOException){ // we don't really care if the handle is invalid at this point } finally { hkey = null; } } else if (disposing && IsPerfDataKey()) { SafeRegistryHandle.RegCloseKey(RegistryKey.HKEY_PERFORMANCE_DATA); } } } 宏自动缩进。

匹配子句被推到了极右,就像普通的函数参数一样:

match

而短2空格缩进会更好:

(match [1 2]
       [1 _] "one"
       :else "two")

使Emacs正确缩进(match [1 2] [1 _] "one" :else "two") (及其他常见特殊情况)的常用方法是什么?

1 个答案:

答案 0 :(得分:5)

(define-clojure-indent
  (match 1))
在您的Emacs init文件中

这在clojure-mode的自述文件中有记录;从版本5.3.0开始,按照this link了解相关部分。

相关问题