cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
588 stars 7 forks source link

Capture highlighted var/symbol from Cursive for extension #1696

Open theronic opened 7 years ago

theronic commented 7 years ago

I want to sequence some music and store the result in the highlighted atom symbol, i.e. #(reset! the-highlighted-symbol {:some-notes [5 6 7 ]}).

Is there a way to interact with Cursive from the REPL to enumerate or detect clicking on a symbol in the text editor so that I can capture that var and trigger an input dialog?

cursive-ide commented 7 years ago

So the closest thing to this at the moment would be a REPL command, see here. There's a fix in the latest EAPs allowing the use of ~selection to pass the selection to the command, and I'm planning to add more, see #1694.

But this isn't really what you're after, right? You'd like to be able to enter that command at the REPL, and use something like those substitutions in the REPL itself. It's an interesting idea, and related to something else someone asked me about - essentially adding bidirectional communication from the editor to the REPL.

The simplest solution in your case would be for me to just wrap the forms you send and bind some dynamic variables with similar values to the substitutions from that issue. So when you enter that command I would issue something like:

(binding [*cursive.interaction/current-editor-var* <some value>]
  #(reset! *cursive.interaction/current-editor-var* {:some-notes [5 6 7 ]}))

What do you think?