File tree Expand file tree Collapse file tree 3 files changed +9
-16
lines changed
Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Original file line number Diff line number Diff line change 8282(def wrap-pprint-fn-optional-arguments
8383 " Common pprint arguments for CIDER's middleware."
8484 {" pprint-fn" " The namespace-qualified name of a 1 or 2-arity function to use for pretty-printing. Defaults to `cider.nrepl.pprint/pprint`."
85- " print-params " " A map of configuration entries that the pprint-fn will understand. Those would typically be specific to the pprint-fn in question." })
85+ " print-options " " A map of configuration entries that the pprint-fn will understand. Those would typically be specific to the pprint-fn in question." })
8686
8787(def-wrapper wrap-pprint-fn cider.nrepl.middleware.pprint /handle-pprint-fn
8888 (fn [msg] true )
9494 `cider.nrepl.pprint/pprint`. The function name can be passed as
9595 a string or symbol. Note that function should take 1 or two params - the
9696 object to print and the an optional map of print params. The params should
97- be passed as `:print-params` - a map of key/value params. If they were passed
98- by the client as with string keys, this middleware will convert the keys to
99- keywords.
97+ be passed as `:print-options` - a map of key/value params.
10098
10199 The `:pprint-fn` slot will be replaced with the var that maps to the name
102100 that was initially passed.
103101
104102 Middlewares further down the stack can then look up the `:pprint-fn`
105- slot, call it where necessary, and pass it the value of the `:print-params ` slot."
103+ slot, call it where necessary, and pass it the value of the `:print-options ` slot."
106104 :requires #{#'session}
107105 :expects #{" eval" " load-file" }})
108106
Original file line number Diff line number Diff line change 22 (:require
33 [cider.nrepl.middleware.util.cljs :as cljs]
44 cider.nrepl.pprint
5- [clojure.walk :as walk]
65 [nrepl.middleware.interruptible-eval :refer [*msg*]]
76 [nrepl.middleware.pr-values :refer [pr-values]]
87 [nrepl.middleware.session :as session]
2625
2726(defn handle-pprint-fn
2827 [handler msg]
29- (let [{:keys [pprint-fn print-options session ]
28+ (let [{:keys [pprint-fn]
3029 :or {pprint-fn 'cider.nrepl.pprint/pprint}}
3130 msg]
32- (handler (assoc msg
33- :pprint-fn (resolve-pprint-fn pprint-fn)
34- :print-options (walk/keywordize-keys print-options)))))
31+ (handler (assoc msg :pprint-fn (resolve-pprint-fn pprint-fn)))))
Original file line number Diff line number Diff line change 33 All functions here are simple wrappers that ensure a consistent API:
44
55 * has one and two params signatures - object to print and a map of print options
6- * the keys of the print options map can be strings, as bencode clients can't send keywords
76 * functions return the printed object as a string"
87 {:added " 0.20.0" }
98 (:require
10- [clojure.pprint :as pp]
11- [clojure.walk :as walk]))
9+ [clojure.pprint :as pp]))
1210
1311(defn pprint
1412 " A simple wrapper around `clojure.pprint/write`.
1715 ([object]
1816 (pprint object {}))
1917 ([object opts]
20- (let [opts (assoc ( walk/keywordize-keys opts) :stream nil )]
18+ (let [opts (assoc opts :stream nil )]
2119 (apply pp/write object (vec (flatten (vec opts)))))))
2220
2321(def ^:private fipp-printer
3129 (fipp-pprint object {}))
3230 ([object opts]
3331 (with-out-str
34- (@fipp-printer object ( walk/keywordize-keys opts) ))))
32+ (@fipp-printer object opts))))
3533
3634(def ^:private puget-printer
3735 (delay
4341 ([object]
4442 (puget-pprint object {}))
4543 ([object opts]
46- (@puget-printer object ( walk/keywordize-keys opts) )))
44+ (@puget-printer object opts)))
You can’t perform that action at this time.
0 commit comments