Skip to content
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

new middleware op to tap-current-value #770

Closed
behrica opened this issue Mar 6, 2023 · 7 comments
Closed

new middleware op to tap-current-value #770

behrica opened this issue Mar 6, 2023 · 7 comments

Comments

@behrica
Copy link
Contributor

behrica commented Mar 6, 2023

In order to continue to support:
clojure-emacs/cider#3311

I think we need a new middleware function, which could the be called later from the cider inspect elisp code to be written.

I think it should be very similar to this function

(defn def-current-value [msg]

and call the new function in orchard inspect/tap-current-value
introduced with commit: clojure-emacs/orchard@625a78a

Does this seems reasonable to go ahead in supporting clojure-emacs/cider#3311 ?

@behrica behrica changed the title new middlewar function new middleware function to tap-current-value Mar 6, 2023
@behrica
Copy link
Contributor Author

behrica commented Mar 19, 2023

Would you be interested in a PR for this ?

@vemv
Copy link
Member

vemv commented Mar 19, 2023

Yes!

Cheers - V

@behrica
Copy link
Contributor Author

behrica commented Mar 19, 2023

I tried to figure out, how I can test my new middleware op without corresponding elisp functions.

I managed to do this:

(with-open [conn (nrepl/connect :port 42857)]
     (-> (nrepl/client conn 1000)    ; message receive timeout required
         (nrepl/message {:op "eval" :code "(+ 2 3)"})
         nrepl/response-values))

How can I use the inspector middleware in this way ?
Are there any prerequisites (middleware ops to be called to "init" the inspector ) ?
Something like this (with an existing op, does not work):

(with-open [conn (nrepl/connect :port 42857)]
     (-> (nrepl/client conn 1000)    ; message receive timeout required
         (nrepl/message {:op "inspect-def-current-value" :ns "user" :var-name "test-xxx"})
         ))

I suppose I need to call som middleware ops before this ?
I looked at the documentation of all midleware ops:
https://docs.cider.mx/cider-nrepl/nrepl-api/ops.html

but did not see anything which looked like "starting the inspector"

@behrica
Copy link
Contributor Author

behrica commented Mar 19, 2023

Otherwise asked:

Which middleware op(s) do I need to call, so that a following op
inspect-def-current-value would have a notion of "current value" ?

@behrica
Copy link
Contributor Author

behrica commented Mar 19, 2023

Knowing this, I could then test my op: inspect-tap-current-value

@vemv
Copy link
Member

vemv commented Jun 23, 2023

Hey @behrica, sorry for the delay.

For developing this feature, I would suggest:

  • Draft your middleware in the cider-nrepl repo
  • Install it with lein with-profile plugin.mranderson/config install
  • Start a CIDER session, make sure the inspector works as usual
  • Read the cider-inspector.el source
    • Specifically, all the code that invokes cider-nrepl-send-sync-request
    • Remember, you can redefine this code to add printlns, etc - anything that would help your understanding
    • Also *nrepl-log* will tell you the specific trail of nrepl interactions that a given feature entails.
  • Start sending messages to your middleware
  • Refine things, and recur!

The key idea is that you simple use CIDER to develop CIDER, instead of emulating an interaction with Clojure nrepl code.

(...That is of course possible but may be hard if you aren't already familiar with the inspector. IDK)

Hope it helps!

@behrica behrica changed the title new middleware function to tap-current-value new middleware op to tap-current-value Oct 15, 2023
@behrica
Copy link
Contributor Author

behrica commented Oct 15, 2023

I did as you suggested and did both small changes to cider-nrepl and cider at the same time localy and verified that it works.
I will do a PR first here.

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

No branches or pull requests

2 participants