Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the correct way of providing a default value for *print-length* in profiles.clj?

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

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.

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

What's wrong with this?

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"]]}}
like image 210
Michiel Borkent Avatar asked Feb 02 '13 17:02

Michiel Borkent


1 Answers

: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)}

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

like image 99
Michał Marczyk Avatar answered Sep 28 '22 13:09

Michał Marczyk