Skip to content

Commit 9868c37

Browse files
committed
Add support for pretty printing values in the inspector.
1 parent d6a875b commit 9868c37

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master (unreleased)
44

5+
- [#3813](https://github.com/clojure-emacs/cider/pull/3813) Add support for pretty printing values in the inspector.
6+
57
### New features
68

79
- [#3802](https://github.com/clojure-emacs/cider/issues/3802): Inspector analytics.

cider-inspector.el

+13-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Can be turned to nil once the user sees and acknowledges the feature."
140140
(define-key map "n" #'cider-inspector-next-inspectable-object)
141141
(define-key map [(shift tab)] #'cider-inspector-previous-inspectable-object)
142142
(define-key map "p" #'cider-inspector-previous-inspectable-object)
143+
(define-key map "P" #'cider-inspector-toggle-pretty-print)
143144
(define-key map ":" #'cider-inspect-expr-from-inspector)
144145
(define-key map "f" #'forward-char)
145146
(define-key map "b" #'backward-char)
@@ -349,6 +350,15 @@ MAX-NESTED-DEPTH is the new value."
349350
(when (nrepl-dict-get result "value")
350351
(cider-inspector--render-value result :next-inspectable))))
351352

353+
(defun cider-inspector-toggle-pretty-print ()
354+
"Toggle the pretty printing of values in the inspector."
355+
(interactive)
356+
(let ((result (cider-nrepl-send-sync-request
357+
`("op" "inspect-toggle-pretty-print")
358+
(cider-current-repl))))
359+
(when (nrepl-dict-get result "value")
360+
(cider-inspector--render-value result))))
361+
352362
(defun cider-inspector-toggle-view-mode ()
353363
"Toggle the view mode of the inspector between normal and object view mode."
354364
(interactive)
@@ -508,7 +518,9 @@ MAX-COLL-SIZE if non nil."
508518
,@(when cider-inspector-max-nested-depth
509519
`("max-nested-depth" ,cider-inspector-max-nested-depth))
510520
,@(when cider-inspector-display-analytics-hint
511-
`("display-analytics-hint" "true"))))
521+
`("display-analytics-hint" "true"))
522+
,@(when cider-inspector-pretty-print
523+
`("pretty-print" "true"))))
512524
(cider-nrepl-send-sync-request (cider-current-repl))))
513525

514526
(declare-function cider-set-buffer-ns "cider-mode")

doc/modules/ROOT/pages/debugging/inspector.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ You'll have access to additional keybindings in the inspector buffer
8181
| Switch the rendering of the current value between `:normal`, `:table`, and
8282
`:object` view modes. In `:table` mode, render the value as a table (only supported for sequences of maps or tuples). In `:object` mode, any value is rendered as a plain Java object (by displaying its fields) instead of custom rendering rules that the Inspector applies in `:normal` mode.
8383

84+
| kbd:[P]
85+
| `cider-inspector-toggle-pretty-print`
86+
| Toggle the pretty printing of values in the inspector.
87+
8488
| kbd:[d]
8589
| `cider-inspector-def-current-val`
8690
| Defines a var in the REPL namespace with current inspector value. If you tend to always choose the same name(s), you may want to set the `cider-inspector-preferred-var-names` customization option.

0 commit comments

Comments
 (0)