[From LotsofIrritatingSillyParentheses]
Out of interest, what editor do you guys use? I find LispLanguage syntax can be a pain when refactoring. When editing the last statement in a function it is easy to add or delete too many parentheses or but them in the wrong place. However, in general editing I don't find it a problem. I use XEmacs or DrScheme and both have parenthesis matching. If I can't see where my parentheses match it's a CodeSmell that a function is too large. -- NoelWelsh
I use the VimTextEditor. When e.g. adding another expression to a function or other implicit (begin ...), I go to the first opening parenthesis of the last form, then I press % to go to the matching closing parenthesis, then I press a, which will put me in insert mode right after the last expression. When deleting the last expression, I also go to the opening parenthesis and then do d%. Vim syntax highlighting will make it clear when parentheses are missing. Formatting the source with = will also indicate the problem. -- StephanHouben
I use GnuEmacs. I never have any parenthesis problems. I think the reason is that I do all my editing on s-expressions---never just on tokens. Extensive use of C-M-{u,n,f,b,k,t} means that you always yank and transpose delimited expressions. After than, M-q reindents the function, and your eye can immediately tell if anything moves "the wrong way". -- AlainPicard
Thanks Alain. I think that is the insight I've been missing. -- NoelWelsh
I use NotePad for most of my source editing, which explains why I write tools like Grayspace (see below). -- EdwardKiser
Many of the EmacsEditor commands are explicitly built to work with EssExpressions. These tend to be bound to the C-M-[] keymap. Thus forward-sexp, backward-sexp, kill-sexp, transpose-sexp, etc. These make editing Lisp almost completely automatic. Outsiders have a hard time believing that lisp programmers literally cannot see the parentheses anymore, but then, C programmers probably don't see the semi-colons any more (and they're a lot less regular!)
Well, the parentheses are clearly a feature. No experienced Lisp Hacker would want to live without them. Why? Because it makes editing source code so much easier.
Okay I give a hint what you could do with it.
Look at the following little and uninteresting code snippet: (expt (sin (sqr x)) x) . The whole thing is a Lisp expression and it has some nested subexpressions. So what are the parentheses doing there? They are grouping the expression(s). But as such they are a visual handle for the expression both at the beginning and the end of the expressions. So when you go there with your cursor you can use them to place direct manipulating editing commands there - especially when you use a mouse.
That is used by the LispMachine and for example Macintosh Common Lisp for a nice editing feature called 'mouse copy'. Let's explain the Macintosh Common Lisp version (which is way simpler than the Lisp Machine's sophisticated mouse support). Lisp programmers often like telling (long) names. As a typing aid, most Lisp development environments have a sophisticated completion facility.
I've actually developed two tools to deal with the parentheses in the SchemeLanguage:
What solutions are there for moving around lisp code? I've been programming java in eclipse, and have been finding the ability to walk through an api's source invaluable for learning about the api, implementation, dark corners of the language, etc; but I can't seem to find anything equivilant in lisp. I'm sure I'm missing something... I just don't know what.
Perhaps you want MetaPoint.
You mean for browsing code as HyperText? You can use tags tables in GNU Emacs. These are explained in http://www.gnu.org/manual/emacs/html_chapter/emacs_26.html#SEC334 Tags tables have been around for decades, first appearing in EmacsEditor on the IncompatibleTimeSharingSystem. They also work for other languages.
Incidentally, there is equivalent functionality in both ViEditor and NeditEditor?, though anyone who uses either for EditingLispCode deserves to lose. -- DonaldFisk
Another perspective on this matter (coming from a Smalltalk/XP/Forth viewpoint as well as the traditional Lisp viewpoint) would be that if you have trouble understanding what parentheses should go where, then you need to refactor your code. -- JosephDale
Also see ReadingLispCode.