@@ -213,9 +213,15 @@ two arguments - an object to print and an options map. The options map will
213
213
have string keys. If the function
214
214
cannot be resolved, an exception will be thrown.
215
215
216
- The function is assumed to respect the contract of \\= `clojure.pprint/pprint\\= `
217
- with respect to the bound values of \\= `*print-length*\\= `, \\= `*print-level*\\= `,
218
- \\= `*print-meta*\\= `, and \\= `clojure.pprint/*print-right-margin*\\= `."
216
+ The function should ideally have a two-arity variant that accepts the
217
+ object to print and a map of configuration options for the printer. See
218
+ `cider-pprint-options' for details.
219
+
220
+ The function is also assumed to respect the contract of
221
+ \\= `clojure.pprint/pprint\\= ` with respect to the bound values of
222
+ \\= `*print-length*\\= `, \\= `*print-level*\\= `, \\= `*print-meta*\\= `, and
223
+ \\= `clojure.pprint/*print-right-margin*\\= `. Those would normally serve as
224
+ fallback values when a map of print options is not supplied explicitly."
219
225
:type '(choice (const pprint)
220
226
(const fipp)
221
227
(const puget)
@@ -246,11 +252,13 @@ able to handle those. Here's an example for `pprint':
246
252
PPRINT-FN is the name of the Clojure function to use.
247
253
RIGHT-MARGIN specifies the maximum column-width of the pretty-printed
248
254
result, and is included in the request if non-nil."
249
- (nconc `(" printer" ,(or pprint-fn (cider--pprint-fn)))
250
- (and cider-pprint-options `(" print-options" , cider-pprint-options ))
251
- ; ; TODO: figure out what to do with this margin
252
- ; ; probably it should be merged with the cider-pprint-options
253
- (and right-margin `(" print-right-margin" , right-margin ))))
255
+ (let* ((print-options (or cider-pprint-options (nrepl-dict))))
256
+ ; ; TODO: Currently this will work only for pprint. We have to add some function
257
+ ; ; to translate the option names for the various pprint backends.
258
+ (when right-margin
259
+ (setq print-options (nrepl-dict-put print-options " right-margin" right-margin)))
260
+ (nconc `(" printer" ,(or pprint-fn (cider--pprint-fn)))
261
+ (and (not (nrepl-dict-empty-p print-options)) `(" print-options" , print-options )))))
254
262
255
263
(defun cider--nrepl-content-type-plist ()
256
264
" Plist to be appended to an eval request to make it use content-types."
0 commit comments