Fork me on GitHub
#calva
<
2022-09-04
>
skylize13:09:57

Is it possible to stay in the user namespace while evaluating code in the editor?

pez14:09:15

Not really. What is the use case?

skylize15:09:30

To take advantage of a user.clj file to prepare a dev environment (e.g. require useful dev namespaces like clojure.repl), and then to work from within that.

skylize16:09:48

Actually, thinking through this a bit, it seems like it would be very difficult to work out what should eval in the editor file's namespace, and what should eval under user. :thinking_face:

skylize17:09:54

I guess the obvious solution here is to just keep the user.clj file open for use as repl input.

pez19:09:15

It’s what I often do.

skylize03:09:10

Seems like it could work decently to have a key-chord prefix that changes eval to user. i.e. Alt + Enter -> Evaluate top level form Ctrl + Alt + C , Alt + Enter -> Evaluate top level form in user namespace

skylize03:09:38

Maybe Ctrl + Alt + U ... to indicate "user". Doesn't seem to be anything that shortcut in a default Code setup.

pithyless08:09:02

Aside from the initial dev setup, isn't most of the code you're evaluating going to be in different namespaces?

pez08:09:19

You can define a custom repl command like so:

"calva.customREPLCommandSnippets": [
        {
            "name": "Eval Current Form in user NS",
            "key": "eval-current-form-in-user-ns",
            "ns": "user",
            "snippet": "$current-form"
        },
Then a keybinding like so:
{
        "key": "ctrl+alt+u alt+enter",
        "command": "calva.runCustomREPLCommand",
        "args": "eval-current-form-in-user-ns"
    }
(You can of course pick a shorter key, like ecfu or something 😄 )

skylize12:09:13

sweet 🍰

pez12:09:15

I've now pushed a PR which allows for defining keyboard shortcuts to ”unregistered” custom repl commands. • Description of change: https://github.com/BetterThanTomorrow/calva/issues/1853 • VSIX (please consider helping with testing it): https://output.circle-artifacts.com/output/job/8ffb18f8-98a0-4f70-84c3-935b54769010/artifacts/0/tmp/artifacts/calva-2.0.299-1853-shortcut-repl-snippets-ecced4a7.vsix

skylize14:09:22

even sweeter

pez12:09:15

I've now pushed a PR which allows for defining keyboard shortcuts to ”unregistered” custom repl commands. • Description of change: https://github.com/BetterThanTomorrow/calva/issues/1853 • VSIX (please consider helping with testing it): https://output.circle-artifacts.com/output/job/8ffb18f8-98a0-4f70-84c3-935b54769010/artifacts/0/tmp/artifacts/calva-2.0.299-1853-shortcut-repl-snippets-ecced4a7.vsix