質問

I'm using Paredit in Emacs to edit Lisp code. How do I delete an extra pair of parens that I accidentally inserted? Paredit does not allow this without extra commands.

((square 5)) into (square 5)

役に立ちましたか?

解決

This is called paredit-splice-sexp, keybinding is M-s. Take a look at the paredit cheat sheet here.

他のヒント

Read up on barfage and slurpage.

You can also installed "paredit-menu.el" which provides a menu of actions, with tooltips that show you their effects.

Paredit occasionally gets you into a situation when the easiest thing to do is to turn it off, fix everything and turn it on again. However, it is worth the effort.

If I realized accidental extra parens right after inserting those extra parens, I would invoke the undo command. If I saw the extra parens much later, then there are paredit commands for fixing it as other answers specified, but if I did not know those commands, then I would have put point somewhere within the inner form, and then typed the following, provided that CUA mode is on.

C-M-u C-M-SPC C-x <timeout> <left> C-M-SPC C-v

The paredit wont let us deleting parens while there is any elements inside. My trick is to cut the the right code and paste it to other place adjacent. It will leave the extra parens empty, then now I can delete it. Actually the right way is using M-s to reindent it. Conversely we can insert single paren using C-q ( or C-q }.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top