Fork me on GitHub
#calva
<
2021-04-21
>
flowthing07:04:47

Does Calva have a scratch buffer (https://docs.cider.mx/cider/usage/misc_features.html#using-a-scratchpad) like CIDER? Can't seem to find it if it does.

pez07:04:45

I’m not completely sure what the scratch buffer brings. But let me try to describe what VS Code and Calva has that I think is relevant given the description on the link. In VS Code you can easily create an unnamed editor (`cmd+n` on mac). An editor is about the same as what Emacs calls buffer. Then you can easily switch the language of that editor to Clojure, either by the command Change Language Mode, the language button in the status bar, or pasting something from another Clojure editor there. This editor then defaults to the user namespace when you evaluate code in it, and just generally get the same treatment as any Calva editor. If it is a ClojureScript project you can use the command Toggle the REPL Connection (clj or cljs) used for CLJC Files to switch this file between the Clojure and the ClojureScript REPL (just as with cljc files and the output window).

pez07:04:01

Does that seem to cover the use case you are looking for?

pez07:04:38

Forgot: The way to “bless” the editor with another namespace than user is to add an ns form to it. (At the moment Calva reads the first ns form it finds. I have been planning to change that so that it is rather the last one that rules.)

flowthing07:04:54

Thanks, that's useful to know, and it does cover the use case. :thumbsup::skin-tone-2: In the context of Calva, implementing a scratch buffer (or editor) type of thing would probably mean just a convenience command that opens a new editor, assigns it the correct syntax, and possibly configures it such that the tab doesn't show the dirty indicator.

pez07:04:05

> possibly configures it such that the tab doesn’t show the dirty indicator I don’t think that’s possible. But I could be wrong.

flowthing07:04:15

Ok, well, not super-critical. :man-shrugging::skin-tone-2:

pez07:04:47

What I’ve been planning to do, which is a bit similar to these unnamed editors, is to have a command that creates a repl/fiddle file for the current “real” Clojure file. That would then “live” side by side with the real file and can be commited or git-ignored as the user sees fit. And it can be saved then to get rid of the dirty marker. You can always do this manually, of course, but I think it makes sense to make it fewer steps.

3
👍 5
🙌 3