在profiles.clj中为* print-length *提供默认值的正确方法是什么? [英] What's the correct way of providing a default value for *print-length* in profiles.clj?

查看:62
本文介绍了在profiles.clj中为* print-length *提供默认值的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

For those that do not know what *print-length* stands for:

如果您(设置!*打印长度* 200),并且在REPL中评估(范围),通常会导致获得无限数量的数字打印,只有前200个数字会被打印.

If you (set! *print-length* 200), and you evaluate (range) in a REPL, which normally causes an infinite list of numbers to get printed, only the first 200 numbers will get printed.

我正在尝试将其设置为 profiles.clj 中所有REPL的默认值.现在我明白了,但是不起作用:

I'm trying to set this as a default for all my REPLs in profiles.clj. Right now I got this, but it doesn't work:

{: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 现在看起来像这样.请注意,它仅在项目内部有效.

Update. Tnx Michal for answering this. My fixed profiles.clj now looks like this. Note that it only works inside a project.

{: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"]]}}

推荐答案

:repl-options 必须是Leiningen的 repl 任务支持的选项的映射;其他任何事情都将被忽略. * print-length * 不是一个有效的选项( nil 也不是;我必须检查一下是否在这里评估了键,但这不会)不管哪种方式都可以.)

:repl-options needs to be a map of options supported by Leiningen's repl task; anything else will be ignored. *print-length* is not a valid option (and neither is nil; I'd have to check to be sure if the keys are evaluated here, but this won't work either way).

相反,您应该使用类似的东西

Instead you should use something like

:repl-options {:init (set! *print-length* 200)}

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

See sample.project.clj in the root of Leiningen's repository for a description of the available options (including :init).

这篇关于在profiles.clj中为* print-length *提供默认值的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆