rewrite-clj

Joel 2025-06-05T16:21:44.002029Z

I’m running into an issue when my search/replace is “recursive”, eg

(some-fun (some-fun "Fred" :remove) :remove)
=> (other (other "Fred"))  ; what I want
I find the positions with grasp, I have :track-position? false, I’m using subedit-> (doesn’t seem to differ with or w/o) and using z/next / (meta (z/node zloc)) to match position and navigate to the next spot. This works flawless until I encounter this situation. Seems finding the inner occurrence returns null for its zloc… but since I have track-position off, I’d think it would still work?

lread 2025-06-05T17:57:58.814259Z

Hi @joel380, I need more info, I think. I don't yet see how position tracking zipper (vs non-position tracking zipper) or subediting come into play for your problem. To help me help you, please provide a complete minimal example (something I can run in my REPL) of what is working/not-working.

1
Joel 2025-06-05T18:47:17.148179Z

I’ll have to minimize the code to reproduce --- that might illicit the problem. But a little more info… With Grasp I get the positions of the first two open parends

(some-fun (some-fun "Fred" :remove) :remove)
^         ^
I’m doing a z/replace on the first position, using z/next to get to the second position, so obviously I need track-position off as the second parend changes location… right?

lread 2025-06-05T19:28:22.959989Z

So... I'm not sure how familiar you are with rewrite-clj and how it works. But... a position tracking zipper is only needed if you need to preserve/use the row offset and column offset of a node.