From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Arjan Bos Newsgroups: gmane.emacs.help Subject: Re: parens matching not matching all matching parens Date: Fri, 17 Sep 2004 19:29:34 +0200 Organization: Planet Internet Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: Reply-To: Arjan.Bos@ISeeYou.nl NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1095442473 10826 80.91.229.6 (17 Sep 2004 17:34:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 17 Sep 2004 17:34:33 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 17 19:34:23 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1C8Mcp-0004BX-00 for ; Fri, 17 Sep 2004 19:34:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C8MiY-0001AY-RH for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Sep 2004 13:40:18 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!proxad.net!fr.ip.ndsoftware.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeeder.wxs.nl!textnews.wxs.nl!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 79 Original-NNTP-Posting-Host: ip51cc04e5.adsl-surfen.hetnet.nl Original-X-Trace: reader13.wxs.nl 1095442175 20152 81.204.4.229 (17 Sep 2004 17:29:35 GMT) Original-X-Complaints-To: abuse@planet.nl Original-NNTP-Posting-Date: 17 Sep 2004 17:29:35 GMT User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en In-Reply-To: Original-Xref: shelby.stanford.edu gnu.emacs.help:125382 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:20737 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:20737 Greg Hill wrote: > At 9:19 PM +0200 9/16/04, Arjan Bos wrote: > >> Hi all, >> >> I'm currently developing yet another rich text format writer. And as >> you might know, RTF is using curly braces a lot. Alas, every now and >> then, a normal parentheses pops up between a set of matching {}. Both >> the parens matching colouring and the forward-sexp / backward-sexp >> can't handle this. How can I (help to) solve this? >> >> An rtf snippet is included here: > >> {\rtf1\mac\ansicpg10000\uc1 >> {\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}} > >> >> This is a complete piece of (non-sensical, but correct) rtf. The first >> `{' matches the last `}'. Only C-M-f jumps from the first `{' to the >> one-to-last `}'. > >> >> I'm wondering if this is a bug or not. >> >> TIA, > >> Arjan > > > Arjan, > > Personally, I would call it a bug in the 'scan-sexps built-in function, > which is called by 'forward-sexp, which is normally bound to "C-M-f". > For some reason 'scan-sexps seems to treat a ")" as matching a "{". You > might want to submit a bug report, but there is no guanentee the > maintainers of Emacs will not call that odd behavior a "feature." Thanks, I'll submit a bug. > > On the other hand, if you just want to get on with life, you can try > putting something like the following code in your .emacs file. The > 'defun defines a function that scans forward for the first '(', '[', '<' > or '{' following point, whatever it see first, then scans for a matching > closing character, ignoring any other characters. The '(setq > forward-sexp-function... effectively replaces the guts of 'forward-sexp > with the new function, so you will not have to rebind your keystroke. > It works in the backward direction as well ("C-M-b"). > > I should warn you, by the way, that I just hacked this code together in > a few minutes after work tonight, and have not tested it exhuastively. > Let me know if you have any questions or problems. Greg, I already had something similar. Looking at the current bracket under point, finding its opposite and start counting the brackets you encounter. Another of the same bracket ups the ante, the opposite pops one from the ante. When the ante is empty, all bets are off, and the bracket is found. My code isn't perfect, so I will borrow heavily from yours. Thanks! > > --Greg -- -- If you really want to contact me, then replace the "I see you" text by its three letter accronym, ICU. Fabricate Diem PVNC, Motto of the Night Watch -- Terry Pratchett