branch: elpa/cider
commit 5c12eb90be3e9075ac96694391f62ee1927cfdbc
Author: vemv <[email protected]>
Commit: vemv <[email protected]>

    Introduce `cider-inspector-tap-at-point`
---
 CHANGELOG.md                                    |  1 +
 cider-inspector.el                              | 32 ++++++++++++++++++++++---
 doc/modules/ROOT/pages/debugging/inspector.adoc |  4 ++++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5270689b98..bffd50f331 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
 ### Changes
 
 - [#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.
+- CIDER 
[Inspector](https://docs.cider.mx/cider/debugging/inspector.html#usage): 
introduce `1` keybinding which performs `cider-inspector-tap-at-point`.
 - CIDER 
[Inspector](https://docs.cider.mx/cider/debugging/inspector.html#usage): 
introduce `o` keybinding which performs `cider-inspector-open-thing-at-point`.
 - CIDER 
[Inspector](https://docs.cider.mx/cider/debugging/inspector.html#usage): 
introduce `:` keybinding which performs `cider-inspect-expr-from-inspector`.
 - 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. 
diff --git a/cider-inspector.el b/cider-inspector.el
index fc6177f6c9..820fd35bd1 100644
--- a/cider-inspector.el
+++ b/cider-inspector.el
@@ -116,6 +116,7 @@ by clicking or navigating to them by other means."
     (define-key map "c" #'cider-inspector-set-max-coll-size)
     (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)
     (define-key map [tab] #'cider-inspector-next-inspectable-object)
     (define-key map "\C-i" #'cider-inspector-next-inspectable-object)
     (define-key map "n" #'cider-inspector-next-inspectable-object)
@@ -386,6 +387,24 @@ current-namespace."
             (error "Could not tap the current Inspector value: %s" err))))
     (user-error "No CIDER session found")))
 
+(defun cider-inspector-tap-at-point ()
+  "Sends the current Inspector current sub-value (per POINT) to `tap>'."
+  (interactive)
+  ;; NOTE: we don't set `cider-inspector--current-repl', because we mean to 
tap the current value of an existing Inspector,
+  ;; so whatever repl was used for it, should be used here.
+  (if cider-inspector--current-repl
+      (seq-let (property value) (cider-inspector-property-at-point)
+        (pcase property
+          (`cider-value-idx
+           (let* ((idx value)
+                  (response (cider-sync-request:inspect-tap-indexed idx)))
+             (nrepl-dbind-response response (value err)
+               (if value
+                   (message "Successfully tapped the Inspector item at point")
+                 (error "Could not tap the Inspector item at point: %s" 
err)))))
+          (_ (error "No object at point"))))
+    (user-error "No CIDER session found")))
+
 ;; nREPL interactions
 (defun cider-sync-request:inspect-pop (&optional v2)
   "Move one level up in the inspector stack,
@@ -520,6 +539,13 @@ instead of just its \"value\" entry."
   "Sends current inspector value to tap>."
   (cider-nrepl-send-sync-request '("op" "inspect-tap-current-value") 
cider-inspector--current-repl))
 
+(defun cider-sync-request:inspect-tap-indexed (idx)
+  "Sends current inspector sub-value to tap>, per IDX."
+  (cl-assert idx)
+  (cider-nrepl-send-sync-request `("op" "inspect-tap-indexed"
+                                   "idx" ,idx)
+                                 cider-inspector--current-repl))
+
 (defun cider-sync-request:inspect-expr (expr ns page-size max-atom-length 
max-coll-size &optional v2)
   "Evaluate EXPR in context of NS and inspect its result.
 Set the page size in paginated view to PAGE-SIZE, maximum length of atomic
@@ -746,11 +772,11 @@ that value.
 3. If point is on a range-button fetch and insert the range."
   (interactive)
   (seq-let (property value) (cider-inspector-property-at-point)
-    (cl-case property
-      (cider-value-idx
+    (pcase property
+      (`cider-value-idx
        (cider-inspector-push value))
       ;; TODO: range and action handlers
-      (t (error "No object at point")))))
+      (_ (error "No object at point")))))
 
 (defun cider-inspector-operate-on-click (event)
   "Move to EVENT's position and operate the part."
diff --git a/doc/modules/ROOT/pages/debugging/inspector.adoc 
b/doc/modules/ROOT/pages/debugging/inspector.adoc
index 6592bb8e0f..d894f492bd 100644
--- a/doc/modules/ROOT/pages/debugging/inspector.adoc
+++ b/doc/modules/ROOT/pages/debugging/inspector.adoc
@@ -96,6 +96,10 @@ You'll have access to additional keybindings in the 
inspector buffer
 | `cider-inspector-tap-current-val`
 | Performs `tap>` using the inspector's current value as it argument.
 
+| kbd:[1]
+| `cider-inspector-tap-at-point`
+| Performs `tap>` using the inspector's current sub-value (the one at POINT) 
as it argument.
+
 |===
 
 == Use `enrich-classpath` for best results

Reply via email to