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

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

Re: Tracing matching parentheses / braces


From: Roman Suzi
Subject: Re: Tracing matching parentheses / braces
Date: Tue, 13 Feb 2001 09:05:31 +0300 (MSK)

On Tue, 13 Feb 2001, Lord Emsworth wrote:

> Hi all,
> 
> Is there any way to trace a corresponding pair of braces / parentheses 
> in Emacs?
> 
> I know that when you type the ending parenthesis, Emacs shows the 
> matching opening parenthesis. But what about when the document to be 
> edited is already written out (say a pre-existing C++ file)? And what 
> does one do if one is at the opening brace and wants to find out the 
> matching closing brace?
> 

I have the following in .emacs:

(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)))))

When I press % over ( or ) I am going to the other paranthesis.
(This is slightly inconvenient if you must type   %(...) things often.)

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd@onego.ru -
 




reply via email to

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