Fork me on GitHub
#nrepl
<
2020-03-31
>
Kevin14:03:45

Hi! I want to create a UI that modifies Clojure functions. Basically in the UI there should be a text editor containing a specific function's (or defmethod) body. On save that function body should change in the selected project. Is NREPL the correct tool for this? I was thinking of having an NREPL start in the Clojure application, and the UI would communicate through that. Is that a viable option or would I have to use a different method?

Kevin14:03:54

I don't think NREPL can actually change the code in the file. But maybe it can help with finding function locations and such?

Kevin14:03:53

Any advice would be appreciated simple_smile

bozhidar08:04:54

Well, you can do pretty much everything with a REPL, so while it’s main purpose is to eval code, there’s no limit to what that code can do. It’d be pretty easy to figure out where something is defined simply by checking it’s metadata.

Kevin08:04:46

Oh wow. I didn't even know function definitions have meta data. (well I should've, since I do use ^:private quite a bit)

Kevin08:04:21

So if I were to attach to an NREPL in a specific project, I could check the metadata like you said

Kevin08:04:45

Thank you, Clojure is full of surprises for me 🙂