Fork me on GitHub
#rewrite-clj
<
2022-02-24
>
jacob.maine00:02:08

The zipper movement helpers don’t treat “uneval” nodes (rewrite-clj’s term for #_) as whitespace or comments. So, when navigating a zipper with “whitespace aware” helpers like z/right and z/next, you’ll make stops on uneval nodes. This surprised me and means a bunch of my code mishandles code with unevals in it. Are there any options besides creating my own version of rewrite-clj.node.extras/whitespace-or-comment? and duplicating everything that references it (directly or indirectly)? I’m OK with doing that, I just want to make sure it’s my best bet.

lread14:02:19

Hi @jacob.maine thanks for the question! This is a relatively common complaint/request of rewrite-clj. There https://github.com/clj-commons/rewrite-clj/issues/70. I did take a crack at a generalized solution some time ago but found it more nuanced than I expected so have let it sit for now.

jacob.maine18:02:17

@lee, thanks for the link! That adds a lot of background. Do you recall the nuances of the generalized solution? Am I likely to run into anything in particular while creating my own versions of the movement functions? Or was the trouble more around fitting node skipping config into the general architecture of zipper construction? If you have more context, perhaps you could update the issue.

lread19:02:10

Hmmm… thanks @jacob.maine I thought I had added some notes on my attempt to that issue but it looks like I have not yet. I think you should be fine. The generalized solution was to skip nodes based on a user provided predicate. If I remember correctly, I was looking into what to do if all nodes ended up being skipped (and how that fits in with current implementation/behaviour), and how to handle a movement if the currently located inside a node that the predicate would skip. I’ll dig up my old notes and update the issue.

jacob.maine19:02:25

@lee thanks! Very helpful 🙏

👍 1