Metaphysical Developer

Idiomatic Clojure with LightTable

Posted in Clojure, Software Development by Daniel Ribeiro on November 18, 2013

LightTable, the famous innovative IDE (slash reactive work surface, as described by the author) recently got some pretty amazing additions: user defined plugins and user defined custom expressions.

Custom expressions allow users to define functions that get any block of text and replace with the result, stream information back to LightTable, or display the result inline:

image

The clojure project Kibit immediately came to mind when I saw the new addition. Kibit is a static code analyzer for Clojure that allows you to find a more idiomatic way of writing a given block of text.

So I wrote this short LightTable integration for it. With it, LightTable can replace any s-expression with its more idiomatic version. For instance, this code:

Screen Shot 2013-11-17 at 5.53.01 PM

becomes:

Screen Shot 2013-11-17 at 5.53.21 PM

To see how Kibit did, here is the before and after shots of the expression broken down in its components:

s0

After:

s1

In order to use Kibit with LightTable, you just need to:

1. add lein-kibit it to your project.clj:

Screen Shot 2013-11-17 at 5.56.49 PM

2. add the integration function to your usermap:

Screen Shot 2013-11-18 at 10.54.40 PM

The sample project can be found on GitHub.

About these ads
Tagged with: ,

3 Responses

Subscribe to comments with RSS.

  1. Foo Bar said, on November 18, 2013 at 6:50 pm

    c’est beau comme du emacs-lisp, bravo mister

    • Daniel Ribeiro said, on November 18, 2013 at 6:59 pm

      Merci :)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: