5

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"]]}}
Michiel Borkent
  • 34,228
  • 15
  • 86
  • 149

2 Answers2

3

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

Michał Marczyk
  • 83,634
  • 13
  • 201
  • 212
  • Michal: I was trying this outside a repl (because I spin up a repl often just to try something) - got bitten by this again. Inside a project it works. Tnx! – Michiel Borkent Feb 02 '13 at 17:55
2

This is now also supported in project.clj:

:global-vars {*print-length* 20}
Michiel Borkent
  • 34,228
  • 15
  • 86
  • 149