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?
I don't think NREPL can actually change the code in the file. But maybe it can help with finding function locations and such?
Any advice would be appreciated :simple_smile:
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.
Oh wow. I didn't even know function definitions have meta data. (well I should've, since I do use ^:private
quite a bit)
So if I were to attach to an NREPL in a specific project, I could check the metadata like you said
Thank you, Clojure is full of surprises for me 🙂
Well, this might answer my question on defmethods at least: https://stackoverflow.com/questions/52861401/dynamically-get-the-source-strings-of-clojure-multimethod-implementation