Skip to content

[docs] Update pretty-printing doc #3825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions doc/modules/ROOT/pages/usage/pretty_printing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

== Configuring a printing function

NOTE: Pretty-printing was overhauled in CIDER 0.21 to leverage new features introduced in nREPL 0.6.
Refer to https://nrepl.org/nrepl/usage/misc.html#_pretty_printing[nREPL's documentation] for details.
NOTE: CIDER relies on nREPL's own value printing mechanism. Refer to
https://nrepl.org/nrepl/usage/misc.html#pretty_printing[nREPL's documentation]
for details.

You can configure the function used by CIDER for pretty-printing evaluation
results and other data using the option `cider-print-fn`, which can take the
Expand All @@ -15,14 +16,16 @@ equivalent of `clojure.core/pr`.
* `pr` to use the equivalent of `clojure.core/pr`.
* `pprint` to use the built-in `clojure.pprint/pprint` (this is the default).
* `fipp` to use the https://github.com/brandonbloom/fipp[Fast Idiomatic
Pretty-Printer]. This is approximately
5-10x faster than `clojure.core/pprint`.
Pretty-Printer]. This is approximately 5-10x faster than `clojure.core/pprint`.
* `puget` to use https://github.com/greglook/puget[Puget], which provides
https://github.com/greglook/puget#canonical-representation[canonical serialization]
of data on top of fipp, but at a slight performance cost.
* `zprint` to use https://github.com/kkinnear/zprint[zprint], a fast and
flexible alternative to the libraries mentioned above.

For `fipp`, `puget`, and `zprint` printers to work, you need to add a
respective dependency into your project explicitly.

Alternatively, `cider-print-fn` can be set to the namespace-qualified name of a
Clojure var whose function takes three arguments: the object to print, the
`java.io.PrintWriter` to print on, and a (possibly nil) map of options.
Expand All @@ -49,11 +52,6 @@ Here's one example:
(apply pp/write value (mapcat identity (assoc options :stream writer))))
----

IMPORTANT: Before Clojure 1.10.2, a
https://clojure.atlassian.net/browse/CLJ-1445[bug] in `clojure.pprint` caused it
to not work properly with `+*print-meta*+`. If you need to print the metadata
you'll have to change the print function or disable pretty-printing.

== Limiting printed output

You can set `cider-print-quota` to limit the number of bytes that will be
Expand Down
Loading