barf and slurp with paredit

Posted by Aaron Feng Mon, 24 Mar 2008 00:58:00 GMT

If you are not barfing and slurping with paredit while you are editing your Lisp code in Emacs, you are missing out. You need to read on.

One of the biggest complaints for beginner Lispers (like myself) is the overwhelming parentheses. After working with Lisp code for a couple of weeks, the parens do disappear. However, you still have to match up the parens even if you don't see them any more. This is where paredit comes in. Paredit will manage all the parens for you, so you never have deal with dangling parens again. It feels annoying at first because it will not allow you to delete a closing paren without removing the opening one. Just like anything else, if you can get over that, it can be quiet useful.

Two of my favorite features are barf and slurp. They are best explained with examples.

; starting with the following sexp

(x (y) (z))

; barf forward...

(x (y)) (z)

; barf forward...

(x) (y) (z)

; slurp forward...

(x (y)) (z)

; slurp forward...

(x (y) (z))

; barf backward...

x ((y) (z))

; barf backward...

x (y) ((z))

; slurp backward...

x ((y) (z))

; slurp backward...

(x (y) (z))

You get the point. There are many more features to paredit besides barf and slurp. If you are interested in learning barfing, slurping and other delicious paredit features, check out this link.

Comments

Leave a response

Comments