1
votes

Whenever I call a clojure function that gets a users' console input using (read-line) through SLIME or a normal REPL, the function returns immediately. I've resorted to jar'ing up my project and running it to test but this obviously isn't quick or sustainable.

Is there some trick to getting console interaction through a REPL working or is it not possible? If not are there any good workarounds?

2
Please, can you test that *in* is the proper BufferedReader? - Serabe
*in* appears to be of type #<LineNumberingPushbackReader clojure.lang.LineNumberingPushbackReader@36673c9f>. I read in another question that it's known not to work. I upgraded swank-clojure to 1.4.0 snapshot and it just returns nil now. - Chris Mowforth

2 Answers

0
votes

Currently there doesn't seem to be any way of reading console input through swank-clojure; calling (read-line) simply returns nil in 1.4.0-SNAPSHOT and hangs in earlier versions. Installing 1.4.0 as a user-level leiningen plugin seems to be the best bet right now. At least the REPL will return to your control at some point.

0
votes

This will work now with swank-clojure 1.4.0-SNAPSHOT if you wrap the call to read-line in swank.core/with-read-line-support like this

(with-read-line-support (println "a line from Emacs:" (read-line))

https://github.com/technomancy/swank-clojure/commit/f4a1eebc4d34f2ff473c4e5350f889ec356f5168