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 Cw
) and quoted-insert
(bound by default to Cq
) 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.
Others have already mentioned Cq
for quoted-insert. You can also use Cu DEL
or Cu Cd
to override paredit's normal balanced behavior of DEL
and Cd
for a single deletion:
(foo)|)
Cu DEL (foo|)
Trust me. By far the easiest is to paste a bracket or parentheses.
You can do:
; ]
and then copy it
When you have unbalanced parenthesis, navigate to the character position you wish to place the balancing parenthesis, issue Mx quoted-insert
(bound by default to Cq
), and then enter the balancing parenthesis. quoted-insert
will not prevent parenthesis from being issued.
Same idea as noisesmith said differently. Turning paredit on and off is not an option :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.