clojure + emacs on windows (the september 2011 version)
There are a bunch of tutorials floating around online on how to get started with an emacs/slime setup for clojure on windows, but—not surprising given the rapid rate of changes in the clojure ecosystem—I wasn’t able to find one that wasn’t outdated or ran without throwing esoteric errors on installation. After a lot of trial-and-error, I managed to get a proper workflow up and running, and decided to document it in case I forget.
I’ve added a few extra steps to make sure nothing is stored in C:\ (which makes it easy for me when I need to reinstall the OS) that you’ll likely need to change/ignore depending on your partition setup, but on the whole I’m happy with this checklist. As always, YMMV and all that; I frankly don’t expect this to last a few months from now, but it might at least be a starting point:
- Pre-install checks
- Delete
~/.emacs.d/and~/.emacs
- Delete
- Installing Leiningen
- Get the Windows distribution from here (e.g., leiningen-1.5.2.zip)
- Extract it to
A:\lein - Replace lein.bat with the latest stable version
- Add
A:\leinto$PATH - Set the
LEIN_HOMEenvironment variable toD:\.leinto make Leiningen store its executables there (instead of%USERPROFILE%\.lein) - Create a junction at
%USERPROFILE%\.m2pointing toD:\.m2so that the Maven local repository is stored inD:\:junction.exe %USERPROFILE%\.m2 D:\.m2 - Run
lein self-install, which fetches the lein jar file
- Installing emacs
- Get the latest emacs distribution from here. Make sure it’s v23 or above
- Extract it to
A:\emacs\. Don’t open emacs yet! - Set the
HOMEenvironment variable toD:to make emacs pick up its config files fromD:\
- Installing emacs-startup-kit
- cd to
D:\ - Run
git clone git://github.com/technomancy/emacs-starter-kit.git .emacs.d - Open emacs
M-x package-list-packages- Select the following packages by pressing
Ito mark for installation:clojure-modeclojure-test-modeslimeslime-repl
- Press
Xto install the selected packages - After it’s done installing,
C-X C-Cto quit emacs
- cd to
- Installing swank-clojure
- Run
lein plugin install swank-clojure 1.3.2(or whatever’s the latest version recommended at the project site)
- Run
- Running everything
- After creating a project (
lein new project-name), open one of the files in emacs M-x clojure-jack-in- That’s it! The Slime REPL should open in a bit, and you’re all set
- After creating a project (
- Customizing Emacs
- Contents of my
~/.emacs, after installingcolor-themeandcolor-theme-zenburnusingM-x package-list-packages:(load "~/.emacs.d/init.el") (set-default-font "Consolas-11") (eval (color-theme-zenburn)) - An insanely roundabout way to pin Emacs to the Win7 taskbar:
(From here; I’m really surprised this actually worked)
Pinning Emacs to the windows 7 taskbar is somewhat of an annoyance: the preferred way to run Emacs seems to be viarunemacs.exe, which launches Emacs without the background console window that you’d get when runningemacs.exedirectly. However,runemacs.exeandemacs.exehave different GUIDs, and therefore, you end up with two buttons for Emacs in the taskbar when you try to pin either one and try to use it. Not really a problem, but annoying in a vague sort of way. This can be fixed by pinning theemacs.exeprocess first, right-clicking the taskbar shortcut to get theClose/Unpin/emacs… menu, then right-clicking theemacsoption to get to its Properties window, and changing the target from …emacs.exeto …runemacs.exe.
- Contents of my