Fork me on GitHub

Heya folks! I’m continuing to think about custom skip support for the rewrite-clj zipper. I’m thinking a :skip-pred option at zipper creation time as suggested-ish in . As those in the know know, the current skip behaviour is hardcoded to skip Clojure whitespace and comments. The :skip-pred will allow folks to skip whatever nodes they like. For example to skip all nodes that are not sexpr-able a :skip-pred might be set to:

#(z/find % z/up* (complement z/sexpr-able?))
This says, I’m not interested in seeing nodes where the node or any of its parents are not sexpr-able. This seems good to me, but am always happy to hear feedback. Things get a little interesting if :skip-pred is very restrictive and makes me wonder what moving up and down might mean. For example, if I want to skip everything but comments, there is no down on a comment, so fine, but up? I suppose it would always navigate to the zipper root node? Or if we skip everything but a container node, let’s say a set, we would see all sets, but unless a set contained a set we would not otherwise see its children through navigation. If set1 contains a vector that contains set2, it seems to me that an up on set2 would bring me to set1. Would a down on set1 bring me to set2? I’m not sure yet, but these are the kinds of questions that are coming to mind.