Skip to content

Commit 0b90313

Browse files
committed
Add command to print the current value of the inspector.
This PR adds the interactive `cider-inspector-print-current-value` command that prints the current value of the inspector to the `cider-inspector-value-buffer` with the usual pretty printing machinery.
1 parent 3379959 commit 0b90313

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### New features
66

7+
- [#3810](https://github.com/clojure-emacs/cider/pull/3810): Add the `cider-inspector-print-current-value` command to print the current value of the inspector.
78
- [#3813](https://github.com/clojure-emacs/cider/pull/3813) Add support for pretty printing values in the inspector.
89
- [#3802](https://github.com/clojure-emacs/cider/issues/3802): Inspector analytics.
910
- [#3802](https://github.com/clojure-emacs/cider/issues/3802): Inspector table view-mode.

cider-inspector.el

+15
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
(require 'cl-lib)
3131
(require 'easymenu)
3232
(require 'seq)
33+
(require 'cider-client)
3334
(require 'cider-eval)
3435

3536
;; ===================================
@@ -146,6 +147,7 @@ Can be turned to nil once the user sees and acknowledges the feature."
146147
(define-key map [(shift tab)] #'cider-inspector-previous-inspectable-object)
147148
(define-key map "p" #'cider-inspector-previous-inspectable-object)
148149
(define-key map "P" #'cider-inspector-toggle-pretty-print)
150+
(define-key map (kbd "C-c C-p") #'cider-inspector-print-current-value)
149151
(define-key map ":" #'cider-inspect-expr-from-inspector)
150152
(define-key map "f" #'forward-char)
151153
(define-key map "b" #'backward-char)
@@ -404,6 +406,18 @@ current-namespace."
404406
(cider-inspector--render-value result)
405407
(message "Defined current inspector value as #'%s/%s" ns var-name)))
406408

409+
(defun cider-inspector-print-current-value ()
410+
"Print the current value of the inspector."
411+
(interactive)
412+
(cider-ensure-connected)
413+
(cider-ensure-op-supported "inspect-print-current-value")
414+
(let ((buffer (cider-popup-buffer cider-result-buffer nil 'clojure-mode 'ancillary)))
415+
(cider-nrepl-send-request
416+
`("op" "inspect-print-current-value"
417+
,@(cider--nrepl-print-request-plist fill-column))
418+
(cider-popup-eval-handler buffer)
419+
(cider-current-repl))))
420+
407421
(defun cider-inspector-tap-current-val ()
408422
"Sends the current Inspector current value to `tap>'."
409423
(interactive)
@@ -428,6 +442,7 @@ current-namespace."
428442
(_ (error "No object at point")))))
429443

430444
;; nREPL interactions
445+
431446
(defun cider-sync-request:inspect-pop ()
432447
"Move one level up in the inspector stack."
433448
(cider-nrepl-send-sync-request `("op" "inspect-pop")

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

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ You'll have access to additional keybindings in the inspector buffer
8989
| `cider-inspector-def-current-val`
9090
| 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.
9191

92+
| kbd:[C-c C-p]
93+
| `cider-inspector-print-current-value`
94+
| Print the current value of the inspector to the `cider-result-buffer`.
95+
9296
| kbd:[9]
9397
| `cider-inspector-previous-sibling`
9498
| Navigates to the previous sibling, within a sequential collection.

0 commit comments

Comments
 (0)