rewrite-clj 2021-09-24

ah totally missed that 🙂

No problemo @yogthos, it is getting to be a rather lengthy doc. Lemme know if you happen to find anything confusing in docs and I’ll try to make things clearer.

awesome thanks, I’ll mention if I run into anything I can’t figure out

a few more examples of doing different transforms could be handy, for example I needed to inject new require statements, and this is what I settled on

(defn append-requires [zloc requires ctx]
  (let [zloc-ns         (z/find-value zloc z/next 'ns)
        zloc-require    (z/up (z/find-value zloc-ns z/next :require))
        updated-require (reduce
                          (fn [zloc child]
                            ;;TODO formatting
                            (if (require-exists? (z/sexpr zloc) child)
                              zloc
                              (z/append-child zloc child)))
                          zloc-require
                          requires)]
    (loop [z-loc updated-require]
      (if-let [parent (z/up z-loc)]
        (recur parent)
        z-loc))))

one thing I couldn’t get to work was injecting a new line for each child

Yeah that’s a good idea. Some more simple examples of usage would be helfpul.

Did the insert-newline-* zipper fns not work for you? Or was it sensible indentation you were hoping for?