4 ms·
As an emacs user, one of the biggest contributors (other than SLIME method list prompts and the like) to my appreciation for Lisp is Paredit[1]. If you ever fi
by neutronicus 16y ago
As an emacs user, one of the biggest contributors (other than SLIME method list prompts and the like) to my appreciation for Lisp is Paredit[1]. If you ever find yourself frustrated with counting parentheses, this is the thing for you. Essentially, it only adds delimiters in pairs - so you never delete closing parenthese, and provides functions for (| indicates cursor location)-
1. 'slurp' the token on either side of a list
(|a b c) d -> (|a b c d)
a (|b c d) -> (a |b c d)
2. 'barf' elements from either side of list
(a |b c d) -> (a b c) d
(a |b c d) -> a (b c d)
3. 'drill down' into nearest list
(|a b c (d e f)) -> (a b c (|d e f))
4. 'break out' of current list
(a b c (d e |f)) -> (a b c |(d e f))
5. And more, like 'jump across next list', 'delete next list', etc.
Using any of these commands re-indents the code. It is the best method I have ever encountered in any language environment for doing 'code surgery' like placing existing code inside conditionals. I even use it for C (although it is not nearly as smart about C/C++ as it is about Lisp, so the benefit is not as great - c'est la vie. Perhaps one day I will attempt to hack decent C/C++ support into paredit). If I ever switch to vim, attempting to port paredit will be the first thing I do, and, if I fail, no switch.
Well, that got long. Too bad the original poster on the newsgoup will never see this.
[1] http://www.emacswiki.org/emacs/ParEdit http://www.emacswiki.org/emacs/ParEdit
[2] 'slurp' and 'barf' are the "official" terminologies, by the way
- ScottBurson 16y agoYes, this is the right way to edit Lisp. It gives most of the benefits of a structure editor without the downside. Balanced-delimiter editing makes Lisp actually easier to edit than any other language. (I've been editing Lisp this way since about 1980, when David Chapman and I implemented balanced-delimiter commands for Zmacs.) (BTW I'm sure Rob is aware of Paredit. He's been around comp.lang.lisp a long time.)
- neutronicus 16y agoBy, 'the original poster,' I meant the poster whose question Rob was answering. I guess that was unclear. I know he's a veteran!