A little experiment into how Clojure with inferred paren might look like
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src Readded file that seems to be needed :P Aug 15, 2014
test oops Aug 15, 2014
.gitignore IT'S ALIVE! Aug 15, 2014
.travis.yml travis build Aug 15, 2014
project.clj Bump version Aug 15, 2014



Build Status

This is an experiment into Clojure with inferred parenthesis. Files with the extension .indent-clj/.indent-cljs/.indent-cljx are rewritten into normal clojure by adding the inferred parenthesis. Since this is done as a leiningen plugin the rewriting should be fairly transparent so you can work in the indent-clj files only and still compile and test normally. The goal isn't to replace parenthesis, just read/write less of them, more specifically to stop making your brain ignore those that end up at the end of forms as "))))))))))" :P

The parser is super simple so there are going to be some cases that it can't handle, like comments on the line after where the end paren is supposed to go.


defn expand-path-once [state path]
  let [index-of-star (s/index-of path STAR)]
    if (= index-of-star -1)
      let [[path-base path-rest] (split-at-exclusive index-of-star path)]
        if (map? (get-in state path-base))
          let [ks (keys (get-in state path-base))]
            for [k ks]
              (into (into path-base [k]) path-rest)

is expanded into:

(defn expand-path-once [state path]
  (let [index-of-star (s/index-of path STAR)]
    (if (= index-of-star -1)
      (let [[path-base path-rest] (split-at-exclusive index-of-star path)]
        (if (map? (get-in state path-base))
          (let [ks (keys (get-in state path-base))]
            (for [k ks]
              (into (into path-base [k]) path-rest)))



Clojars Project

into the :plugins vector of your project.clj, and then leiningen will support indent-clj files.


Copyright © 2014 Anders Hovmöller

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.