Fork me on GitHub
#calva
<
2023-10-04
>
Ingy döt Net18:10:29

I started using a calva fiddles for key bindings to my test files. But then I realized that I could just use one fiddle file. Now I realize that all I want to do in the key binding is call a function but have it act like I called it from the current file. That's what the fiddle is doing for me effectively. So I have a bunch of bindings that look like:

{ "key": "ctrl+t",
  "when": "calva:connected",
  "command": "runCommands",
  "args": {
    "commands": [
      { "command": "calva.runCustomREPLCommand",
        "args": "(intern 'user 'opts \":x :y :z\")" },
      { "command": "calva.evaluateFiddleForSourceFile" } ] } },
with a fiddle.clj like:
(eval (read-string (str "(my.test.ns/run " user/opts ")")))
when something like this seems more simple and powerful:
{ "key": "ctrl+t",
  "when": "calva:connected",
  "command": "calva.runCustomREPLCommand",
  "args": "(my.test.ns/run :x :y :z)" }
but my.test.run/run is a macro that uses *ns* which is bound to the current ns, which without the fiddle is user and I want it to be the ns of the current file I'm editting. If there was a var that held the currently editing ns, I think I could do this. Is there?

pez18:10:38

That’ll be $editor-ns. See https://calva.io/custom-commands/ for all the substitution variables available.

❤️ 1