Skip to content

zprint will directly format rewrite-clj zippers #8

@kkinnear

Description

@kkinnear

This isn't a "issue", just an FYI. I'm not quite sure what specter-edn is used for, but I see that you are using rewrite-clj, and in the readme you are talking about formatting things. I expect that some of the contributors know about zprint since I recognize their names, but they (and you) might not know that the zprint library will directly format the zippers that rewrite-clj outputs. That is how it formats Clojure(script) code -- it uses rewrite-clj to parse the source, and then runs the formatting engine on the resulting zipper structure. There is a (currently hidden) option which will allow you to access this capability directly. I would be more than happy to make it a visible part of the zprint API if you wanted to use it. I didn't bother (so far) because I didn't think anyone would care. Which may well still be the case, but I thought I'd at least let you all know about it.

The option is {:zipper? true}. So, if you have something that is a rewrite-clj zipper which is the value of x, then this will format it to a string:

(zprint-str x {:zipper? true}

The entire zprint API will accept the :zipper? true key-value pair in the options map.

One possible problem is that zprint is using an old-ish version of rewrite-clj, and so there might be some incompatibility with the parsing output (or even the zipper implementation). If you are interested in using zprint, and you encounter problems because of the rewrite-clj version mismatch, I would be willing to move zprint to a more recent rewrite-clj (which is on my list of things to do anyway, but I would work on it sooner rather than later if it mattered to you).

Anyway, I thought that this might possibly be interesting to you, but if not, no problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions