Occasionally I yank code into a paredit-mode
buffer that is missing a closing parenthesis or bracket. paredit-mode
then detects the unclosed expression and tries to add the missing paren in the wrong place. This is frustrating when I move the cursor to the point where I want the close paren but I can't put it there. I end up having to switch off paredit-mode
.
Here's an example:
I've just yanked
[["https://github.com/aconbere/yesql.git"
"aea69ebd4a7788a66fc8689fea7e806f1463c347"]
but paredit-mode
sees a missing )
at the very end (in red). I'm not even sure why it wants to use a close parens when the opening is a bracket. Typing ]
at the point makes the cursor jump to the end and try to fill in the red paren. Slurping or barfing don't have the intended effects and simply move the )
around.
Is there any way to fix this without temporarily disabling paredit-mode
?
kill-region
(bound by default to C-w
) and quoted-insert
(bound by default to C-q
) are unaffected by paredit mode. You can delete regions or insert matching delimiters using these keybindings, bypassing paredit rules. Remember that you can also turn off paredit, clean something up, and then turn it back on again.