rewrite-clj

https://github.com/clj-commons/rewrite-clj
witek 2019-12-16T10:54:51.004300Z

Hello. I am new to rewrite-clj and I have never used zippers before. I have loaded a clojure file with z/of-file and I would like to extract a list of all symbols used in that file. Is a recursion with z/next the right way to do it?

borkdude 2019-12-16T11:01:00.004800Z

@witek There is a very good talk by @plexus on the subject of zippers. I recommend watching it first

❤️ 1
borkdude 2019-12-16T11:01:30.005400Z

Also note that you don't necessarily need to use the zipper stuff. In clj-kondo I work with the raw nodes and don't touch the zippers at all.

borkdude 2019-12-16T11:06:52.005800Z

but tl;dr, I think z/next is indeed the thing you want

2019-12-16T14:57:38.008700Z

@witek i have written a simple external tool (graal native-image binary) that uses rewrite-clj* to modify clj* source. it is more a proof of concept than anything, but the repository also contains integration code for emacs, vscode, and atom. if you're interested in taking a look, it's at: https://github.com/sogaiu/adorn

❤️ 1
lread 2019-12-16T21:13:47.010400Z

@witek let us know how it goes. The @plexus video that @borkdude refers to is this one: https://lambdaisland.com/blog/2018-11-26-art-tree-shaping-clojure-zip

witek 2019-12-16T22:03:30.011700Z

@borkdude I went for zippers because I want to change symbols and write them back.