Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

user.clj and init.clj dont work?

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!

like image 333
patz Avatar asked Jan 05 '12 03:01

patz


2 Answers

(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.

like image 62
mange Avatar answered Oct 13 '22 01:10

mange


lein's init.clj runs in the leiningen process, not in your project process. See https://github.com/technomancy/leiningen (search for init.clj)

like image 42
Joost Diepenmaat Avatar answered Oct 13 '22 00:10

Joost Diepenmaat