Skip to content

Commit c28428b

Browse files
[inspect] Tune pretty-printing
1 parent 4930267 commit c28428b

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## master (unreleased)
44

55
* [#314](https://github.com/clojure-emacs/orchard/pull/314): Print: add special printing rules for records and allow meta :type overrides.
6+
* [#336](https://github.com/clojure-emacs/orchard/pull/336): Inspector: tune pretty-printing mode.
67

78
## 0.34.0 (2025-04-18)
89

src/orchard/inspect.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@
378378
"Returns true of `s` is a long string, more than 20 character or
379379
containing newlines."
380380
[^String s]
381-
(or (.contains s "\n") (> (count s) 20)))
381+
(or (.contains s "\n") (> (count s) 50)))
382382

383383
(defn- render-map-separator
384384
"Render the map separator according to `rendered-key`. If

src/orchard/print.clj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,13 @@
208208
"Pretty print the object `x` with `orchard.pp/pprint` and return it as
209209
a string. The `:indentation` option is the number of spaces used for
210210
indentation."
211-
[x & [{:keys [indentation]}]]
212-
(let [writer (TruncatingStringWriter. *max-atom-length* *max-total-length*)
213-
indentation-str (apply str (repeat (or indentation 0) " "))]
214-
(try (pp/pprint writer x {:indentation indentation-str})
215-
(catch TruncatingStringWriter$TotalLimitExceeded _))
216-
(str/trimr (.toString writer))))
211+
([x]
212+
(pprint-str x {}))
213+
([x options]
214+
(let [{:keys [indentation] :or {indentation 0}} options
215+
writer (TruncatingStringWriter. *max-atom-length* *max-total-length*)
216+
indentation-str (apply str (repeat indentation " "))]
217+
(try (pp/pprint writer x {:indentation indentation-str
218+
:max-width (+ indentation 80)})
219+
(catch TruncatingStringWriter$TotalLimitExceeded _))
220+
(str/trimr (.toString writer)))))

0 commit comments

Comments
 (0)