diff --git a/CHANGELOG.md b/CHANGELOG.md index 37ab72942..274553d82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### New features +- [#3692](https://github.com/clojure-emacs/cider/pull/3692): Add ability to switch view modes in the ispector (bound to `v`). + ### Changes - Bump the injected `cider-nrepl` to [0.49.0](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0490-2024-06-02). diff --git a/cider-inspector.el b/cider-inspector.el index dee954011..ad0109739 100644 --- a/cider-inspector.el +++ b/cider-inspector.el @@ -124,6 +124,7 @@ by clicking or navigating to them by other means." (define-key map "a" #'cider-inspector-set-max-atom-length) (define-key map "c" #'cider-inspector-set-max-coll-size) (define-key map "C" #'cider-inspector-set-max-nested-depth) + (define-key map "v" #'cider-inspector-toggle-view-mode) (define-key map "d" #'cider-inspector-def-current-val) (define-key map "t" #'cider-inspector-tap-current-val) (define-key map "1" #'cider-inspector-tap-at-point) @@ -353,6 +354,14 @@ MAX-NESTED-DEPTH is the new value." (when (nrepl-dict-get result "value") (cider-inspector--render-value result 'v2)))) +(defun cider-inspector-toggle-view-mode () + "Toggle the view mode of the inspector between normal and object view mode." + (interactive) + (let ((result (cider-nrepl-send-sync-request `("op" "inspect-toggle-view-mode") + cider-inspector--current-repl))) + (when (nrepl-dict-get result "value") + (cider-inspector--render-value result 'v2)))) + (defcustom cider-inspector-preferred-var-names nil "The preferred var names to be suggested by `cider-inspector-def-current-val'. diff --git a/doc/modules/ROOT/pages/debugging/inspector.adoc b/doc/modules/ROOT/pages/debugging/inspector.adoc index fc82481dc..72bc376e1 100644 --- a/doc/modules/ROOT/pages/debugging/inspector.adoc +++ b/doc/modules/ROOT/pages/debugging/inspector.adoc @@ -76,6 +76,10 @@ You'll have access to additional keybindings in the inspector buffer | `cider-inspector-set-max-atom-length` | Set a new maximum length above which nested atoms (non-collections) are truncated +| kbd:[v] +| `cider-inspector-toggle-view-mode` +| Switch the rendering of the current value between `:normal` and `:object` view mode. 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. + | kbd:[d] | `cider-inspector-def-current-val` | 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.