This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-23
Channels
- # announcements (2)
- # architecture (16)
- # babashka (26)
- # beginners (106)
- # calva (173)
- # chlorine-clover (19)
- # cider (36)
- # cljdoc (4)
- # clojure (113)
- # clojure-berlin (3)
- # clojure-czech (3)
- # clojure-dev (5)
- # clojure-europe (37)
- # clojure-france (3)
- # clojure-hamburg (12)
- # clojure-italy (4)
- # clojure-nl (2)
- # clojure-uk (22)
- # clojurescript (38)
- # cryogen (10)
- # cursive (30)
- # data-science (7)
- # datascript (1)
- # datomic (13)
- # deps-new (7)
- # depstar (13)
- # duct (3)
- # events (2)
- # exercism (3)
- # fulcro (31)
- # graalvm (56)
- # graphql (1)
- # helix (5)
- # java (12)
- # jobs-discuss (19)
- # kaocha (13)
- # luminus (1)
- # lumo (4)
- # malli (5)
- # off-topic (17)
- # parinfer (1)
- # pathom (1)
- # pedestal (7)
- # rdf (10)
- # re-frame (1)
- # remote-jobs (7)
- # rum (6)
- # shadow-cljs (4)
- # tools-deps (41)
- # uncomplicate (3)
- # vim (14)
Hi all, I'm trying to do some hacking on cider. How do I ensure the code I send to the REPL will get evaluated on the namespace of the file I'm in?
when you eval in-line that happens automatically. the ns is sent along with the code form. the repl has a namespace and this is the ns that is used. i can't think of a good way to do this that also allows for input from a user.
one suggestion would be to make a read only buffer that could contain the inputs and outputs to things that are evaluated in-line. so it would appear like a repl but only contain the inputs and outputs to cider's evaluating inline
i suppose you could put stuff in the cider-send-to-repl to attempt to set the current ns to the file's ns
I'll describe what I'm trying to do, maybe it'll help clarify things: I thought it would be nice to add a cider-decompile
interactive command, sort of like cider-macroexpand-1
. For that I started my hacking around the cider-macroexpand.el
file
The idea was to take the output and display it in a temporary buffer in java mode
It does, but cider-nrepl-send-sync-request
doesn't eval in the current ns unlike cider-interactive-eval
(?)
you can see how it sends that along. it sends the ns into cider-nrepl-request:eval
. which just builds up a list like
(("ns" whatever) ("code" "code to be evaluated") ....)
there's a helper function nrepl--eval-request
which builds all that up and the ns is threaded through
yeah this may just be a cool thing people can add. not sure if CIDER should depend on that
perhaps the documentation could take this? A section on expanding and customizing CIDER and show how easy it can be to add new features like this
Theoretically, there's a bigger feature here. The ability to take some arbitrary piece of code at point, wrap it in an expression, potentially parametrized over some variables, and evaluate that, instead
off the top of my head, it could be useful for profiling, benchmarking, decompiling, they all behave the same
can you give an example? or the proposed change to CIDER? i'm not following as it seems you kinda used the building blocks already present. i'm assuming you constructed a handler using one of the handler functions and that took the response, opened a new buffer and made it java mode. and the eval you reused one of the existing functions or made a new one using a template more or less?
This isn't a big feature, more of a convenience where you'll need to plug in a few parameters: ā¢ pre command ā¢ wrap command ā¢ output buffer name ā¢ output buffer mode ā¢ cider-jack-in extra dependencies ā¢ command name ā¢ command keys This can be exposed as a single function which will allow users to make small extensions to cider without modifying the core, even with extra dependencies
In the meanwhile I threw my work https://github.com/bsless/clj-decompiler.el/blob/master/clj-decompiler.el, I'll add some README instructions, credits, etc. Hope you find it useful š