Fork me on GitHub
#cursive
<
2021-04-10
>
gscacco11:04:05

Hi all. If I select some part of a s-expression including parenthesis (even not balanced) and press del, cursive deletes the selection generating a not-balanced s-expression. From here I can't find any way to re-balance parenthesis. Is there a way to solve this problem ? Thanks

raspasov11:04:44

Don’t select expressions manually; I personally use “Extend Selection”

raspasov11:04:41

(with a keyboard shortcut attached, ofc)

simongray12:04:33

use parinfer

dpsutton14:04:28

If using paredit you can insert a new balanced pair of parens and then highlight and delete one to leave you with the desired paren to help balancing. But the advice to never get into this state is the more correct way to manipulate forms

simongray14:04:12

All I know is that as long as I keep auto-indenting while using parinfer, I can quite casually highlight and delete most stuff and It Just Works(tm) 😉

armed08:04:20

Sometimes I manually select closing paren, copy it to buffer and paste somewhere else to achieve balance. I know it’s dirty technique, but works.

katox07:04:21

the dirty solution to unbalanced parens with cursive paredit is just copying and pasting closing parens

👆 3
raspasov13:04:09

In addition to “Extend Selection” + backspace, you can also simply “backspace”; With paredit (what I use) it always does the right thing (at least from my perspective); But I agree coming from another language it can be tempting to hold Shift + arrow keys to select portions of the code; Just don’t 🙂 It can take a few weeks to break that muscle memory; I’ve forgotten those times so much that now it’s super hard to code without at least “Extend Selection” in another language; For example, XCode doesn’t have “Extend Selection”, so if I have to write Swift, I use AppCode (by IntelliJ) and use Extend Selection, copy/paste/delete all the time (since there’s no easy+proper structural movement).