在profiles.clj中为* print-length *提供默认值的正确方法是什么?

时间:2013-02-02 17:29:27

标签: clojure leiningen

对于那些不知道*print-length*代表什么的人:

如果您(set! *print-length* 200),并且在REPL中评估(range),这通常会导致打印无数的数字列表,则只会打印前200个数字。

我正在尝试将此设置为profiles.clj中所有REPL的默认设置。 现在我得到了这个,但它不起作用:

{:user {:plugins [[lein-swank "1.4.4"]
                  [lein-catnip "0.5.0"]]
        :repl-options {*print-length* 200}} 
 :dev {:dependencies [[clj-ns-browser "1.2.0"]
                      [org.clojure/tools.trace "0.7.5"]]}}

这有什么问题?

更新。 Tnx Michal回答此问题。我的固定profiles.clj现在看起来像这样。请注意,它仅适用于项目。

{:user {:plugins [[lein-swank "1.4.4"]
                  [lein-catnip "0.5.0"]]
        :repl-options {:init (set! *print-length* 200)}} 
 :dev {:dependencies [[clj-ns-browser "1.2.0"]
                      [org.clojure/tools.trace "0.7.5"]]}}

2 个答案:

答案 0 :(得分:3)

:repl-options需要是Leiningen repl任务支持的选项图;其他任何东西都会被忽略。 *print-length*不是有效选项(也不是nil;我必须检查以确定是否在此处评估密钥,但这无论如何都无效。)

相反,你应该使用像

这样的东西
:repl-options {:init (set! *print-length* 200)}

请参阅Leiningen存储库根目录中的sample.project.clj,了解可用选项的说明(包括:init)。

答案 1 :(得分:2)

project.clj现在也支持这个:

:global-vars {*print-length* 20}
相关问题