![clojure 替代 emacs 和 slime](https://linux22.com/image/1374189/clojure%20%E6%9B%BF%E4%BB%A3%20emacs%20%E5%92%8C%20slime.png)
我已经为 emacs 配置了 slime,并且可以运行许多不同的 common lisp 实现。那么运行像 clojure 这样的语言怎么样?
我通过修改文件来测试这一点.emacs
:
(add-to-list 'load-path "~/slime/") ; your SLIME directory
(setq slime-lisp-implementations
`((sbcl ("/usr/bin/sbcl"))
(clojure ("/usr/bin/clojure"))
(ecl ("/usr/bin/ecl"))
(clisp ("/usr/bin/clisp" "-q -I"))))
;(setq inferior-lisp-program "/usr/bin/sbcl") ; your Lisp system
(require 'slime)
(slime-setup '(slime-fancy))
看起来可行,但是有一个例外:
(progn (load "/home/d2b2/slime/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.19396"))
此外,我在迷你缓冲区中收到一条奇怪的消息:
polling "/tmp/slime2.4708" .. ddd (Abort with M-x 'slime-abort-connection'.)
其中ddd
计时器以秒为单位增加。
Clojure 1.1.0
user=> java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)
user=> user=>
我决定运行一个 commonlisp 解释器并进行比较。这是我sbcl
在收到提示之前从解释器获得的信息:
(progn (load "/home/d2b2/slime/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank-loader:init")) (funcall (read-from-string "swank:start-server") "/tmp/slime.19396"))
This is SBCL 1.0.55.0.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
*
; loading #P"/home/d2b2/slime/swank-loader.lisp"
STYLE-WARNING: redefining EMACS-INSPECT (#<BUILT-IN-CLASS T>) in DEFMETHOD
STYLE-WARNING:
Implicitly creating new generic function STREAM-READ-CHAR-WILL-HANG-P.
WARNING: These Swank interfaces are unimplemented:
(DISASSEMBLE-FRAME SLDB-BREAK-AT-START SLDB-BREAK-ON-RETURN)
;; Swank started at port: 57199.
57199
* STYLE-WARNING:
redefining THREAD-FOR-EVALUATION (#<STRUCTURE-CLASS
MULTITHREADED-CONNECTION>
#<SB-MOP:EQL-SPECIALIZER
{1004A8CC43}>) in DEFMETHOD
然后通用 Lisp 解释器出现了。
- 我该如何使用 slime 设置 clojure repl 或者如何解决我的小问题?
答案1
有一个swank-clojure使用 SLIME 和 Clojure 的项目,但现在已被弃用,取而代之的是nrepl.el。我的建议是查看 nrepl.el。
nrepl 是事实上repl 用于 Clojure,并且与 nrepl.el 一起它具有与 SLIME 类似的功能 - 您在 Emacs 中运行 REPL,从缓冲区向其发送代码,可以快速跳转到定义,获得动态代码完成等。与 SLIME 相比,我发现它唯一有点欠缺的地方是调试,但 swank-clojure 不支持 SLIME 的调试器。