我可以配置 Clojure REPL 自动需要的东西吗?

Can I configure things to be automatically required by the Clojure REPL?

有些函数非常通用,我希望它们始终在 REPL 中可用,无论我当前切换到哪个命名空间。

有没有办法配置 lein repl 自动要求某些东西以便它们在全球范围内可用?另一种方法是调用 (use 'clojure.tools.trace).

之类的东西

Leiningen 2.x 支持 :repl-options 改变 REPL 的行为方式,including :init hook。 Leiningen 会在第一次打开 REPL 时 运行 这个钩子,所以它只会影响你的 :main 命名空间。

以下是使用此选项的示例:

  :repl-options { :init (require '[criterium.core
                                    :refer [bench quick-bench]])}

您可以在相应的 project.clj 文件中为每个项目在本地设置 :repl-options,或者通过将其放入 ~/.lein/profiles.clj 文件来全局设置:

{:user {:repl-options {:init (...)}}}