technomancy / swank-clojure

Swank/slime support for clojure
Eclipse Public License 1.0
412 stars 83 forks source link

Clojure and Common Lisp Compatibility on Mac Os X #66

Closed John-Poplett closed 12 years ago

John-Poplett commented 12 years ago

Requirements

While searching for a satisfactory solution to a compatible Clojure / CL emacs configuration, I started to understand my requirements better. The fundamental requirement was that the emacs configuration must allow for unobtrusive use of Clojure, Common Lisp, Quicklisp, Slime and SBCL.

As a secondary requirement, the solution could not involve manual maintenance and conflict management of multiple copies of slime.

If you're programming in Common Lisp, then you probably know why Quicklisp is a requirement. It's the package manager that CL brings parity with the best of the younger programming languages. If you're working on Clojure, you probably want leiningen for similar reasons.

Solution

Most of the solutions I've seen put the user through contortions or, when I've tried them, don't work (at least not on Mac Os X with Quicklisp as part of the equation).

The solution I am experimenting with at the moment is surprisingly simple. This approach gave me inspiration but fails on the count of requiring too much manual slime configuration management. It did helped me to realize though that I could defer loading slime and only run slime setup on demand, i.e. on M-x slime. That way, if instead, I want to run clojure, I can M-x clojure-jack-in without the presence of a potentially conflicting slime setup in my emacs image. This is an excerpt from my .emacs file. Most of this is just standard Quicklisp slime initialization.

;;; Define a slime that defers slime setup. It first detaches itself ;;; then runs slime setup, then invokes the "real" slime. ;;; By delaying slime setup, quicklisp slime setup doesn't interfere ;;; with M-x clojure-jack-in. ;;; (defun slime () (interactive) (fmakunbound 'slime) (load (expand-file-name "~/quicklisp/slime-helper.el")) (set-language-environment "UTF-8") (setq slime-net-coding-system 'utf-8-unix) (setq inferior-lisp-program "/usr/local/bin/sbcl") (slime))

With this minor modification, M-x slime behaves as before and continues to use the Quicklisp maintained copy of Slime. If I am working in Clojure, M-x clojure-jack-in works as expected. This is working for me with Aquamacs and GNU Emacs for Mac OS X (24).

Setup is based on Emacs for Mac Os X (23.3.1), Quicklisp Slime current (08/11), Swank-clojure 1.3.2 and Snow Leopard. The initial Clojure-swank setup came from the technomancy's readme on the swank-clojure github site.

Problems Along the Way

  1. Multiple versions of swank-clojure in my classpath; removed older plugins with lein plugin uninstall.
  2. Emacs couldn't find my Brew installed line in the path; adding this to .emacs was sufficient: (setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))
  3. Aquamacs had an old version of Slime installed in its private elpa location ( /Users/john/Library/Application Support/Aquamacs Emacs/elpa), a leftover from a previous Clojure integration effort . Removing the older versions of slime from the Aquamacs location allowed me to use the Quicklisp version of slime, same as GNU Emacs for Mac Os X.
technomancy commented 12 years ago

I will add a link to this explanation to the readme under troubleshooting as it trips up a lot of people.

John-Poplett commented 12 years ago

Great! I jotted that down after going through that for a second time!

Regards,

John

On Mon, Dec 19, 2011 at 5:57 PM, Phil Hagelberg < reply@reply.github.com

wrote:

I will add a link to this explanation to the readme under troubleshooting as it trips up a lot of people.


Reply to this email directly or view it on GitHub: https://github.com/technomancy/swank-clojure/issues/66#issuecomment-3211883