unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Fernando Dobladez <ferd@fuego.com>
Cc: "Ambardekar, Shailesh" <Shailesh.Ambardekar@corp.vizzavi.net>,
	 help-gnu-emacs@gnu.org
Subject: Re: command help : matching braces
Date: Mon, 08 Apr 2002 14:07:42 -0500	[thread overview]
Message-ID: <3CB1EA7E.3040804@fuego.com> (raw)
In-Reply-To: 00c001c1df21$e26e9fa0$8f31d49f@HL7C711

It shouldn't be necessary. Actually the special \s( and \s) in a regular 
expresion matches any opening/closing "parenthesis" (generic meaning) 
character. This meaning depends on the current mode. From the elisp 
manual: "In English text, and in C code, the parenthesis pairs are 
`()',     `[]', and `{}'.  In Emacs Lisp, the delimiters for lists and 
vectors (`()' and `[]') are classified as parenthesis characters."

Fernando.


Matthew O. Smith wrote:

>Hi,
>
>I added curly brace matching as well.
>Thanks.
>
>(defun match-paren (arg)
>  "Go to the matching parenthesis if on parenthesis, otherwise insert %.
>(Like in VI editor).  Thanks Fernando Dobladez <ferd@fuego.com>"
>  (interactive "p")
>  (cond
>   ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
>   ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
>   ((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)))))
>
>
>----- Original Message -----
>From: "Fernando Dobladez" <ferd@fuego.com>
>To: "Ambardekar, Shailesh" <Shailesh.Ambardekar@corp.vizzavi.net>
>Cc: <help-gnu-emacs@gnu.org>
>Sent: Monday, April 08, 2002 11:07 AM
>Subject: Re: command help : matching braces
>
>
>>If you miss VI's % too much, you'd probably like to include the
>>following in your .emacs:
>>
>>(defun match-paren (arg)
>>  "Go to the matching parenthesis if on parenthesis, otherwise insert %.
>>(Like in VI editor)"
>>  (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)))))
>>
>>(global-set-key "%"                  'match-paren)
>>
>>
>>That will make the '%' go to the matching brace if the cursor is on a
>>brace, and it will insert "%" otherwise.
>>
>>Fernando.
>>
>>
>>Ambardekar, Shailesh wrote:
>>
>>>In gnu emacs 20.3.1 under Sun Solaris 2.6,
>>>what is the emacs command for going to the matching brace ?
>>>( looking for emacs equivalent of % vi command ).
>>>
>>>Thanks in advance.
>>>
>>>Shailesh
>>>
>>>
>>
>>
>>_______________________________________________
>>Help-gnu-emacs mailing list
>>Help-gnu-emacs@gnu.org
>>http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
>>
>
>

      reply	other threads:[~2002-04-08 19:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-04 16:15 command help : matching braces Ambardekar, Shailesh
2002-04-04 18:17 ` Chuck Siska
2002-04-05  5:45 ` Gurucharan
2002-04-08 17:07 ` Fernando Dobladez
2002-04-08 17:21   ` Matthew O. Smith
2002-04-08 19:07     ` Fernando Dobladez [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3CB1EA7E.3040804@fuego.com \
    --to=ferd@fuego.com \
    --cc=Shailesh.Ambardekar@corp.vizzavi.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).