This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-04
Channels
- # aleph (2)
- # announcements (1)
- # biff (1)
- # calva (16)
- # cider (4)
- # clojure (45)
- # clojure-argentina (1)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-norway (18)
- # clojure-uk (7)
- # clojurebridge (1)
- # clojurescript (3)
- # clr (3)
- # cursive (21)
- # datomic (4)
- # fulcro (4)
- # graalvm (3)
- # holy-lambda (8)
- # honeysql (22)
- # lsp (3)
- # malli (3)
- # nbb (1)
- # off-topic (3)
- # portal (13)
- # re-frame (3)
- # reagent (7)
- # releases (1)
- # shadow-cljs (1)
Is there a Calva command that can take a string to eval (in the current namespace at least)? Similar to the “Evaluate Selection” command, but instead of taking selection, is passed a string to evaluate?
I know about Repl Snippets, but I’m thinking of something I could use with less ceremony (not having to name them, and also avoiding littering config with permutations of a command).
Context: I use vscode commands programmatically from Talon Voice with a synax like this:
evaluate selection: vscode("calva.evaluateSelection")
The first part is the spoken phrase, then takes a vscode command id. There is a version that takes input parameters for vscode commands that take them. So in this case the vscode command would take the string to evaluate.
Did you see my reply on that issue, @U09D96P9B? https://github.com/BetterThanTomorrow/calva/issues/2422#issuecomment-1981626014
Ok that does seem to work!! I thought I had tried that before, (simply giving the command a string, and it didn’t work for me previously. maybe just had an incorrect call)

I am using it via rpc like this.
user.run_rpc_command("calva.runCustomREPLCommand", "(println \"hello-world\" )")
This invokation takes args linearly. Any thing I’m missing compared to your example with named argument? what is "repl": "clj"
?
Could I declare a namespace with this linear call? .
Oh, I think I see.. the first argument can be a map?
What format is runCustomREPLCommand expecting arguments? Pass it json string?
I tried passing json string and got this error:
; Syntax error reading source at (REPL:1607:12).
; Invalid token: :
What is the best way to pass multiple argments (map) to vscode action, from a python context? python dict -> json string, or is there some kind of desctructured syntax the vscode command expects (for associative args)?
So to confirm, calva.runCustomREPLCommand
takes 1 argment?…If it is a string, evaluates it as a snippet in the current namespace. If it is a json map, it reads named arguments (outlined in custom repl commands)
I’m thinking that the rpc call maybe supports using a python dict and take care of converting it to json. Have you tried that?
Thx for confirming. I tried the dict->json via dump()
in Python. It didnt work and was throwing some kind of error, but maybe something else was off, will try again.
I tried passing json string and got this error:
; Syntax error reading source at (REPL:1607:12).
; Invalid token: :