Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set up Aquamacs for Clojure development?

I've tried to migrate to Emacs several times for Clojure development, following a variety of blogposts, screencast and tutorials, but somewhere along the way something always went wrong - keybindings that didn't work, incompatible versions, etc, and I found myself scrambling back to Vim. But I know I want Paredit and SLIME.

So, I'm going to try again, this time backed by the powerful Stack Overflow™ community.

I hope that the answer to this question will remain up-to-date, and can serve as a reference for tentative converts like me.

What I'd like is:

  • The latest stable release of Clojure
  • Aquamacs (if it's good enough for Rich Hickey, it's good enough for me), a recent version
  • Clojure Mode
  • SLIME/SWANK
  • Paredit
  • Anything else that's indispensible?

Step-by-step instructions to install the above would be excellent - preferably in shell script format. I'd also like some hints on how to get started with the most common Clojure-related actions (including key-bindings), including links to documentation and cheatsheets.

like image 817
Michiel de Mare Avatar asked Jan 22 '10 21:01

Michiel de Mare


4 Answers

These are the steps I took to set them up without using ELPA. Hope this helps.

Get SLIME using MacPorts

sudo port -v install slime

Get paredit

curl -O http://mumble.net/~campbell/emacs/paredit.el

Get clojure & clojure-contrib

  • Either using MacPorts
sudo port -v install clojure clojure-contrib
  • Or downloading directly
curl -O http://build.clojure.org/snapshots/org/clojure/clojure/1.1.0-master-SNAPSHOT/clojure-1.1.0-master-20091202.150145-1.jar
curl -O http://build.clojure.org/snapshots/org/clojure/clojure-contrib/1.1.0-master-SNAPSHOT/clojure-contrib-1.1.0-master-20091212.205045-1.jar

Get clojure-mode and swank-clojure (Emacs side)

git clone http://github.com/technomancy/clojure-mode.git
git clone http://github.com/technomancy/swank-clojure.git

Get swank-clojure (Clojure side)

  • Either downloading pre-built jar file
curl -O http://repo.technomancy.us/swank-clojure-1.1.0.jar
  • Or building from source (assuming lein is installed)
cd path/to/dir/swank-clojure
lein jar

Put clojure, clojure-contrib and swank-clojure .jar files in ~/.swank-clojure or ~/.clojure (the default places where swank-clojure.el searches for them).


Add to either ~/.emacs or ~/Library/Preferences/Aquamacs Emacs/customization.el (change paths to match your own settings)

(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/slime/")
(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/slime/contrib/")
;; Change these paths to match your settings
(add-to-list 'load-path "path/to/dir/clojure-mode/")
(add-to-list 'load-path "path/to/dir/swank-clojure/")
(add-to-list 'load-path "path/to/dir/paredit/")

;; Customize swank-clojure start-up to reflect possible classpath changes
;; M-x ielm `slime-lisp-implementations RET or see `swank-clojure.el' for more info 
(defadvice slime-read-interactive-args (before add-clojure)
(require 'assoc)
(aput 'slime-lisp-implementations 'clojure
(list (swank-clojure-cmd) :init 'swank-clojure-init)))

(require 'slime)
(require 'paredit)
(require 'clojure-mode)
(require 'swank-clojure)

(eval-after-load "slime"
  '(progn
    ;; "Extra" features (contrib)
    (slime-setup 
     '(slime-repl slime-banner slime-highlight-edits slime-fuzzy))
    (setq 
     ;; Use UTF-8 coding
     slime-net-coding-system 'utf-8-unix
     ;; Use fuzzy completion (M-Tab)
     slime-complete-symbol-function 'slime-fuzzy-complete-symbol)
    ;; Use parentheses editting mode paredit
    (defun paredit-mode-enable () (paredit-mode 1))
    (add-hook 'slime-mode-hook 'paredit-mode-enable)
    (add-hook 'slime-repl-mode-hook 'paredit-mode-enable)))

;; By default inputs and results have the same color
;; Customize result color to differentiate them
;; Look for `defface' in `slime-repl.el' if you want to further customize
(custom-set-faces
 '(slime-repl-result-face ((t (:foreground "LightGreen")))))

(eval-after-load "swank-clojure"
  '(progn
    ;; Make REPL more friendly to Clojure (ELPA does not include this?)
    ;; The function is defined in swank-clojure.el but not used?!?
    (add-hook 'slime-repl-mode-hook
      'swank-clojure-slime-repl-modify-syntax t)
    ;; Add classpath for Incanter (just an example)
    ;; The preferred way to set classpath is to use swank-clojure-project
    (add-to-list 'swank-clojure-classpath 
"path/to/incanter/modules/incanter-app/target/*")))
like image 50
ubolonton Avatar answered Nov 12 '22 18:11

ubolonton


Download and install Aquamacs.

Download and install ELPA (http://tromey.com/elpa/install.html)

Do M-x package-list-packages

Mark the lines called "clojure-mode" and "swank-clojure" with "I" then press "X".

Done.

like image 36
mac Avatar answered Nov 12 '22 18:11

mac


Here's a blog post that mentions Aquamacs: Setting up Clojure, Incanter, Emacs, Slime, Swank, and Paredit

like image 5
Jouni K. Seppänen Avatar answered Nov 12 '22 18:11

Jouni K. Seppänen


There seems to be a fairly easy way to set up Aquamacs 2.4 and SLIME for clojure:

  1. Install Clojure
  2. Install Aquamacs 2.4 from here "http://aquamacs.org/"
  3. Install the Aquamacs SLIME package from here "http://aquamacs.org/download.shtml"

This will not work so...

  1. Get the latest version of SLIME from here "http://common-lisp.net/project/slime/#downloading" - you want the CVS snapshot tar file
  2. Unpack the SLIME tar file and copy it into /Library/Application Support/Aquamacs Emacs/SLIME

Seems to work OK for me...

like image 1
Jim Avatar answered Nov 12 '22 18:11

Jim