home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!airgun!airgun.wg.waii.com!jct
- From: jct@se33.wg2.waii.com (Jim Thompson)
- Newsgroups: gnu.emacs.help
- Subject: Re: Matching Parenthesis
- Message-ID: <JCT.92Aug16090848@se33.wg2.waii.com>
- Date: 16 Aug 92 13:08:48 GMT
- References: <1992Aug13.222811.12442@cbfsb.cb.att.com>
- Sender: news@airgun.wg.waii.com
- Distribution: usa
- Organization: Western Geophysical Exploration Products
- Lines: 25
- Nntp-Posting-Host: se33.wg2.waii.com
- In-reply-to: anand@cbnewsb.cb.att.com's message of 13 Aug 92 22:28:11 GMT
-
- 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.
-
- Someone posted this to comp.emacs a few months ago; sorry, but I don't
- remember who. It works as follows: if you're over a paren-type
- character and you type '%', it will jump you to the matching character
- (if there is one). If you're not over a paren-type character, it
- inserts a '%' as normal:
-
- (global-set-key "%" 'match-paren)
-
- (defun match-paren (arg)
- "Go to the matching parenthesis if on parenthesis otherwise insert %."
- (interactive "p")
- (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
- ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
- (t (self-insert-command (or arg 1)))))
-
- --
- _ Jim Thompson | Wanted:
- _| ~- thompson@wg2.waii.com | Nick Park's "Grand Day Out"
- \, _} Western Geophysical | on VHS-format videotape
- \( Houston, Texas | Email me if you know where I can buy it.
-