help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: catching parenthesis errors in elisp


From: Tim X
Subject: Re: catching parenthesis errors in elisp
Date: Fri, 12 Jun 2009 20:18:38 +1000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux)

rustom <rustompmody@gmail.com> writes:

> Im hacking on a 700 line elisp function.
> While doing some (fairly mechanical) cut-paste operations it looks
> like either Ive got a parenthesis or a quote (most likely double quote
> but could also be single quote) error.
>
> Any suggestions on how to catch such errors?

Have a look at occur and make sure you are using paren matching mode.

For lisp, I'd also suggest looking at paredit mode. It is a mode that is
very handy for editing lisp like languages. It has commands for
manipulating the text as sexps, puts in matching () etc. Takes a little
to get use to it, but once you are, it makes editing lisp like languages
really fast an efficient. 

Personally, I'd also be breaking up the function - 700 lines in one
function is a little excessive IMO. Apart from making it harder to find
simple syntax errors, it makes it harder to hold the whole thing in your
head conceptually and probably has lots of repetition (your reference to
cut and paste makes me suspect there is too much repetition. Try to
follow the D.R.Y. mantra (Don't repeat yourself). 

My basic approach with lisp like languages is to write small functions,
get them working in the repl and once I'm happy with them, put them into
the source file. If I can't see the whole function in one screen, it
usually means its time to break it down into smaller functions. If I can
see lots of similar constructs in a function, then its almost certainly
a sign its time to break the similar bits outinto its own function. 

HTH

Tim





-- 
tcross (at) rapttech dot com dot au


reply via email to

[Prev in Thread] Current Thread [Next in Thread]