From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: CC Mode - syntactical can of worms. Date: Thu, 31 Jan 2008 11:45:46 +0000 Message-ID: <20080131114546.GA2150@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1201779314 22948 80.91.229.12 (31 Jan 2008 11:35:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 31 Jan 2008 11:35:14 +0000 (UTC) To: emacs-devel@gnu.org, bug-cc-mode@gnu.org Original-X-From: cc-mode-help-bounces@lists.sourceforge.net Thu Jan 31 12:35:34 2008 Return-path: Envelope-to: sf-cc-mode-help@m.gmane.org Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by lo.gmane.org with esmtp (Exim 4.50) id 1JKXhd-0000gG-VP for sf-cc-mode-help@m.gmane.org; Thu, 31 Jan 2008 12:35:34 +0100 Original-Received: from sc8-sf-list1-new.sourceforge.net (sc8-sf-list1-new-b.sourceforge.net [10.3.1.93]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP id 67B7B12F80; Thu, 31 Jan 2008 03:35:06 -0800 (PST) Original-Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) id 1JKXh9-0006gx-NZ for cc-mode-help@lists.sourceforge.net; Thu, 31 Jan 2008 03:35:03 -0800 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by mail.sourceforge.net with esmtps (TLSv1:AES256-SHA:256) (Exim 4.44) id 1JKXh6-0004AC-Oo for cc-mode-help@lists.sourceforge.net; Thu, 31 Jan 2008 03:35:03 -0800 Original-Received: from mx10.gnu.org ([199.232.76.166]) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1JKXgx-0006Px-I3 for bug-cc-mode@gnu.org; Thu, 31 Jan 2008 06:34:51 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1JKXgu-00052F-7R for bug-cc-mode@gnu.org; Thu, 31 Jan 2008 06:34:51 -0500 Original-Received: from colin.muc.de ([193.149.48.1] 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 1JKXgt-00050v-Gi for bug-cc-mode@gnu.org; Thu, 31 Jan 2008 06:34:48 -0500 Original-Received: (qmail 60866 invoked by uid 3782); 31 Jan 2008 11:34:43 -0000 Original-Received: from acm.muc.de (p57AF5C2E.dip.t-dialin.net [87.175.92.46]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Thu, 31 Jan 2008 12:34:39 +0100 Original-Received: (qmail 2466 invoked by uid 1000); 31 Jan 2008 11:45:46 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 X-Spam-Score: 1.0 (+) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 1.0 FORGED_RCVD_HELO Received: contains a forged HELO X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.1.8 Precedence: list List-Id: "Bug reports, feature requests, and general talk about CC Mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: cc-mode-help-bounces@lists.sourceforge.net Errors-To: cc-mode-help-bounces@lists.sourceforge.net Xref: news.gmane.org gmane.emacs.cc-mode.general:5017 gmane.emacs.devel:87853 Archived-At: Hi, Emacs and CC Mode! Following up from: [orium69@gmail.com: Bug in emacs 22.1.1 (cosmetic bug)]. This bug was in C Mode, with the following source line: #warning for isn't a keyword here. This fouls up the fontification, because the syntactic fontification recognises the apostrophe as a string opener. It can get pretty bad - here is a syntactically correct C function: 1 #warning for isn't a keyword here. ( 2 //#warning for isnt a keyword here. 3 void foo (bar) 4 { 5 #error Brace yourself! } 6 printf ("Hello, world!\n") ; /* the famous one liner! */ 7 } The apostrophe in L1 fouls up the entire fontification. The pseudo brace in L5 spuriously matches the real one on L4. The brace on L7 mismatches the pseudo parenthesis on L1. The root of the problem is that CPP lines are allowed to mingle syntactically with ordinary lines. Somehow, CPP lines need to be "commented out" from the Emacs's syntactic routines. However, turning # and EOL into another pair of comment delimiters is NOT the Right Thing. I think I need a hook function somewhere (after-change, but before-font-lock, maybe) which should analyse the innards of CPP lines for unbalanced string quotes or unbalanced parens/braces/brackets, or the like. It feels like another syntax category is wanted for such things, a kind of "open-enclosure / close-enclosure (or close-enopener? ;-)" pair, whose purpose is syntactically to isolate its contents from the rest of the file. Would anybody like to give me any ideas here? -- Alan Mackenzie (Nuremberg, Germany). ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/