Skip to content

Commit 06a62f3

Browse files
committed
Add cider-print-quota option
1 parent 5dceb74 commit 06a62f3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cider-client.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ able to handle those. Here's an example for `pprint':
246246
(defun cider--pprint-fn ()
247247
"Return the value to send in the pprint-fn slot of messages."
248248
(pcase cider-pprint-fn
249+
(defcustom cider-print-quota (* 1024 1024)
250+
"A hard limit on the number of bytes to return from any printing operation.
251+
Set to nil for no limit."
252+
:type 'integer
253+
:group 'cider
254+
:package-version '(cider . "0.21.0"))
255+
249256
(`pprint "cider.nrepl.pprint/pprint")
250257
(`fipp "cider.nrepl.pprint/fipp-pprint")
251258
(`puget "cider.nrepl.pprint/puget-pprint")
@@ -283,6 +290,8 @@ result, and is included in the request if non-nil."
283290
(setq print-options (nrepl-dict-put print-options (cider--pprint-option "right-margin" cider-pprint-fn) right-margin)))
284291
(append `("nrepl.middleware.print/print" ,(or pprint-fn (cider--pprint-fn))
285292
"nrepl.middleware.print/stream?" "1")
293+
(when cider-print-quota
294+
`("nrepl.middleware.print/quota" ,cider-print-quota))
286295
(and (not (nrepl-dict-empty-p print-options)) `("nrepl.middleware.print/options" ,print-options)))))
287296

288297
(defun cider--nrepl-content-type-plist ()

nrepl-client.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,10 @@ the corresponding type of response."
787787
(when stderr-handler
788788
(funcall stderr-handler buffer err)))
789789
(status
790+
(when (and stderr-handler (member "nrepl.middleware.print/truncated" status))
791+
(let ((warning (format "\n... output truncated to %sB ..."
792+
(file-size-human-readable cider-print-quota))))
793+
(funcall stderr-handler buffer warning)))
790794
(when (member "notification" status)
791795
(nrepl-dbind-response response (msg type)
792796
(nrepl-notify msg type)))

0 commit comments

Comments
 (0)