The regular Clojure repl clojure.main/repl
accepts options like :print
, :prompt
and :eval
that let you hook-in and override the repl's behaviour.
E.g.
(clojure.main/repl
:print #(println "main print!" %)
:prompt #(println "main prompt!")
:eval #(do (println "main eval!") (eval %)))
I assumed that Leiningen's :repl-options
let you specify the same options, and Leiningen would pass them on to Clojure's repl. There's even a hint at this in the Leiningen repo:
Support :repl-options in project.clj that get passed to clojure.main/repl.
I cannot get this to work. It appears that Leiningen doesn't accept the same set of options as clojure.main/repl
. :prompt
works, although the function signature is different, and :print
and :eval
seem to be ignored.
Is there a way to change the print and eval behaviour in Leiningen's repl?
My project.clj
:
(defproject repl-test "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.7.0"]]
:repl-options {
:print #(println "lein print!" %)
:prompt (constantly "lein prompt!")
:eval #(do (println "lein eval!") (eval %))
}
)
I'm using Leiningen 2.7.1.
Background:
I've been trying to set lein repl
to use pprint
for its output. Again, NEWS.md hints at this:
Support :project-init in project.clj to allow pprint to be used in :repl-options.
Help with that also appreciated!