branch: elpa/cider
commit 966cae463c65d0392d1148eb252912f31c03c881
Author: behrica <behr...@users.noreply.github.com>
Commit: vemv <v...@users.noreply.github.com>

    Inspector: introduce `cider-inspector-tap-current-val` command
    
    Fixes https://github.com/clojure-emacs/cider/issues/3548
---
 CHANGELOG.md                                    |  1 +
 cider-inspector.el                              | 18 ++++++++++++++++++
 doc/modules/ROOT/pages/debugging/inspector.adoc |  9 +++++++++
 3 files changed, 28 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index dbf1dfe035..547cc9f38b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
 ### New features
 
 - [#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)).
+- [#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)).
 
 ### Changes
 
diff --git a/cider-inspector.el b/cider-inspector.el
index fedca2e496..563b2c661f 100644
--- a/cider-inspector.el
+++ b/cider-inspector.el
@@ -106,6 +106,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 "d" #'cider-inspector-def-current-val)
+    (define-key map "t" #'cider-inspector-tap-current-val)
     (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)
@@ -328,6 +329,19 @@ current-namespace."
     (cider-inspector--render-value value)
     (message "%s#'%s/%s = %s" cider-eval-result-prefix ns var-name value)))
 
+(defun cider-inspector-tap-current-val ()
+  "Sends the current Inspector current value 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
+      (let ((response (cider-sync-request:inspect-tap-current-val)))
+        (nrepl-dbind-response response (value err)
+          (if value
+              (message "Successully tapped the current Inspector value")
+            (error"Could not tap the current Inspector value: %s" err))))
+    (user-error "No CIDER session found")))
+
 ;; nREPL interactions
 (defun cider-sync-request:inspect-pop ()
   "Move one level up in the inspector stack."
@@ -402,6 +416,10 @@ MAX-SIZE is the new value."
                 (cider-nrepl-send-sync-request cider-inspector--current-repl)
                 (nrepl-dict-get "value")))
 
+(defun cider-sync-request:inspect-tap-current-val ()
+  "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-expr (expr ns page-size max-atom-length 
max-coll-size)
   "Evaluate EXPR in context of NS and inspect its result.
 Set the page size in paginated view to PAGE-SIZE, maximum length of atomic
diff --git a/doc/modules/ROOT/pages/debugging/inspector.adoc 
b/doc/modules/ROOT/pages/debugging/inspector.adoc
index 400e22d4e1..e3b79c96bd 100644
--- a/doc/modules/ROOT/pages/debugging/inspector.adoc
+++ b/doc/modules/ROOT/pages/debugging/inspector.adoc
@@ -22,6 +22,10 @@ the last result. This behavior can be controlled with the 
variable
 TIP: The inspector can also be invoked in the middle of a debugging
 session, see xref:debugging/debugger.adoc[here] for more details.
 
+TIP: The current value of the debugger can be as sent as well to Clojure's
+`tap>` facility. This can be used to integrate CIDER with various external
+tools which render tapped values in a web browser, for example.
+
 You'll have access to additional keybindings in the inspector buffer
 (which is internally using `cider-inspector-mode`):
 
@@ -79,6 +83,11 @@ You'll have access to additional keybindings in the 
inspector buffer
 | kbd:[0]
 | `cider-inspector-next-sibling`
 | Navigates to the next sibling, within a sequential collection.
+
+| kbd:[t]
+| `cider-inspector-tap-current-val`
+| Performs `tap>` using the inspector's current value as it argument.
+
 |===
 
 == Configuration

Reply via email to