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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

r0man
Copy link
Contributor

@r0man r0man commented Apr 13, 2025

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.

The NREPL part is here: clojure-emacs/cider-nrepl#933

When pressing "P" in the inspector the currently inspected value is printed in a new popup buffer (on the left side in the picture).

cider-inspect-print-current-value

I see it as the inspectors brother of cider-pprint-eval-last-sexp which I use all the time.

This is the functionality I initially suggested, before working on the pretty mode. I think it is still useful. What I would like to have is a quick way to pretty print the current value of the inspector in the same familiar way my eye is used to, as the Clojure pretty printer (or what we are using in CIDER).

The new pretty mode does print more pretty, but differently, it uses "inspector mode" printing.

That's why I think this could be a useful addition.

Wdyt?


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (eldev test)
  • All code passes the linter (eldev lint) which is based on elisp-lint and includes
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the user manual (if adding/changing user-visible functionality)

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.
@r0man r0man force-pushed the inspect-pprint-current-value branch from 6350c4c to 34637f1 Compare April 13, 2025 19:33
@@ -2,6 +2,9 @@

## master (unreleased)

- [#3810](https://github.com/clojure-emacs/cider/pull/3810) Add the `cider-inspector-print-current-value` command to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot the : after the PR link. Also - this should be under "New features".

@bbatsov
Copy link
Member

bbatsov commented Apr 22, 2025

I'm fine with this suggestion. @alexander-yakushev what do you think?

@alexander-yakushev
Copy link
Member

With pretty-printing mode now merged, do you still desire to have this feature, @r0man? If so, we'll need some other key binding.

@r0man
Copy link
Contributor Author

r0man commented Apr 22, 2025

Hi @alexander-yakushev and @bbatsov, yes, I'm still interested in it. I take a look at it later or tomorrow and look for a new keybinding.

(require 'cider-eval)

;; ===================================
;; Inspector Key Map and Derived Mode
;; ===================================

(defconst cider-inspector-buffer "*cider-inspect*")
(defconst cider-inspector-value-buffer "*cider-inspect-value*")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to reuse *cider-result* buffer for this instead of creating yet another buffer type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually using that before, but then thought a new buffer is better. But, yes, I can change it to use that one instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is best to reuse the existing facility that powers *cider-result* so that we don't need to add any new code for setting up the buffer, making it readonly, establishing q binding, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants