Welcome! Please see the About page for a little more info on how this works.

+3 votes
in Printing by
closed by
Short example illustrating the behavior:

user=> *clojure-version*
{:major 1, :minor 6, :incremental 0, :qualifier nil}

user=> (def f1 '(defn foo [^Integer x] ^{:bar 8} (inc x)))
#'user/f1

;; pr shows all metadata, as expected

user=> (binding [*print-meta* true] (pr f1))
^{:line 2, :column 10} (defn foo [^Integer x] ^{:bar 8, :line 2, :column 33} (inc x))nil

;; pprint shows some metadata, but not all

user=> (binding [*print-meta* true] (clojure.pprint/pprint f1))
(defn foo [^Integer x] (inc x))
nil


I have not dug into the details yet, but it appears that this may be because pprint uses pr to show symbols, but not to show collections.  Thus pprint shows metadata on symbols, but not collections.

It would be nice if pprint could instead show all metadata, as pr does, when *print-meta* is bound to true.
closed with the note: Fixed in 1.10.2-rc1

3 Answers

0 votes
by

Comment made by: jafingerhut

Attached file clj-1445-workaround-v1.clj is a function that pprints with more metadata than clojure.pprint does. As noted in the comments, it may not show metadata on other metadata. Please update with an enhanced version if you create one.

0 votes
by

Comment made by: jafingerhut

Attached file clj-1445-workaround-v2.clj supersedes the earlier one, which I will delete.

The included function pprint-meta appears to be a correct way to pprint values with all metadata, even if the metadata maps themselves have metadata on them.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1445 (reported by jafingerhut)
...