feat: Honor *print-namespace-maps* in pprint (#1387)

We can now use the dynamic var `*print-namespace-maps*` to control how
maps with namespaced keys are printed using `pprint`.

Fixes: #1381
This commit is contained in:
Baishampayan Ghose 2022-10-04 22:41:59 +05:30 committed by GitHub
parent 9fba927ec8
commit 77768cec67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View file

@ -8,6 +8,7 @@ A preview of the next release can be installed from
## Unreleased
- Add single argument read method support to PipedInputStream proxy ([@retrogradeorbit](https://github.com/retrogradeorbit))
- feat: Honor `*print-namespace-maps*` in pprint ([@ghoseb](https://github.com/ghoseb))
## 0.10.163 (2022-09-24)

View file

@ -97,7 +97,8 @@
pprint/*print-miser-width* @print-miser-width
*print-meta* @sci/print-meta
*print-readably* @sci/print-readably
*print-length* @sci/print-length]
*print-length* @sci/print-length
*print-namespace-maps* @sci/print-namespace-maps]
(pprint/pprint s writer))))
(defn cl-format

View file

@ -10,3 +10,13 @@
(deftest print-length-test
(is (= "(0 1 2 3 4 5 6 7 8 9 ...)"
(bb "-e" "(set! *print-length* 10) (clojure.pprint/pprint (range 20))"))))
(deftest print-namespaced-map-test
(test/testing
"Testing disabling of printing namespace maps..."
(is (= "{:a/x 1, :a/y 2, :a/z {:b/x 10, :b/y 20}}"
(bb "-e" "(binding [*print-namespace-maps* false] (clojure.pprint/pprint {:a/x 1 :a/y 2 :a/z {:b/x 10 :b/y 20}}))"))))
(test/testing
"Testing manually enabling printing namespace maps..."
(is (= "#:a{:x 1, :y 2, :z #:b{:x 10, :y 20}}"
(bb "-e" "(binding [*print-namespace-maps* true] (clojure.pprint/pprint {:a/x 1 :a/y 2 :a/z {:b/x 10 :b/y 20}}))")))))