The documentation of cl-format claims that it is fully compatible with the CL version of format. However, in CL the ~A directive (print aesthetically) pretty-prints the corresponding argument. For example (format out "~A" some-list) outputs the same as (pprint some-list out) However, in clojure (cl-format out "~A" some-list) outputs the contents of some-list all on a single line.
Does anyone know whether it is possible to make this work correctly? I've seen the dynamic variable print-pretty which seems to have no effect on ~A.
After a bit of searching, I've found what I think is the culprit. According to line 1338 of cl_format.clj it seems ~A dispatches unconditionally to print-str rather than to some form of pprint-to-str. I suspect that is a bug, because I don't see any comment there explaining how the pretty-printer is intended to be triggered here.
It seems like it should use something like (fn [data] (with-out-str (pprint data)) rather than print-str.