home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.help
- Path: sparky!uunet!pipex!demon!edscom.demon.co.uk!kevin
- From: kevin@edscom.demon.co.uk (Kevin Broadey)
- Subject: Re: Matching Parenthesis
- In-Reply-To: anand@cbnewsb.cb.att.com's message of Thu, 13 Aug 1992 22:28:11 GMT
- Message-ID: <KEVIN.92Aug14095203@buffalobill.edscom.demon.co.uk>
- Sender: kevin@edscom.demon.co.uk (Kevin Broadey)
- Organization: EDS-Scicon, Milton Keynes, UK
- References: <1992Aug13.222811.12442@cbfsb.cb.att.com>
- Distribution: usa
- Date: Fri, 14 Aug 1992 09:52:03 GMT
- Lines: 26
-
- In article <1992Aug13.222811.12442@cbfsb.cb.att.com> anand@cbnewsb.cb.att.com (anand.r.setlur) writes:
-
- Can someone give me a method in emacs to achieve the equivalent of vi's
- "%" command that helps match parenthesis in a given file.
-
-
- I use:-
-
- (defun match-paren ()
- "Go to the matching parenthesis."
- (interactive)
- (cond ((looking-at "[\(\[\{]")
- (forward-sexp 1)
- (backward-char))
- ((looking-at "[\]\)\}]")
- (forward-char)
- (backward-sexp 1))
- (t (error "No paren to match"))))
-
- I know the backslashes aren't necessary, but I think it makes the expression
- clearer. If you disagree, take them out!
- --
- Kevin Broadey, EDS-Scicon
- Mail: Wavendon Tower, Wavendon, Milton Keynes, MK17 8LX, England
- E-mail: kbroadey@edscom.demon.co.uk
- Phone: +44 908 284198 or +44 908 585858 ext 4198
-