This is my problem:
I need run some code every time I open a new repl, searching in Google I found that I can use the file init.clj
or the user.clj
(with Leiningen)
This is the code I need to run:
(set! *print-length* 103)
(println "hello")
(println *print-length*)
These are the results with both of the files:
[~/project]$ lein repl
hello <- this is the println, so the file is excecuted
103 <- this is the println of *print-length* apparently change
REPL started; server listening on localhost port 20875
user=> *print-length*
nil <- but the val of *print-length* don't change
Is there something I need to do or do I have some error?
Thanks to all!
(alter-var-root #'*print-length* (constantly 103))
in ~/user.clj
works for me.
As far as I know set!
doesn't work outside of a binding
's dynamic scope.
lein's init.clj runs in the leiningen process, not in your project process. See https://github.com/technomancy/leiningen (search for init.clj)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With