Skip to content

Instantly share code, notes, and snippets.

@stuartsierra
Last active November 12, 2019 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartsierra/f2db3748424f08346474a08630720998 to your computer and use it in GitHub Desktop.
Save stuartsierra/f2db3748424f08346474a08630720998 to your computer and use it in GitHub Desktop.
Demonstration of pair-wise indentation for Clojure syntax
;; Demonstration of pair-wise indentation for Clojure syntax
(let [local-symbol-one
(expression-to-compute-symbol-one)
local-symbol-two
(expression-to-compute-symbol-two)]
(body-expressions))
(def a-map
{:com.example.application/one
"Value number one, the first of its kind."
:com.example.applicaton/two
"Value number two, how do you do?"})
(cond
(test-expression-one)
(result-expression-one)
(test-expression-two)
(result-expression-two)
(test-expression-three)
(result-expression-three)
:else
(else-result-expression))
(case test-value
:value-one
(result-expression-one)
:value-two
(result-expression-two)
:value-three
(result-expression-three)
(else-result-expression))
@rlhk
Copy link

rlhk commented Nov 12, 2019

Looks very clean.
But what about destructuring in let block? Say:

(let [[local-1 local-2]
        (expression-to-compute-symbol-one)
      local-symbol-two
        (expression-to-compute-symbol-two)]
  (body-expressions))

Parinfer will formate automatically and break it:

(let [[local-1 local-2
        (expression-to-compute-symbol-one)]
      local-symbol-two
        (expression-to-compute-symbol-two)]
  (body-expressions))

Not sure if there's any config to tune the behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment