Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zprint will directly format rewrite-clj zippers #8

Open
kkinnear opened this issue May 31, 2017 · 2 comments
Open

zprint will directly format rewrite-clj zippers #8

kkinnear opened this issue May 31, 2017 · 2 comments

Comments

@kkinnear
Copy link

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.

@mynomoto
Copy link
Collaborator

@kkinnear Thanks for this information, it will be useful. I have a project using zprint and specter-edn on the resulting string and I had no problem with incompatible rewrite-clj apis so far. I don't think there is need to rush on upgrading zprint. I will try the :zipper? true option later.
Formatting the output after the transformation will be a very nice feature to have.

@mynomoto
Copy link
Collaborator

@kkinnear actually, ignore the part about zprint and specter-edn working on the same project, that was my mistake and the rewrite-clj from zprint was shadowing the one from specter-edn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants