问题
I've been using emacs/slime for coding lisp, but with Clojure I found 'lein swank'. I must say that it's pretty useful, as I can connect to a server that runs clojure.
How about the other Lisp implementations? What Lisp implementations provide the equivalent of 'lein swank' in Clojure? I mean, is there any other Lisp implementations that provide server connectivity so that I use 'M-x slime-connect', not just 'M-x slime'?
回答1:
Non-clojure swank backends don't need a lein swank equivalent since they can just launch a lisp instance and change its load-path at runtime to make it work for a given project. That approach doesn't work with Clojure since the JVM's classpath can't be modified at runtime.
回答2:
I don't know about clisp, but this is what I have for SBCL. This co-exists with my clojure swank setup as well. I don't use ELPA and instead have a completely manual setup.
(add-to-list 'load-path "~/src/slime")
(require 'slime)
(add-to-list 'slime-lisp-implementations '(sbcl ("/usr/local/bin/sbcl")))
(setq slime-default-lisp 'sbcl)
I have a hand compiled SBCL. I see a swank backend for CLISP in the SLIME CVS codebase, so I guess, changing slime-default-lisp and slime-lisp-implementations to clisp probably will just work.
lein swank mainly exists for starting swank port on a particular project. This is needed because JVM classpaths cannot be modified at runtime. So, we start java with classpaths set to our project directories and dependencies using lein swank or swank-clojure-project. With CL, this is not necessary, as pathnames can be modified during runtime.
I have posted the complete config file at: http://github.com/vu3rdd/dotfiles
I will be glad to help setting up a fully manual emacs/slime/swank setup.
回答3:
You can load swank manually in CL and start the server (slime/swank were created for CL after all).
回答4:
Fire up the Lisp implementation, load Swank (via Quicklisp, for example), and run swank:create-server
:
CL-USER(1): (ql:quickload "swank")
;; ...
CL-USER(2): (swank:create-server)
;; Swank started at port: 4005.
4005
If you want to specify a different port, you can do so by using the :port
keyword argument:
CL-USER(3): (swank:create-server :port 4123)
;; Swank started at port: 4123.
4123
Note that since the protocol tends to change between versions, you need to make sure that you are not using wildly different versions of SLIME and Swank. For Common Lisp, I tend to use the versions from Quicklisp by putting something like the following into my .emacs
, depending on the version of SLIME currently available in Quicklisp:
(add-to-list 'load-path "~/quicklisp/dists/quicklisp/software/slime-20111105-cvs")
(add-to-list 'load-path "~/quicklisp/dists/quicklisp/software/slime-20111105-cvs/contrib")
来源:https://stackoverflow.com/questions/3548169/equivalent-of-lein-swank-to-other-lisp-scheme-implementations-with-emacs-slime