Content tagged emacs

Clojure for the Emacs user
posted on 2014-08-17 13:46:28

One of the great things about Clojure is that it's a Lisp, and not just for the fact that this brings a lot of linguistic power over typical languages. Lisps have a very intertwined history with Emacs.

In this post I will show you what I think is the perfect environment for composing Clojure code.

First of all you will need Emacs version >=24, this ensures that you have the proper package.el support by default. If not; you will need to install package.el manually. This page is a great resource on package.el.

Now, we can install the basic clojure-mode, which will provide proper font-locking and basic code highlighting.

To install: M-x package-install RET clojure-mode RET.

Personally, I prefer a live editing environment over the archaic write/compile/test/repeat cycle that a lot of languages enforce. To this end, we need to install the exceptional CIDER mode. CIDER provides a SLIME-like environment for Clojure. CIDER is a mode which enables a powerful embedded REPL inside emacs. This embedded REPL can do code evaluation, code introspection, code-completion and much more. It's very difficult to return to languages which do not have this rich-editing experience.

To install: M-x package-install RET cider RET.

Finally, clj-refactor is a package which provides a few helpful code transformations. There are gems such as "introduce-let" which moves a form into an enclosing let form, or sort-namespace, which will alphabetically sort the namespace (great for keeping tidy code). There are many more so I suggest that you browse the repository.

To install: M-x package-install RET clj-refactor RET

Enjoy!

This blog covers amazon, browser, cider, clojure, common lisp, distributed computing, ec2, emacs, erlang, fresh, haproxy, kafka, kubernetes, lisp, new, storm, webkit, websockets, zookeeper

View content from 2017-03, 2016-02, 2015-02, 2014-08, 2014-07


Unless otherwise credited all material Creative Commons License by Aaron France