For 95% I’m developing code on either Unix or OSX operating systems. There is though the odd time I want to do some Clojure work on Windows (usually sat in front of the tele noodling around with some Clojure aspect I’m trying to learn).

Now I’d rather use the same sort of setup as I do on my Mac so here’s my notes on how to get it working Windows 10.

Download Java

Java is not a dirty word, so get over it, the JVM powers way too many businesses than it gets credit for. Download the SDK 1.8 and install it.

Download Emacs

The download mirror has plenty of different versions, I went with 24.5.

Leiningen

The lein build tool is a Clojure godsend and integrates well with Emacs, so we’ll need it. Luckily for us D.J. Powell has kindly created a Windows installer version.

Go to your directory with the .lein directory and run the following:

lein self-install

You’ll see a bunch of things load, that’s fine…..

C:\Users\Jason\.lein\bin>lein self-install
Downloading Leiningen now...

PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
    [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive]
    [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
    [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
    [-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
    [-Command { - | <script-block> [-args <arg-array>]
                  | <string> [<CommandParameters>] } ]

PowerShell[.exe] -Help | -? | /?

Try running lein.bat from the command line and you’ll see lots of jar files load up.

C:\Users\Jason\.lein\bin>lein.bat
Retrieving cider/cider-nrepl/0.10.0-SNAPSHOT/cider-nrepl-0.10.0-20151127.123841-44.pom from clojars
Retrieving org/clojure/tools.nrepl/0.2.12/tools.nrepl-0.2.12.pom from central
Retrieving org/clojure/pom.contrib/0.1.2/pom.contrib-0.1.2.pom from central
Retrieving org/sonatype/oss/oss-parent/7/oss-parent-7.pom from central
Retrieving org/tcrawley/dynapath/0.2.3/dynapath-0.2.3.pom from central
Retrieving refactor-nrepl/refactor-nrepl/2.0.0-SNAPSHOT/refactor-nrepl-2.0.0-20151117.182629-13.pom from clojars
Retrieving org/clojure/tools.nrepl/0.2.10/tools.nrepl-0.2.10.pom from central
Retrieving org/clojure/clojure/1.2.0/clojure-1.2.0.pom from central
Retrieving org/clojure/clojure/1.7.0/clojure-1.7.0.pom from central
Retrieving refactor-nrepl/refactor-nrepl/2.0.0-SNAPSHOT/refactor-nrepl-2.0.0-20151117.182629-13.jar from clojars
Retrieving cider/cider-nrepl/0.10.0-SNAPSHOT/cider-nrepl-0.10.0-20151127.123841-44.jar from clojars
Retrieving org/clojure/clojure/1.7.0/clojure-1.7.0.jar from central
Retrieving org/tcrawley/dynapath/0.2.3/dynapath-0.2.3.jar from central
Retrieving org/clojure/tools.nrepl/0.2.12/tools.nrepl-0.2.12.jar from central
Leiningen is a tool for working with Clojure projects.

Now we’re ready to rock.

Setting Up Emacs

For the uber-emacs guys and gals they can probably sort their own init.el file in their sleep, while drinking Mountain Dew and eating a curry…. for mortals like me it’s easier to nick one created by someone else.

I started off Clojure life with the setup from Clojure for the Brave and True. More recently I’ve used Bruce Durling‘s “Home Lightsabre Kit“, it’s on Github so you can nab it too.

Either softlink or copy the init.el in your .emacs.d folder.

On some Windows installs there is no init.el file, so if you create one with C-x C-f and go to the ~/.emacs.d/ folder from the chooser in Emacs and type in init.el and press return, that will create the new file for you.

Within Bruce’s setup file is everything you need to get the REPL running (via Lein). To start a REPL within Emacs run the following from Emacs itself:

M-x cider-jack-in

emacs

Advertisements