branch: elpa/cider
commit ec9c651116916fbaab3f952ab296c79d16033a14
Author: Roman Scherer <ro...@burningswell.com>
Commit: Oleksandr Yakushev <a...@bytopia.org>

    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.
---
 CHANGELOG.md                                    |  1 +
 cider-inspector.el                              | 15 +++++++++++++++
 doc/modules/ROOT/pages/debugging/inspector.adoc |  4 ++++
 3 files changed, 20 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc9fd25e06..b7ee5527ec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
 
 ### New features
 
+- [#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.
 - [#3813](https://github.com/clojure-emacs/cider/pull/3813) Add support for 
pretty printing values in the inspector.
 - [#3802](https://github.com/clojure-emacs/cider/issues/3802): Inspector 
analytics.
 - [#3802](https://github.com/clojure-emacs/cider/issues/3802): Inspector table 
view-mode.
diff --git a/cider-inspector.el b/cider-inspector.el
index 75a5355390..e8de3bf819 100644
--- a/cider-inspector.el
+++ b/cider-inspector.el
@@ -30,6 +30,7 @@
 (require 'cl-lib)
 (require 'easymenu)
 (require 'seq)
+(require 'cider-client)
 (require 'cider-eval)
 
 ;; ===================================
@@ -146,6 +147,7 @@ Can be turned to nil once the user sees and acknowledges 
the feature."
     (define-key map [(shift tab)] 
#'cider-inspector-previous-inspectable-object)
     (define-key map "p" #'cider-inspector-previous-inspectable-object)
     (define-key map "P" #'cider-inspector-toggle-pretty-print)
+    (define-key map (kbd "C-c C-p") #'cider-inspector-print-current-value)
     (define-key map ":" #'cider-inspect-expr-from-inspector)
     (define-key map "f" #'forward-char)
     (define-key map "b" #'backward-char)
@@ -404,6 +406,18 @@ current-namespace."
     (cider-inspector--render-value result)
     (message "Defined current inspector value as #'%s/%s" ns var-name)))
 
+(defun cider-inspector-print-current-value ()
+  "Print the current value of the inspector."
+  (interactive)
+  (cider-ensure-connected)
+  (cider-ensure-op-supported "inspect-print-current-value")
+  (let ((buffer (cider-popup-buffer cider-result-buffer nil 'clojure-mode 
'ancillary)))
+    (cider-nrepl-send-request
+     `("op" "inspect-print-current-value"
+       ,@(cider--nrepl-print-request-plist fill-column))
+     (cider-popup-eval-handler buffer)
+     (cider-current-repl))))
+
 (defun cider-inspector-tap-current-val ()
   "Sends the current Inspector current value to `tap>'."
   (interactive)
@@ -428,6 +442,7 @@ current-namespace."
       (_ (error "No object at point")))))
 
 ;; nREPL interactions
+
 (defun cider-sync-request:inspect-pop ()
   "Move one level up in the inspector stack."
   (cider-nrepl-send-sync-request `("op" "inspect-pop")
diff --git a/doc/modules/ROOT/pages/debugging/inspector.adoc 
b/doc/modules/ROOT/pages/debugging/inspector.adoc
index 2b5430cb2f..6c40aaeca9 100644
--- a/doc/modules/ROOT/pages/debugging/inspector.adoc
+++ b/doc/modules/ROOT/pages/debugging/inspector.adoc
@@ -89,6 +89,10 @@ You'll have access to additional keybindings in the 
inspector buffer
 | `cider-inspector-def-current-val`
 | 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.
 
+| kbd:[C-c C-p]
+| `cider-inspector-print-current-value`
+| Print the current value of the inspector to the `cider-result-buffer`.
+
 | kbd:[9]
 | `cider-inspector-previous-sibling`
 | Navigates to the previous sibling, within a sequential collection.

Reply via email to