Skip to content

Commit 5c12eb9

Browse files
committed
Introduce cider-inspector-tap-at-point
1 parent 4856be1 commit 5c12eb9

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

CHANGELOG.md

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

77
- [#3576](https://github.com/clojure-emacs/cider/issues/3576): CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html): display Java class/method/field block tags (Returns/Throws/Params info) when available.
8+
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html#usage): introduce `1` keybinding which performs `cider-inspector-tap-at-point`.
89
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html#usage): introduce `o` keybinding which performs `cider-inspector-open-thing-at-point`.
910
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html#usage): introduce `:` keybinding which performs `cider-inspect-expr-from-inspector`.
1011
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html): retain [`truncate-lines`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Line-Truncation.html) values across screens.

cider-inspector.el

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ by clicking or navigating to them by other means."
116116
(define-key map "c" #'cider-inspector-set-max-coll-size)
117117
(define-key map "d" #'cider-inspector-def-current-val)
118118
(define-key map "t" #'cider-inspector-tap-current-val)
119+
(define-key map "1" #'cider-inspector-tap-at-point)
119120
(define-key map [tab] #'cider-inspector-next-inspectable-object)
120121
(define-key map "\C-i" #'cider-inspector-next-inspectable-object)
121122
(define-key map "n" #'cider-inspector-next-inspectable-object)
@@ -386,6 +387,24 @@ current-namespace."
386387
(error "Could not tap the current Inspector value: %s" err))))
387388
(user-error "No CIDER session found")))
388389

390+
(defun cider-inspector-tap-at-point ()
391+
"Sends the current Inspector current sub-value (per POINT) to `tap>'."
392+
(interactive)
393+
;; NOTE: we don't set `cider-inspector--current-repl', because we mean to tap the current value of an existing Inspector,
394+
;; so whatever repl was used for it, should be used here.
395+
(if cider-inspector--current-repl
396+
(seq-let (property value) (cider-inspector-property-at-point)
397+
(pcase property
398+
(`cider-value-idx
399+
(let* ((idx value)
400+
(response (cider-sync-request:inspect-tap-indexed idx)))
401+
(nrepl-dbind-response response (value err)
402+
(if value
403+
(message "Successfully tapped the Inspector item at point")
404+
(error "Could not tap the Inspector item at point: %s" err)))))
405+
(_ (error "No object at point"))))
406+
(user-error "No CIDER session found")))
407+
389408
;; nREPL interactions
390409
(defun cider-sync-request:inspect-pop (&optional v2)
391410
"Move one level up in the inspector stack,
@@ -520,6 +539,13 @@ instead of just its \"value\" entry."
520539
"Sends current inspector value to tap>."
521540
(cider-nrepl-send-sync-request '("op" "inspect-tap-current-value") cider-inspector--current-repl))
522541

542+
(defun cider-sync-request:inspect-tap-indexed (idx)
543+
"Sends current inspector sub-value to tap>, per IDX."
544+
(cl-assert idx)
545+
(cider-nrepl-send-sync-request `("op" "inspect-tap-indexed"
546+
"idx" ,idx)
547+
cider-inspector--current-repl))
548+
523549
(defun cider-sync-request:inspect-expr (expr ns page-size max-atom-length max-coll-size &optional v2)
524550
"Evaluate EXPR in context of NS and inspect its result.
525551
Set the page size in paginated view to PAGE-SIZE, maximum length of atomic
@@ -746,11 +772,11 @@ that value.
746772
3. If point is on a range-button fetch and insert the range."
747773
(interactive)
748774
(seq-let (property value) (cider-inspector-property-at-point)
749-
(cl-case property
750-
(cider-value-idx
775+
(pcase property
776+
(`cider-value-idx
751777
(cider-inspector-push value))
752778
;; TODO: range and action handlers
753-
(t (error "No object at point")))))
779+
(_ (error "No object at point")))))
754780

755781
(defun cider-inspector-operate-on-click (event)
756782
"Move to EVENT's position and operate the part."

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ You'll have access to additional keybindings in the inspector buffer
9696
| `cider-inspector-tap-current-val`
9797
| Performs `tap>` using the inspector's current value as it argument.
9898

99+
| kbd:[1]
100+
| `cider-inspector-tap-at-point`
101+
| Performs `tap>` using the inspector's current sub-value (the one at POINT) as it argument.
102+
99103
|===
100104

101105
== Use `enrich-classpath` for best results

0 commit comments

Comments
 (0)