Leiningen 是否将 repl-options 传递给 clojure.main/repl

Ale*_*lex 5 clojure leiningen

定期Clojure的REPLclojure.main/repl接受类似的选项:print:prompt并且:eval可以让你钩,并覆盖REPL的行为。

例如

(clojure.main/repl 
    :print #(println "main print!" %) 
    :prompt #(println "main prompt!") 
    :eval  #(do (println "main eval!") (eval %)))
Run Code Online (Sandbox Code Playgroud)

我假设 Leiningen:repl-options允许您指定相同的选项,而 Leiningen 会将它们传递给 Clojure 的 repl。在 Leiningen 的 repo 中甚至有一个提示:

支持传递给 clojure.main/repl 的 project.clj 中的 :repl-options。

我不能让它工作。似乎 Leiningen 不接受与clojure.main/repl. :prompt有效,尽管函数签名不同,:print并且:eval似乎被忽略了。

有没有办法改变莱宁根 repl 中的打印和评估行为?

我的project.clj

(defproject repl-test "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.7.0"]]
  :repl-options { 
    :print #(println "lein print!" %)
    :prompt (constantly "lein prompt!")
    :eval #(do (println "lein eval!") (eval %))
  }
)
Run Code Online (Sandbox Code Playgroud)

我正在使用莱宁根 2.7.1。

背景:

我一直在试图设置lein repl使用pprint其输出。NEWS.md 再次暗示了这一点:

在 project.clj 中支持 :project-init 以允许在 :repl-options 中使用 pprint。

帮助也很感激!

Pio*_*dyl 3

lein repl启动 nREPL,而不是clojure.main/repl. 它支持一组不同的选项。检查示例project.clj以获取支持的参数列表