Try something like this:
(require '[clojure.pprint :as pprint])
(defn print-code [o]
(binding [pprint/*print-right-margin* 100
pprint/*print-miser-width* 60]
(pprint/with-pprint-dispatch pprint/code-dispatch
(pprint/pprint o))))
Or one of the "pretty printer" libraries like fipp or zprint.
On Sunday, October 23, 2016 at 6:28:23 AM UTC-5, Jiyin Yiyong wrote:
>
> I'm using `write` function to generate code very heavily. But small part
> of the code are hard to read.
> So I digged into the options and increased `right-margin` to make it a
> little better. Here's the changes:
>
>
> https://github.com/Cirru/sepal.clj/commit/e65e2d3cac8a5c5537716acd12cc475712ab6f66
>
>
> https://github.com/Quamolit/quamolit/commit/1d2e2a579a3b6741109223faa88c84157035577f
>
> But it turned out the algorithm is doing layout like always appending code
> in a line, until it reaches right margin.
> So if `right-margin` is too big, all the code are in a single line, which
> is hard to read.
> if `right-margin` is too small, then all the code in a column, which is
> also hard to read.
> I think it's not smart enough to make all of my code readable enough, but
> majority of that is fine.
>
> Is there any solution to improvement the readability at this moment?
> Especially for such scenarios:
>
>
> https://github.com/Quamolit/quamolit/blob/master/src/quamolit/render/expand.cljs#L102
>
>
> Thanks.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.