|
81 | 81 |
|
82 | 82 | (def wrap-pprint-fn-optional-arguments
|
83 | 83 | "Common pprint arguments for CIDER's middleware."
|
84 |
| - {"pprint-fn" "The namespace-qualified name of a single-arity function to use for pretty-printing. Defaults to `clojure.pprint/pprint`." |
85 |
| - "print-length" "Value to bind to `*print-length*` when pretty-printing. Defaults to the value bound in the current REPL session." |
86 |
| - "print-level" "Value to bind to `*print-level*` when pretty-printing. Defaults to the value bound in the current REPL session." |
87 |
| - "print-meta" "Value to bind to `*print-meta*` when pretty-printing. Defaults to the value bound in the current REPL session." |
88 |
| - "print-right-margin" "Value to bind to `clojure.pprint/*print-right-margin*` when pretty-printing. Defaults to the value bound in the current REPL session."}) |
| 84 | + {"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."}) |
89 | 86 |
|
90 | 87 | (def-wrapper wrap-pprint-fn cider.nrepl.middleware.pprint/handle-pprint-fn
|
91 | 88 | (fn [msg] true)
|
|
94 | 91 |
|
95 | 92 | A namespace-qualified name of the function to be used for printing can
|
96 | 93 | be optionally passed in the `:pprint-fn` slot, the default value being
|
97 |
| - `clojure.pprint/pprint`. |
| 94 | + `cider.nrepl.pprint/pprint`. The function name can be passed as |
| 95 | + a string or symbol. Note that function should take 1 or two params - the |
| 96 | + 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. |
98 | 100 |
|
99 |
| - The `:pprint-fn` slot will be replaced with a closure that calls the |
100 |
| - given printing function with `*print-length*`, `*print-level*`, |
101 |
| - `*print-meta*`, and `clojure.pprint/*print-right-margin*` bound to the |
102 |
| - values of the `:print-length`, `:print-level`, `:print-meta`, and |
103 |
| - `:print-right-margin` slots respectively. |
| 101 | + The `:pprint-fn` slot will be replaced with the var that maps to the name |
| 102 | + that was initially passed. |
104 | 103 |
|
105 | 104 | Middlewares further down the stack can then look up the `:pprint-fn`
|
106 |
| - slot and call it where necessary." |
| 105 | + slot, call it where necessary, and pass it the value of the `:print-params` slot." |
107 | 106 | :requires #{#'session}
|
108 | 107 | :expects #{"eval" "load-file"}})
|
109 | 108 |
|
|
0 commit comments