From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: HELP, PLEASE! Syntax problem! Date: Wed, 25 Nov 2009 20:30:39 +0000 Message-ID: <20091125203039.GA4874@muc.de> References: <20091125125810.GA4734@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1259182478 27057 80.91.229.12 (25 Nov 2009 20:54:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Nov 2009 20:54:38 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 25 21:54:31 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NDOsY-0007Ku-9h for ged-emacs-devel@m.gmane.org; Wed, 25 Nov 2009 21:54:23 +0100 Original-Received: from localhost ([127.0.0.1]:60146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDOsX-0001lW-U0 for ged-emacs-devel@m.gmane.org; Wed, 25 Nov 2009 15:54:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDOQi-0005gR-Fa for emacs-devel@gnu.org; Wed, 25 Nov 2009 15:25:36 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDOQd-0005bC-LB for emacs-devel@gnu.org; Wed, 25 Nov 2009 15:25:35 -0500 Original-Received: from [199.232.76.173] (port=41756 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDOQd-0005b3-ED for emacs-devel@gnu.org; Wed, 25 Nov 2009 15:25:31 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:1241 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 1NDOQc-00025X-QT for emacs-devel@gnu.org; Wed, 25 Nov 2009 15:25:31 -0500 Original-Received: (qmail 40020 invoked by uid 3782); 25 Nov 2009 20:25:25 -0000 Original-Received: from acm.muc.de (pD9E51569.dip.t-dialin.net [217.229.21.105]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Wed, 25 Nov 2009 21:25:24 +0100 Original-Received: (qmail 5048 invoked by uid 1000); 25 Nov 2009 20:30:39 -0000 Content-Disposition: inline In-Reply-To: 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:117762 Archived-At: Hi, Stefan! On Wed, Nov 25, 2009 at 09:43:01AM -0500, Stefan Monnier wrote: > > In the following fragment of code: > > 1 int a = foo ( > > 2 1); > > 3 #define X(A, B) \ > > 4 do { \ > > 5 printf (A, B); \ > > 6 } while (0) > > 7 int a = foo ( > > 8 1); > > , there is a C macro between lines 3 and 6. The syntax-table > > properties here have been manipulated (see below). Putting point at > > the "(" in L5 and doing C-M-n takes point to after ")" ON LINE 8. > > Similar things happen with C-M-p, C-M-u from various places inside > > the macro > > Evidently, all syntactic properties inside the macro have been > > suppressed. This is not wanted. > The first problem is most likely that `syntax-table' is only special for > text-properties, not for char-properties in general (i.e. when placed > on an overlay, it has no effect). Ah. OK, that's a shame, but life is like that sometimes. I'd assumed that the special properties in text properties would be the same as in overlays (modulo any which are specific to the mechanism). > Of course, the real problem is that the syntax-table hacking you're > doing here is just that: a hack. We're hackers. ;-) > Maybe another hack would have fewer shortcomings? E.g. maybe you > could place a syntax-table property on the # that says "beginning of > comment" and a matching "end of comment" on the newline that > terminates line 6? Wow! That's one of these "why didn't I think of that?" ideas. It's much simpler and more effective than individually marking each paren/brace/bracket. But the thing to do is to set a category property value 'c-cpp-delimiter at the boundaries of each macro. All that I have to do now is to give that symbol the syntax-table property value "generic comment delimiter", and all these pesky parens vanish just like that, like switching a (n old fashioned tungsten) light bulb off. ;-) > Then again, our syntax-tables are too limited in their comment > handling, so given that CC already uses most forms of comments, it'll > be difficult to make sure that # only matches that particular comment > ender and not just "any \n" or "*/", but maybe just marking the "\\\n" > that get in the way as "punctuation" would solve it? One or two little things to sort out, and c-parse-state will run like greased lightning, like "this of a spade" (or something like that). To appreciate why I'm doing this, download and try scrolling around near EOB. :-( My fix to this problem speeds up scrolling speed by an order of magnitude in such ill-conditioned files. > Stefan -- Alan Mackenzie (Nuremberg, Germany).