Download
Leiningen installer script and put it in a directory. I personally, have a
Programs directory in my home; so I put the script in
/home/bahman/Programs/Leiningen. Change the permissions of the script to be executable either using your favourite file manager or using command line as below:
$ chmod +x DIRECTORY_YOU_HAVE_PUT_THE_SCRIPT_IN/lein
Now at the command line,
cd to the directory you have put the script in and run
$ ./lein self-install
and wait a short while for Leiningen to download the needed JAR files.
3. Install Slime
Now it's time to download
Slime.
Remember that you cannot use the version shipped with your distro. Only a specific version of Slime works with Leiningen.
At a command prompt run
$ git clone https://github.com/technomancy/slime/
and then copy the slime directory which
git just created to the desired place. Again, I put it under
/home/bahman/Programs .
Now open
~/.emacs in your favourite editor and add this at the end of the file:
(add-to-list 'load-path "PATH_TO_SLIME/")
(add-to-list 'load-path "PATH_TO_SLIME/contrib/")
(require 'slime)
(slime-setup '(slime-fancy))
(slime-setup '(slime-repl))
4. Install Elpa (Emacs package manager)
For a more complete guide see Elpa installation guide.
Run Emacs. In the
*scratch* buffer type this
(let ((buffer (url-retrieve-synchronously
"http://tromey.com/elpa/package-install.el")))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer))))
then press
ALT+x and type
eval-buffer.
Close Emacs. Open
~/.emacs.d/init.el in your favourite text editor (create the file if it doesn't exist yet) and paste this in the file to add Marmalade package repository to Emacs.
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
Open
~/.emacs too and add this at the end and save it.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
Run Emacs. Press
ALT+x and type
package-list-packages and hit
ENTER. A list of packages that can be installed is shown. Navigate to a package named
clojure-mode and press
i followed by
x. Voila! It's done!
5. Test Your Installation
At a command prompt (assuming you have added
~/.lein to your $
PATH and have
cd'ed to the desired directory) run
$ lein new myproject. Run Emacs. Press
ALT+x followed by
cd. Now enter the directory of the project you just created with Leiningen and hit
ENTER. Now type
ALT+x again followed by
clojure-jack-in. If you get a warning about Slime version (just ignore it), this means that you have setup everything correctly so far.
6. Git Integration
If you haven't installed
Git yet, run this at the command prompt to do so
$ sudo apt-get install git
We'll use
Egg for integration of Emacs and Git. Clone the
Egg repository like this
$ git clone https://github.com/bogolisk/egg.git
and copy the egg directory to
~/.emacs.d
Open
~/.emacs in your favourite editor and add this to the end of it
(add-to-list 'load-path (expand-file-name "~/.emacs.d/egg"))
(require 'egg)
Restart Emacs and it's all done.
7. Javadoc Lookup
This is a real handy and neat feature: browsing Javadocs inside Emacs!
Fire up Emacs, press
ALT+x and type
package-list-packages followed by
ENTER. In the packages list, navigate to the package named
javadoc-help. Type
x followed by
i. After the package is installed. Open
~/.emacs in your favourite text editor and add this to the end of it to enable
javadoc-help.
(require 'javadoc-help)
. In the customisation buffer that just opened change the value of the "Value Menu" drop-down to "Your own function". Then in the box in front of it type
. Then press both "Set for current session" and "Set for future sessions" buttons (make sure they are pressed!) and then press "Exit".