rewrite-clj

yogthos 2021-09-24T17:42:51.020600Z

ah totally missed that 🙂

lread 2021-09-24T20:42:59.021900Z

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.

yogthos 2021-09-24T20:43:43.022400Z

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

yogthos 2021-09-24T20:47:03.023500Z

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))))

yogthos 2021-09-24T20:47:38.024100Z

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

lread 2021-09-24T20:56:12.025Z

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

lread 2021-09-24T20:59:09.025900Z

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