I have a syntax error due to copy+paste creating mismatched parens. paredit won't allow me to fix it! It blocks me from either adding an extra one or deleting the other. Is paredit supposed to prevent fixing mismatched parens?
Its not meant to correct copy/paste errors. That's the job of the human that did the copy/paste incorrectly 🤣 Either undo the copy paste or switch off the structured editing tool and manually fix.
sometimes I switch to parinfer just to paste code and then back to paredit
As Dave, I do more copy and pasting, 1. Select a paren containing the thing I want 2. M-x expand-region 3. Kill (cut) 4. Undo the paste containing the mismatching parens 5. Yank (paste)
I feel like there should be some logic that if the parens are already mis-matched it doesn't block editing.
I use smartparens instead of paredit these days, but IIRC it's C-q ) to add a closing one, and when deleting you need to use C-u. But I know some prefer just to turn paredit off and back on again instead.
(Apologies if I'm misremembering the specific keys)
Yes, C-q allows literal character insert, so you're able to insert missing parens. C-<backspace> also lets you delete them 😊
Personally I fix copy-paste errors with copy-paste.
For obvious unballanced code, I may use Evil (vim-style) editing mode 6 visual select to fix copy/paste errors,
v r <space> to visually select the paren and replace it with a blank space (my editor removes blank spaces on save)
Or select a blank space and replace with a paren, e.g. v r )
If its no obvious if the code being copied is balanced, then I would paste it into a new Clojure file (or at least a rich comment form at the end of a file) This avoids messing up any other code. Or just avoid copy / pasting code 🤣