First you need to get “lein”. Lein is a tool that lets you manage your projects in clojure. Lein also has a REPL that lets you run clojure directly.
~$ wget https://raw.github.com/technomancy/leiningen/stable/bin/lein
This will download lein into your home directory. Once downloaded, move it to ~/bin directory. Add bin directory to your PATH environment variable and then finally make this file executable using the following commands.
~$ mkdir ~/bin ~$ mv lein ~/bin ~$ export PATH=$PATH:~/bin #put this into your .bashrc ~$ chmod u+x ~/bin/lein
Once this is done, run lein with the following command
~$ lein repl
This command is to get a REPL command line to run your clojure code. When run for the first time, it will try to find clojure and if it doesn’t find it installed, then it will download clojure and install it and return you the following shell
Write your first clojure program by typing (println “hello, world”) into this shell. You can type (exit) to exit.
There you go, now you have clojure and lein installed.
Now you need to configure your emacs to use this setup. I am going to use SLIME and swank-clojure. First let us install swank-clojure plugin to lein.
~ $ lein plugin install swank-clojure 1.3.4
This command should end with :
Including clojure-1.2.1.jar Created swank-clojure-1.3.4.jar
Now add the ~/bin to execution path within your .emacs file. (anywhere)
(setenv "PATH" (concat (getenv "PATH") ":~/bin")) (setq exec-path (append exec-path '("/sw/bin")))
I prefer using slime for my lisp! sweet sweet slime. It is important that you do not have your old slime, its known to create problems. I would recommend commenting out the old slime load instructions on your .emacs. To load slime, all you need is clojure-mode.el from
and add the following lines in your .emacs
(add-to-list 'load-path "~/.emacs-local/clojure-mode") (require 'clojure-mode)
This is all you need.
Now on your command prompt you could use lein to create a new project.
$ lein new first-project
This will create a new directory called first-project in your current directory.
Open emacs, go to eshell and cd to the directory of the project. Once you are there type
and thats it!! you will have SLIME ready to go!
“hack and glory await”