简体   繁体   中英

How to delete extra parens in Paredit mode?

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 Ms . 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 Ms to reindent it. Conversely we can insert single paren using Cq ( or Cq } .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM