home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / gnu / emacs / help / 3726 < prev    next >
Encoding:
Text File  |  1992-08-13  |  1.3 KB  |  40 lines

  1. Newsgroups: gnu.emacs.help
  2. Path: sparky!uunet!pipex!demon!edscom.demon.co.uk!kevin
  3. From: kevin@edscom.demon.co.uk (Kevin Broadey)
  4. Subject: Re: Matching Parenthesis
  5. In-Reply-To: anand@cbnewsb.cb.att.com's message of Thu, 13 Aug 1992 22:28:11 GMT
  6. Message-ID: <KEVIN.92Aug14095203@buffalobill.edscom.demon.co.uk>
  7. Sender: kevin@edscom.demon.co.uk (Kevin Broadey)
  8. Organization: EDS-Scicon, Milton Keynes, UK
  9. References: <1992Aug13.222811.12442@cbfsb.cb.att.com>
  10. Distribution: usa
  11. Date: Fri, 14 Aug 1992 09:52:03 GMT
  12. Lines: 26
  13.  
  14. In article <1992Aug13.222811.12442@cbfsb.cb.att.com> anand@cbnewsb.cb.att.com (anand.r.setlur) writes:
  15.  
  16.    Can someone give me a method in emacs to achieve the equivalent of vi's 
  17.    "%" command that helps match parenthesis in a given file.
  18.  
  19.  
  20. I use:-
  21.  
  22. (defun match-paren ()
  23.   "Go to the matching parenthesis."
  24.   (interactive)
  25.   (cond ((looking-at "[\(\[\{]")
  26.      (forward-sexp 1)
  27.      (backward-char))
  28.     ((looking-at "[\]\)\}]")
  29.      (forward-char)
  30.      (backward-sexp 1))
  31.     (t (error "No paren to match"))))
  32.  
  33. I know the backslashes aren't necessary, but I think it makes the expression
  34. clearer.  If you disagree, take them out!
  35. -- 
  36. Kevin Broadey, EDS-Scicon
  37. Mail:    Wavendon Tower, Wavendon, Milton Keynes, MK17 8LX, England
  38. E-mail: kbroadey@edscom.demon.co.uk
  39. Phone:    +44 908 284198 or +44 908 585858 ext 4198
  40.