<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Free Geek &#187; emacs</title>
	<atom:link href="http://freegeek.in/blog/tag/emacs/feed/" rel="self" type="application/rss+xml" />
	<link>http://freegeek.in/blog</link>
	<description>The Chronicles of Nerd-nia</description>
	<lastBuildDate>Fri, 03 Jun 2011 05:15:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Setting up Emacs &amp; Clojure with Emacs Starter Kit</title>
		<link>http://freegeek.in/blog/2009/08/setting-up-emacs-clojure-with-emacs-starter-kit/</link>
		<comments>http://freegeek.in/blog/2009/08/setting-up-emacs-clojure-with-emacs-starter-kit/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 21:21:55 +0000</pubDate>
		<dc:creator>Baishampayan</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[functional programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://freegeek.in/blog/?p=63</guid>
		<description><![CDATA[Note: This blog post is no longer accurate as a lot of things have changed since I wrote this post. Please check this document for working instructions. Clojure is a very modern functional programming language which runs on the JVM. It&#8217;s a very cleanly designed Lisp dialect and has all the features that any useful [...]]]></description>
			<content:encoded><![CDATA[<p><ins><strong>Note:</strong> This blog post is no longer accurate as a lot of things have changed since I wrote this post. Please check <a title="Clojure Project on Assembla" href="http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs">this document</a> for working instructions.</ins></p>
<p><a href="http://clojure.org">Clojure</a> is a very modern functional programming language which runs on the <a href="http://en.wikipedia.org/wiki/JVM">JVM</a>. It&#8217;s a very cleanly designed <a href="http://en.wikipedia.org/wiki/Lisp_(programming_language)">Lisp</a> dialect and has all the features that any useful programming language would require. You can learn more about Clojure on the official website, <a href="http://en.wikibooks.org/wiki/Clojure_Programming">the wikibook</a>, <a href="http://java.ociweb.com/mark/clojure/article.html">a comprehensive article by R. Mark Volkmann</a> or by buying <a href="http://www.amazon.com/Programming-Clojure-Pragmatic-Programmers-Halloway/dp/1934356336/ref=sr_1_1?ie=UTF8&amp;qid=1249074313&amp;sr=8-1">the awesome book by Stuart Halloway</a>.</p>
<p>Now to setup <a href="http://en.wikipedia.org/wiki/Emacs">Emacs</a> as a Clojure IDE. If you are new to Emacs then don&#8217;t worry as we will take the easiest way to set it all up. If you are a Emacs veteran, then keep your own dotemacs and the bunch of customisations that you have done in all these years aside and follow along.</p>
<p>Installing Emacs is easy. On an <a href="http://ubuntu.com">Ubuntu</a> system, do this -</p>
<p><code>$ sudo apt-get install emacs-snapshot-gtk</code></p>
<p>That will install Emacs 23 for you. You will also need a few other things -</p>
<p><code>$ sudo apt-get install sun-java6-jdk ant git-core</code></p>
<p>You will need the JDK and <a href="http://ant.apache.org/">Ant</a> to build and run Clojure (it runs on the JVM, remember?) and <a href="http://git-scm.com/">Git</a> to fetch the Clojure an other related libraries.</p>
<p>Now to setup Emacs, we will use a brilliant set of Emacs Lisp libraries aptly named <a href="http://github.com/technomancy/emacs-starter-kit/">Emacs Starter Kit</a> (ESK). To get it, do this -</p>
<p><code>$ git clone git://github.com/technomancy/emacs-starter-kit.git ~/.emacs.d</code></p>
<p>That will get the ESK and will put it in your <code>~/.emacs.d</code> (existing Emacs users, please move your <code>~/.emacs</code> and <code>~/.emacs.d</code> to some other location before doing this. You can get back your old settings later).</p>
<p>What ESK does is that it provides a bunch of sane defaults for pretty much everything in Emacs. You can safely use it and get a very usable Emacs setup almost immediately.</p>
<p>You can now launch Emacs by going to <code>Applications &gt; Accessories</code> and selecting Emacs Snapshot Gtk. Once Emacs has started up, install the Emacs Clojure libraries by typing <code>M-x package-list-packages</code>. That will start up a buffer with a bunch of Emacs packages. Go to the line that says <code>clojure-mode</code> in it and press <code>i</code>. Then press <code>x</code> to install the package. Once that&#8217;s done you are ready to install Clojure. Now type <code>M-x clojure-install</code> and it will prompt you for a directory to install Clojure. Just press Enter for now and let it proceed. You can always change these things later.</p>
<p>That will fetch the Clojure runtime and also a few other useful libraries like <code>clojure-contrib</code> and will install them inside <code>~/src</code>.</p>
<p>Once that is done, you can type <code>M-x slime</code> to start Clojure inside your Emacs. Play around with it and learn the various key-bindings for <a href="http://common-lisp.net/project/slime/">Slime</a> and <a href="http://www.emacswiki.org/emacs/ParEdit">Paredit</a> which is a fantastic system for doing Lisp development. Paredit is so good that it makes all those parentheses just vanish in thin air. But yes, it takes a bit getting used to which you can achieve with some practice. One tip is to type <code>C-h m</code> in Emacs to see the documentation of all the modes that are currently active. This gives a good overview of all the key-bindings and the functions bound to those keys.</p>
<p>To develop slightly more complex Clojure applications, you need to use different dependencies with your own code. Since Java has its own <a href="http://en.wikipedia.org/wiki/Classpath">classpath</a> related quirkiness it can become a slightly complicated task. But then, there is cool function in Emacs Starter Kit called <code>clojure-project</code> which will make your life easy.</p>
<p>To use it all you need to do is to follow this simple directory structure and the rest will be taken care of automagically. The directory structure should be like this -<br />
<code><br />
myproject<br />
|-- lib<br />
|-- src<br />
|-- target<br />
|   |-- classes<br />
|   `-- dependency<br />
`-- test<br />
</code></p>
<p>Copy the Clojure &amp; Clojure Contrib (or any other dependency) JAR files into <code>lib</code> (you also alternately use a build system like <a href="http://maven.apache.org/">Maven</a> to manage dependencies for you in which case you should consider configuring the build system to copy the dependencies into <code>target/dependency</code>). Keep all your code inside <code>src</code> and tests inside <code>test</code>. The <code>src</code> and <code>test</code> directories should contain namespaces like <code>foo.bar</code> &amp; <code>foo.bar.test</code> respectively (you can later use <code>clojure-test-mode</code> to automatically pick up the tests and run them quickly). So when you run <code>M-x clojure-project</code>, it will ask you for a directory name. Give it the name of the project directory and boom! Emacs will launch Slime with the right classpath settings.</p>
<p>If you want to customise any Emacs setting, just create a file with your current system login id called <code>&lt;username.el&gt;</code> inside <code>~/.emacs.d</code> and it will be automatically loaded when you restart Emacs. If you use additional libraries, create a directory with your username inside the same directory and everything inside will be in the Emacs load-path. Nifty, right?</p>
<p>So that&#8217;s all required to setup Emacs for Clojure. Join the Clojure <a href="http://groups.google.com/group/clojure">mailing list</a> to communicate with the Clojure community. Do check the Emacs <a href="http://emacswiki.org">Wiki</a> in case you have any queries about Emacs.</p>
<p>Above all, have fun. That&#8217;s what we are here for.</p>
<p>By the way, I am <a href="http://twitter.com/ghoseb">@ghoseb</a> on Twitter and I think <a href="http://twitter.com/ghoseb">you should follow me</a> <img src='http://freegeek.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>UPDATE: Fixed a factual inconsistency regarding the paths used for <code>clojure-project</code>. Thanks to <a href="http://technomancy.us/">Phil</a> (the creator of ESK &amp; <code>clojure-project</code>) for pointing this out!</p>
]]></content:encoded>
			<wfw:commentRss>http://freegeek.in/blog/2009/08/setting-up-emacs-clojure-with-emacs-starter-kit/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.353 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2011-12-30 10:57:57 -->

