rewrite-clj

2025-05-14T20:57:28.182779Z

i have a zipper and a bunch of locations. i can step between the locations, but if i modify the code at a given location, the later locations now point to the incorrect spot (because the later positions are updated). i'd like to be able to modify the code at each location without losing the later positions. is there an easy way to do what i want?

borkdude 2025-05-14T21:03:45.467289Z

this is the difference between location tracking and not tracking I believe?

2025-05-14T21:04:33.386549Z

oh dang, i completely misunderstood that option. i thought without it, there'd be no location data at all. facepalm

❤️ 1
2025-05-14T21:06:22.882019Z

hmm jk, i can't use z/find-last-by-pos without it

lread 2025-05-14T21:12:47.927499Z

yep https://github.com/clj-commons/rewrite-clj/issues/285

2025-05-14T21:14:23.949789Z

oh perfect, thank you

👍 1
borkdude 2025-05-14T21:14:40.920869Z

another idea: attach also the old location on the node under a different key :P

2025-05-14T21:16:02.075909Z

yeah i could walk the whole zloc and annotate the locations and then walk it a second time to perform the updates, but @lee's quick fix looks like it'll work great

🎉 1
2025-05-15T21:28:08.803129Z

the suggested function in that issue works great, thank you

🎉 2