views:

135

answers:

1

I use Aquamacs, and aquamacs is pre-equipped with slime.

(setq inferior-lisp-program "/usr/local/bin/sbcl") #####!!!
(add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME/contrib")
(add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME")
(require 'slime)
(slime-setup)

As is asked in here, I try to use clojure by adding this code.

(add-to-list 'load-path "~/clojure/clojure-mode")
(setq inferior-lisp-program "/Users/smcho/bin/clj") ################
(require 'clojure-mode)
(setq auto-mode-alist
  (cons '("\\.clj$ . clojure-mode")
     auto-mode-alist))
(add-hook 'clojure-mode-hook
  '(lambda ()
     (define-key clojure-mode-map "\C-c\C-e" 'lisp-eval-last-sexp)))
)

I couldn't make it clojure run with slime, but I'm satisfied with the current setting, the only problem is that because of the (setq inferior-lisp-program ...) code, I have to change the .emacs code depending on I use clojure or sbcl.

Is there any way to solve this problem? Can I choose between multiple (inferior) lisps?

Added

I could make clojure run on Aquamacs. Please refer to this. Forget about the settings written above, if you want to run aquamacs/clojure. you need just one line (slime-setup '(slime-repl)) and 'lein swank'.

+3  A: 

Sure, you can use C-u M-x slime instead of just M-x slime to have SLIME ask you for the name of the Lisp executable to be launched, with whatever is your default already filled in.

There's also a slime-lisp-implementations variable which I have configured like so:

(setq slime-lisp-implementations
      `((clojure ,(swank-clojure-cmd) :init swank-clojure-init)
        (sbcl ("sbcl") :coding-system utf-8-unix)))

I have to say that I just can't remember what this does for me anymore (if indeed it does anything)... Type C-h v slime-lisp-implementations to learn roughly what it's supposed to do. I seem to have to type sbcl if I want to start that, which is fine by me due to the high Clojure-to-SBCL ratio in my SLIME'ing.

Update:

I have just rediscovered M-- M-x slime (that first key is meta-minus for a negative argument), which prompts for one of the names of Lisp implementations in slime-lisp-implementations (with tab completion) and then starts the required Lisp. With the above example config, M-- M-x slime sbcl starts SBCL.

(I find this useful mostly because of how it allows one to configure more complex commands to start Lisp -- e.g. (sbcl-options ("sbcl" "--an-option" "--another-option") ...), (sbcl-clbuild ("/path/to/clbuild" "lisp") ...) -- and refer to them by name.)

Michał Marczyk
By the way, at least the `(clojure ...)` entry is absolutely guaranteed to do nothing at all, since `swank-clojure` currently arranges to have it replaced just before the (Clojure) Swank server is started.
Michał Marczyk