Skip to content

Commit 966cae4

Browse files
behricavemv
authored andcommitted
Inspector: introduce cider-inspector-tap-current-val command
Fixes #3548
1 parent 1203129 commit 966cae4

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New features
66

77
- [#3529](https://github.com/clojure-emacs/cider/issues/3529): CIDER inspector: introduce `cider-inspector-previous-sibling`, `cider-inspector-next-sibling` commands ([doc](https://docs.cider.mx/cider/debugging/inspector.html#usage)).
8+
- [#3548](https://github.com/clojure-emacs/cider/issues/3548): CIDER inspector: introduce `cider-inspector-tap-current-val` command ([doc](https://docs.cider.mx/cider/debugging/inspector.html#usage)).
89

910
### Changes
1011

cider-inspector.el

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ by clicking or navigating to them by other means."
106106
(define-key map "a" #'cider-inspector-set-max-atom-length)
107107
(define-key map "c" #'cider-inspector-set-max-coll-size)
108108
(define-key map "d" #'cider-inspector-def-current-val)
109+
(define-key map "t" #'cider-inspector-tap-current-val)
109110
(define-key map [tab] #'cider-inspector-next-inspectable-object)
110111
(define-key map "\C-i" #'cider-inspector-next-inspectable-object)
111112
(define-key map "n" #'cider-inspector-next-inspectable-object)
@@ -328,6 +329,19 @@ current-namespace."
328329
(cider-inspector--render-value value)
329330
(message "%s#'%s/%s = %s" cider-eval-result-prefix ns var-name value)))
330331

332+
(defun cider-inspector-tap-current-val ()
333+
"Sends the current Inspector current value to `tap>'."
334+
(interactive)
335+
;; NOTE: we don't set `cider-inspector--current-repl', because we mean to tap the current value of an existing Inspector,
336+
;; so whatever repl was used for it, should be used here.
337+
(if cider-inspector--current-repl
338+
(let ((response (cider-sync-request:inspect-tap-current-val)))
339+
(nrepl-dbind-response response (value err)
340+
(if value
341+
(message "Successully tapped the current Inspector value")
342+
(error"Could not tap the current Inspector value: %s" err))))
343+
(user-error "No CIDER session found")))
344+
331345
;; nREPL interactions
332346
(defun cider-sync-request:inspect-pop ()
333347
"Move one level up in the inspector stack."
@@ -402,6 +416,10 @@ MAX-SIZE is the new value."
402416
(cider-nrepl-send-sync-request cider-inspector--current-repl)
403417
(nrepl-dict-get "value")))
404418

419+
(defun cider-sync-request:inspect-tap-current-val ()
420+
"Sends current inspector value to tap>."
421+
(cider-nrepl-send-sync-request '("op" "inspect-tap-current-value") cider-inspector--current-repl))
422+
405423
(defun cider-sync-request:inspect-expr (expr ns page-size max-atom-length max-coll-size)
406424
"Evaluate EXPR in context of NS and inspect its result.
407425
Set the page size in paginated view to PAGE-SIZE, maximum length of atomic

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ the last result. This behavior can be controlled with the variable
2222
TIP: The inspector can also be invoked in the middle of a debugging
2323
session, see xref:debugging/debugger.adoc[here] for more details.
2424

25+
TIP: The current value of the debugger can be as sent as well to Clojure's
26+
`tap>` facility. This can be used to integrate CIDER with various external
27+
tools which render tapped values in a web browser, for example.
28+
2529
You'll have access to additional keybindings in the inspector buffer
2630
(which is internally using `cider-inspector-mode`):
2731

@@ -79,6 +83,11 @@ You'll have access to additional keybindings in the inspector buffer
7983
| kbd:[0]
8084
| `cider-inspector-next-sibling`
8185
| Navigates to the next sibling, within a sequential collection.
86+
87+
| kbd:[t]
88+
| `cider-inspector-tap-current-val`
89+
| Performs `tap>` using the inspector's current value as it argument.
90+
8291
|===
8392

8493
== Configuration

0 commit comments

Comments
 (0)