Article View: gnu.emacs.bug
Article #98751Elisp question:how do I move over UNbalanced sexps for syntax checking
From: share!MBParker%zardoz.uucp
Date: Fri, 05 Apr 1991 00:01
Date: Fri, 05 Apr 1991 00:01
26 lines
1981 bytes
1981 bytes
(Please forward this elisp question if it is misdirected.)
I'd like to write an elisp function which would check to see if the sexp
following the point is correctly balanced, and if not, locate the error.
Often you have an improperly balanced sexp which is hard to find (but can
seriously mess up TeX, my current delema). For instance:
{ lots of text ( } lots of text }
Note in the middle, the opening "(" doesn't match closing "}". Only when you
actually type the inner "}" does emacs warn you "Mismatched parenthesis".
otherwise emacs will forward-sexp and backward-sexp over these two sexp without
warning you of the mismatch (try it).
So I want to write an elisp function which detects such mismatches (but emacs
should probably have such a function built in, since this error can be common).
To write such a function, I need to be able to search to the first opening OR
closing open parenthesis class syntax character, possibly ignoring comments.
Unfortunately, the only function that seems to come close, parse-partial-sexp,
only stops for open parenthesis class syntax, not close parenthesis class. And
every other sexp movement moves only over balanced sexps.
So how do I do this?
Thanks for your help, -Mike Parker
Technical Details
Message-ID:
<9104040450.AA01877@.share.>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!snorkelwacker.mit.edu!stanford.edu!agate!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbageShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,a4ec3e9b1a25bb2,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-04-05 12:54:18 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!snorkelwacker.mit.edu!stanford.edu!agate!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbage From: share!MBParker%zardoz.uucp@ICS.UCI.EDU Newsgroups: gnu.emacs.bug Subject: Elisp question:how do I move over UNbalanced sexps for syntax checking Message-ID: <9104040450.AA01877@.share.> Date: 5 Apr 91 00:01:35 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 26 Approved: bug-gnu-emacs@prep.ai.mit.edu X-Unparsable-Date: Wed, 3 Apr 91 20:50:50 GMT-0800