Skip to content
Magnar Sveen edited this page Apr 3, 2015 · 1 revision

el Expand let

Find the closest let and move it up one level in the syntax tree.

Given I have my cursor at find-body here:

(defn handle-request
  {:status 200
   :body (let [body (find-body abc)]
           body)})

I do cljr-expand-let, and the let form is moved up:

(defn handle-request
  (let [body (find-body abc)]
    {:status 200
     :body body}))

It also replaces identical entries in the newly embraced body:

(defn create-entity
  {:created-at (let [date (Date.)]
                 date)
   :updated-at (Date.)})

turns into:

(defn create-entity
  (let [date (Date.)]
    {:created-at date
     :updated-at date}))