所以常规的 clojure repl 工作正常,(read-line)
收集输入,然后回显它。使用lein repl
虽然,从不回显任何输入字符,也不允许我从任何标准输入读取命令返回。
我确定它与重新绑定有关,但想知道是否有解决方法/修复?
谢谢。
这是由于 ant 中的错误造成的;它防止使用它启动的子进程中的标准输入流。但是 telnet 技巧应该可以工作,因为 lein repl 启动了一个套接字 repl 服务器;它在这里工作正常。
通过 telnet 连接到 REPL。
$ lein repl
REPL started; server listening on localhost:63849.
user=>
[1]+ Stopped lein repl
$ telnet localhost 63849
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
user=> (read-line)
hello
"hello"
user=>
现在这对我有用:用 ns swank.core 中的宏 with-read-line-support 包装你的 read-line 调用 [因为我相信 swank-clojure 1.4+]:
(use 'swank.core)
(with-read-line-support
(println "a line from Emacs:" (read-line)))
感谢 Tavis Judd 的修复。