Skip to content

Commit a14a653

Browse files
committed
Tweak the new pprint functions to have single-arity version
Originally I didn't notice that other middlewares were making use of the same functions.
1 parent b1a6e11 commit a14a653

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/cider/nrepl/middleware/format.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
(defn- format-edn
4646
[edn pprint-fn]
4747
(->> (read-edn edn)
48-
(map #(with-out-str (pprint-fn %)))
48+
(map #(pprint-fn %))
4949
str/join
5050
str/trim))
5151

src/cider/nrepl/middleware/stacktrace.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
of pretty printed problems. The content of the returned map is modeled after
250250
`clojure.spec/explain-printer`."
251251
[ed pprint-fn]
252-
(let [pp-str #(with-out-str (pprint-fn %))
252+
(let [pp-str #(pprint-fn %)
253253
problems (sort-by #(count (:path %))
254254
(or (:clojure.spec/problems ed)
255255
(:clojure.spec.alpha/problems ed)))]

src/cider/nrepl/pprint.clj

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Pretty-print related utilities.
33
All functions here are simple wrappers that ensure a consistent API:
44
5-
* two params - object to print and a map of print options
5+
* has one and two params signatures - object to print and a map of print options
66
* the keys of the print options map can be strings, as bencode clients can't send keywords
77
* functions return the printed object as a string"
88
{:added "0.20.0"}
@@ -14,25 +14,33 @@
1414
"A simple wrapper around `clojure.pprint/write`.
1515
It provides an API compatible with what nREPL's
1616
pr-values middleware expects for printer functions."
17-
[object opts]
18-
(let [opts (assoc (walk/keywordize-keys opts) :stream nil)]
19-
(apply pp/write object (vec (flatten (vec opts))))))
17+
([object]
18+
(pprint object {}))
19+
([object opts]
20+
(let [opts (assoc (walk/keywordize-keys opts) :stream nil)]
21+
(apply pp/write object (vec (flatten (vec opts)))))))
2022

2123
(def ^:private fipp-printer
2224
(delay
2325
(do
2426
(require 'fipp.edn)
2527
(resolve 'fipp.edn/pprint))))
2628

27-
(defn fipp-pprint [object opts]
28-
(with-out-str
29-
(@fipp-printer object (walk/keywordize-keys opts))))
29+
(defn fipp-pprint
30+
([object]
31+
(fipp-pprint object {}))
32+
([object opts]
33+
(with-out-str
34+
(@fipp-printer object (walk/keywordize-keys opts)))))
3035

3136
(def ^:private puget-printer
3237
(delay
3338
(do
3439
(require 'puget.printer)
3540
(resolve 'puget.printer/pprint-str))))
3641

37-
(defn puget-pprint [object opts]
38-
(@puget-printer object (walk/keywordize-keys opts)))
42+
(defn puget-pprint
43+
([object]
44+
(puget-pprint object {}))
45+
([object opts]
46+
(@puget-printer object (walk/keywordize-keys opts))))

0 commit comments

Comments
 (0)