From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: Problem with parenthesis matching and autoindentation in MacOS X version of emacs Date: Mon, 15 Dec 2008 18:39:05 +0000 Message-ID: <20081215183905.GB2765@muc.de> References: <49463d12$0$4789$9b536df3@news.fv.fi> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1229366068 30964 80.91.229.12 (15 Dec 2008 18:34:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Dec 2008 18:34:28 +0000 (UTC) Cc: Chong Yidong , help-gnu-emacs@gnu.org, Stefan Monnier To: Juha Nieminen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 15 19:35:32 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LCIHt-0006Mb-T6 for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Dec 2008 19:35:26 +0100 Original-Received: from localhost ([127.0.0.1]:51616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCIGi-0006Ft-0p for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Dec 2008 13:34:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LCI6q-0002C8-RN for help-gnu-emacs@gnu.org; Mon, 15 Dec 2008 13:24:01 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LCI6p-0002At-Un for help-gnu-emacs@gnu.org; Mon, 15 Dec 2008 13:24:00 -0500 Original-Received: from [199.232.76.173] (port=45608 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LCI6p-0002AX-MW for help-gnu-emacs@gnu.org; Mon, 15 Dec 2008 13:23:59 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:4448 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LCI6p-0002Ya-1M for help-gnu-emacs@gnu.org; Mon, 15 Dec 2008 13:23:59 -0500 Original-Received: (qmail 6603 invoked by uid 3782); 15 Dec 2008 18:23:52 -0000 Original-Received: from acm.muc.de (pD9E5115F.dip.t-dialin.net [217.229.17.95]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Mon, 15 Dec 2008 19:23:51 +0100 Original-Received: (qmail 11509 invoked by uid 1000); 15 Dec 2008 18:39:05 -0000 Content-Disposition: inline In-Reply-To: <49463d12$0$4789$9b536df3@news.fv.fi> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 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: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60632 Archived-At: Hi, Juha! On Mon, Dec 15, 2008 at 01:18:42PM +0200, Juha Nieminen wrote: > I'm using emacs in MacOS X, and it reports its version as: > GNU Emacs 22.1.50.1 (i386-apple-darwin8.10.1, Carbon Version 1.6.0) of > 2007-08-20 on macpro > It has an annoying problem/bug regarding parenthesis matching and > autoindentation. (These problems do not happen in the linux nor the > Windows versions.) For example if I write this code in C++ mode: > void foo() > { > if(x < 0 || x >= puzzleWidth || y < 0 || y >= puzzleHeight) > { > } > } > it will report a "Mismatched parenteses" at the parenthesis which ends > the if conditional, and after that it will autoindent the {} symbols > wrongly (as seen above). If I replace the above with this: > void foo() > { > const bool isOutside = > x < 0 || x >= puzzleWidth || y < 0 || y >= puzzleHeight; > if(isOutside) > { > } > } > then it will not report the mismatch, and will indent the {} properly. > Any idea what could be wrong? Yes. There're bugs in C++ Mode to do with template brackets (who on earth "designed" this feature in C++?). C++ Mode is probably marking your (newly typed) "<" and ">" as template delimiters, than unmarking the ">" as soon as it has become a ">=". In C++, it's impossible, in the general case, to distinguish < "less than" from < "open template", unless the thing doing the analysis is a compiler. C++ Mode tries to mark template delimiters as parentheses, but sometimes it gets it badly wrong. I've almost finished a fix for a problem here, which I'm hoping will be ready in time for Emacs 23. (Hi, Yidong and Stefan!). Please try your code snippets in C mode. There probably isn't a problem there. If there is, could you report it to bug-cc-mode@gnu.org, please. > (As said, this doesn't happen in linux nor Windows.) I suspect this isn't actually the case. Whether or not problems appear is highly dependent on the order you type the characters. Anyhow, I'm trying to fix the cause of the problem by always marking "<" and ">" as parens in matching pairs. Could you please check again, typing the EXACT SAME sequence of characters on the Mac and either GNU/Linux or Windows, whether you actually do get different results on different systems. Thanks in advance! -- Alan Mackenzie (Nuremberg, Germany).