BetterThanTomorrow / calva

Clojure & ClojureScript Interactive Programming for VS Code
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
Other
1.64k stars 214 forks source link

Make the (comment \n ,) trick aka "comma close parens" work on reformatting #945

Open clyfe opened 3 years ago

clyfe commented 3 years ago

When writing a comment, the closing parens is ergonomically on the next line, to work easily with the last form. Reformatting moves it up. In Clover there's a trick with a comma, that keeps the parens in it's place. It would be nice if that would work with Calva.

(comment
  (dabble)
  ,)
bpringe commented 3 years ago

the closing parens is ergonomically on the next line, to work easily with the last form.

Not to say this shouldn't work in Calva, but just curious what your reasons are for saying this. I find that since alt+enter evaluates the top level form within the comment (in Calva), that there's no issue working with the last form being on the same line as the closing paren. Maybe your workflow is different and/or I am missing something(s), though.

clyfe commented 3 years ago

You don't always want to evaluate all that's in the comment block, it may not all be pure functional, you may want to cherry pick because order, or side effects.

PEZ commented 3 years ago

From en evaluation point of view the placement of that last paren doesn't matter at all, though. Can you describe in a bit more detail what ”work easily with the last form” means?

bpringe commented 3 years ago

Just to clarify, if you put your cursor anywhere inside the (dabble) form in your example, and run "Evaluate top level form" (alt+enter by default), it will only evaluate (dabble), even if you had other forms inside the comment form. This is how Calva makes working inside comment forms easier.

clyfe commented 3 years ago

I guess I'm used to moving to the end of a form and "eval last form". I pretty much never use "eval top level". I use "eval file" and "eval last form" ("current" I believe in calva parlance).

PEZ commented 3 years ago

Current Form goes beyond parlance, actually. You can also place the cursor before the opening paren and use the command. (Even if it seems to be unnecessary work to move the cursor around and evaluate something that you can just alt+enter instead.)