Configure symbol quote expansion in clojure zprint

Viewed 80

Is there a way to avoid having zprint write 'my-symbol as (quote my-symbol)? I am aware it is the reader that converts it to that form. However I would expect zprint to be configurable to produce the more idiomatic format which is the default for clojure.pprint.

(require '[zprint.core :as zp])
(zp/zprint '(def foo 'my-symbol))
;; (def foo (quote my-symbol))


(require '[clojure.pprint :as pp])
(pp/pprint '(def foo 'my-symbol))
;; (def foo 'my-symbol)
1 Answers

See related issue: https://github.com/kkinnear/zprint/issues/121

Following bfabry's comment, as a workaround, we can use pprint to create the nicely quoted string, and then pass it through zprint for formatting:

(require '[zprint.core :as zp])
(require '[clojure.pprint :as pp])

(-> '(def foo 'my-symbol)
    pp/pprint
    with-out-str 
    (zp/zprint 40 {:parse-string? true}))
(def foo 'my-symbol)
nil
Related