Skip to content

Clojars Release 0.3.0

Compare
Choose a tag to compare
@xsc xsc released this 07 Aug 19:18

This release adds indentation-aware zipper operations (in rewrite-clj.zip.indent), requiring the addition of the new token type :newline, as well as having the zipper root node be of type :forms. This means that projects relying on the old structure have to be revisited!

Indentation can now be propagated through branches spanning multiple lines:

(require '[rewrite-clj.zip :as z] '[rewrite-clj.zip.indent :as i])
(def code
  (z/of-string "
{:dependencies [[a \"1.0.0\"]
                [b \"0.1.1\"]
                [c \"1.2.3\"]]}"))

(-> code 
  (z/find-value z/next :dependencies) 
  (z/replace :deps)
  z/print-root)
; {:deps [[a "1.0.0"]
;                 [b "0.1.1"]
;                 [c "1.2.3"]]}

(-> code 
  (z/find-value z/next :dependencies) 
  (i/replace :deps)  ;; !!!
  z/print-root)
; {:deps [[a "1.0.0"]
;         [b "0.1.1"]
;         [c "1.2.3"]]}

Additionally, removal now handles whitespaces appropriately and there are some new functions for zipper manipulation/analysis. Click here for a detailed list of changes.