Skip to content

Add command to print the current value of the inspector. #3810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
(require 'cl-lib)
(require 'easymenu)
(require 'seq)
(require 'cider-client)
(require 'cider-eval)

;; ===================================
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions doc/modules/ROOT/pages/debugging/inspector.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading