rewrite-clj 2020-10-20

thank you, i'm trying that out now

that got me on the right path, thank you

my next issue is trying to create a new map node and then insert values into it from the surrounding node

i have maps that have a :choices key that is sometimes a list or vector, and I'd like to wrap it in a map. from :choices existing-list to something like :choices {:buttons existing-list}

(n/map-node) seems to work to create the node, but then I can't use z/assoc to insert key value pairs

throws an "rewrite_clj.node.seq.SeqNode cannot be cast to clojure.lang.IFn" error

@nbtheduke Sometimes I find it easier to just use the raw nodes instead of zippers, so I grab the :children and manually rewrite them and assoc them back in

huh, okay. i'll see if i can figure out how to do that. thanks

@nbtheduke This is the primary approach when writing clj-kondo hooks: https://github.com/borkdude/clj-kondo/blob/master/doc/hooks.md

Thanks btw, I didn't know about z/assoc

ha there isn't a lot of documentation, so i've just been poring over the generated docs and trying things out. my code looks wack, so this is all great info

@nbtheduke if it helps, here's also a lib I made for rewriting config files: https://github.com/borkdude/rewrite-edn

it's still pretty young and maybe incomplete

but it should make things easier than working directly with rewrite-clj if you only need to assoc or update-in etc

nice! did you implement maintaining whitespace as well? your examples look like it

yeah, it uses rewrite-clj under the hood