Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you type lisp efficiently, with so many parentheses? [closed]

Tags:

I try to keep my fingers on home row as much as possible.

Typing all the parentheses makes me move away from there a fair bit.

I use Emacs; the parentheses themselves are no issue, I'm comfortable with them. And I don't like modes that type them for me automatically.

I've thought about remapping the square brackets to parentheses and vice versa. Is this a good idea? What does everyone else do?

like image 518
Chris Poole Avatar asked Dec 22 '08 17:12

Chris Poole


1 Answers

I would personally recommend the lethal combo of Emacs, SLIME & paredit.el Paredit allows you to pseudo-semantically edit the LISP code at sexp level, and that makes the parentheses disappear almost completely. You can move around sexps as if they are simple words and even mutate them with just a couple of key-strokes. There is also a minor mode called Redshank which works in conjunction with Paredit and that provides more power.

Consider simple these examples (| is the position of the cursor):

(foo bar (baz| quux) zot) + C-( => (foo (bar baz| quux) zot)
(foo (bar |baz) quux zot) + C-) => (foo (bar |baz quux) zot)

(foo (bar baz |quux) zot) + C-{ => (foo bar (baz |quux) zot)
(foo (bar |baz quux) zot) + C-} => (foo (bar |baz) quux zot)

I have done some serious Common Lisp programming in my time, and paredit has proved to be invaluable to me. I can't even think of writing non-trivial LISP code without my toolbox. And after all that's the way it should be; you should never have to count or match your parentheses... once you master Paredit, the parentheses will just disappear from in front of your eyes.

Remapping the [] to () will help, but you will stop caring much after you start using Paredit.

Feel free to use the LISP specific portions from my dot-emacs.

like image 88
Baishampayan Ghose Avatar answered Sep 23 '22 09:09

Baishampayan Ghose