Over the last year, I learned Ruby. I’m not amazing at it and there’s still a lot to learn, but I know enough to be useful with it. In the spirit of learning a new language every year, the next one I wanted to tackle was Clojure.
I also decided to try using Emacs, since I had heard the Clojure support was pretty good.
After installing Emacs on my Mac (which is running OS X 10.7), I spent the morning surfing teh interwebz and trying a few different things to get Clojure working. Here’s how it looked in the end:
- Install Emacs from here.
- Read the tutorial to understand the basic shortcuts (C = control, M = alt below)
- Install marmalade – inside the directory
~/.emacs.dcreate the file
'("marmalade" . "http://marmalade-repo.org/packages/") t)
- Run M-x: “package-refresh-contents”
- M-x package-install
- Install clojure-mode by pressing M-x package-install and choose clojure-mode.
- Install Leiningen by folling the instructions here: https://github.com/technomancy/leiningen
- Install swank-clojure: run “lein plugin install swank-clojure 1.3.3”
Note – I initially installed 1.3.2 which gave me an error when I tried to run it from Emacs.
- Create a new project with Leiningen.
- Open Emacs, navigate to a project file and type M-x clojure-jack-in.
Once this was working, I also discovered a couple of key shortcuts that were really useful:
- C-c C-k compiles the code in the current buffer.
- C-x C-e executes the code in the buffer before the current line end.
Now I’m up and running, I’ve been able to complete all of the 4Clojure Koans at the elementary level. You don’t actually need to have clojure running locally, although I found it helped to figure out what was going on.
I’m also working on the Clojure Koans on github.
So far I’m finding both to be really fun and good learning resources ☺
Some of the best guidance I found
- Clojure.org – getting started with emacs
There were some really good updates in a comment from Muthu Bhuvana Sundaram T – although his steps applied to Windows it was really helpful.