From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Fernando Dobladez Newsgroups: gmane.emacs.help Subject: Re: command help : matching braces Date: Mon, 08 Apr 2002 14:07:42 -0500 Sender: help-gnu-emacs-admin@gnu.org Message-ID: <3CB1EA7E.3040804@fuego.com> References: <578F3C8F6DD3D411850600508BF320CAD014D6@aries-exch1.uk.eu.corp.vizzavi.net> <3CB1CE5F.9020604@fuego.com> <00c001c1df21$e26e9fa0$8f31d49f@HL7C711> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1018293172 24016 127.0.0.1 (8 Apr 2002 19:12:52 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 8 Apr 2002 19:12:52 +0000 (UTC) Cc: "Ambardekar, Shailesh" , help-gnu-emacs@gnu.org Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16ueZQ-0006FF-00 for ; Mon, 08 Apr 2002 21:12:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16ueYk-0007Si-00; Mon, 08 Apr 2002 15:12:10 -0400 Original-Received: from [65.201.108.41] (helo=saturn.fuegotech.com) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16ueXH-0007IZ-00 for ; Mon, 08 Apr 2002 15:10:39 -0400 Original-Received: from fuego.com ([192.168.0.224]) by saturn.fuegotech.com with Microsoft SMTPSVC(5.0.2195.4453); Mon, 8 Apr 2002 14:10:37 -0500 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020311 X-Accept-Language: en-us, en Original-To: "Matthew O. Smith" X-OriginalArrivalTime: 08 Apr 2002 19:10:37.0511 (UTC) FILETIME=[11066D70:01C1DF31] Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:65 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:65 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 " > (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" >To: "Ambardekar, Shailesh" >Cc: >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 >> > >