From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Martin Stjernholm Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.bugs Subject: Re: [sigra@home.se: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows] Date: Sat, 19 Feb 2005 01:03:32 +0100 Message-ID: <5bvf8p4drf.fsf@lister.roxen.com> References: Reply-To: bug-cc-mode@gnu.org NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1108771557 6317 80.91.229.2 (19 Feb 2005 00:05:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 19 Feb 2005 00:05:57 +0000 (UTC) Cc: bug-cc-mode@gnu.org, bug-gnu-emacs@gnu.org, rms@gnu.org Original-X-From: cc-mode-help-admin@lists.sourceforge.net Sat Feb 19 01:05:56 2005 Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D2I85-0006D3-2p for sf-cc-mode-help@m.gmane.org; Sat, 19 Feb 2005 01:05:50 +0100 Original-Received: from projects.sourceforge.net (sc8-sf-list1-b.sourceforge.net [10.3.1.7]) by sc8-sf-spam1.sourceforge.net (Postfix) with ESMTP id D5B0089764; Fri, 18 Feb 2005 16:08:19 -0800 (PST) Original-Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.11] helo=sc8-sf-mx1.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1D2IA5-00050E-C3 for cc-mode-help@lists.sourceforge.net; Fri, 18 Feb 2005 16:07:53 -0800 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by sc8-sf-mx1.sourceforge.net with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.41) id 1D2IA4-00006p-8X for cc-mode-help@lists.sourceforge.net; Fri, 18 Feb 2005 16:07:53 -0800 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.34) id 1D2I9u-0000dC-1l for bug-cc-mode@gnu.org; Fri, 18 Feb 2005 19:07:42 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1D2I60-0005aH-Bj for bug-cc-mode@gnu.org; Fri, 18 Feb 2005 19:03:40 -0500 Original-Received: from [212.247.28.43] (helo=mail.roxen.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D2I5z-0005a5-QH; Fri, 18 Feb 2005 19:03:40 -0500 Original-Received: by mail.roxen.com (Postfix, from userid 52) id 5640599B8; Sat, 19 Feb 2005 01:03:37 +0100 (MET) Original-Received: from localhost (localhost [127.0.0.1]) by mail.roxen.com (Postfix) with ESMTP id D461D99FC; Sat, 19 Feb 2005 01:03:34 +0100 (MET) Original-Received: from lister.roxen.com (lister.roxen.com [212.247.28.136]) by mail.roxen.com (Postfix) with ESMTP id 531F899B8; Sat, 19 Feb 2005 01:03:33 +0100 (MET) Original-Received: from mast by lister.roxen.com with local (Exim 3.36 #1 (Debian)) id 1D2I5t-0003nI-00; Sat, 19 Feb 2005 01:03:33 +0100 Original-To: Erik In-Reply-To: (Richard Stallman's message of "Fri, 21 Jan 2005 21:53:42 -0500") User-Agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/20.7 (gnu/linux) X-Virus-Scanned: by amavisd 0.1 X-Spam-Status: No, hits=-2.5 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,RCVD_IN_ORBS, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) X-Spam-Score: 1.5 (+) 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.4 ADDRESS_IN_SUBJECT To: address appears in Subject 0.0 SF_CHICKENPOX_PARATHESES_OPEN BODY: Text interparsed with ( 0.0 SF_CHICKENPOX_PERIOD BODY: Text interparsed with . 0.0 SF_CHICKENPOX_MINUS BODY: Text interparsed with - 0.0 SF_CHICKENPOX_AT BODY: Text interparsed with @ 0.0 SF_CHICKENPOX_APOSTROPHE BODY: Text interparsed with ' Original-Sender: cc-mode-help-admin@lists.sourceforge.net Errors-To: cc-mode-help-admin@lists.sourceforge.net X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.0.9-sf.net Precedence: bulk List-Unsubscribe: , List-Id: Bug reports, feature requests, and general talk about CC Mode. List-Post: List-Help: List-Subscribe: , List-Archive: X-Original-Date: Sat, 19 Feb 2005 01:03:32 +0100 X-MailScanner-From: cc-mode-help-admin@lists.sourceforge.net X-MailScanner-To: sf-cc-mode-help@m.gmane.org Xref: main.gmane.org gmane.emacs.cc-mode.general:2237 gmane.emacs.bugs:10762 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:10762 Richard Stallman wrote: > Would you please fix this, if it is still broken in the current > sources? > > From: Erik > Subject: C++-mode: Syntax highlighting: wrong color for function identifier > depending on the kind of whitespace that follows > To: bug-gnu-emacs@gnu.org > Date: Fri Jan 21 18:44:19 2005 +0100 > > In GNU Emacs 21.3.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) If I'm not mistaken, that version contains CC Mode 5.28, which is before CC Mode took over the font locking responsibility. Still, the situation is the same in 5.30, so I'll address the problem anyway, but my discussion will be in the context of 5.30 and not 5.28. > In C++-mode, type: > void function(int x); > > The string "function" is blue, which is correct. Now type: > void function (int x); > > The color is still correct. But type: > void function > (int x); > > The color is suddenly yellow. This is clearly a bug. I assume yellow is the color you have for font-lock-variable-name-face. As I understand this, you type in your examples sequentially. I.e. at one time the buffer contains the single line void function and then you add a newline and continue to type "(int x)". If so, the bug, or rather misfeature, is in the font-lock package: By design, it only refontifies the current line on the fly. When you're leaving the first line, CC Mode is only acting on the information given by the incomplete declaration "void function", which it prefers to recognize as a variable declaration. It's first when you enter the "(" on the second line that it can correct that analysis. But then font-lock no longer requests refontification of the line containing the function name. Both the font-lock package and CC Mode could be improved in this regard, but in general it's very tricky to know whether a change affects the meaning of some code further back in the buffer. To be really correct, the whole buffer down to the point should be considered for refontification for every change in the buffer. Needless to say that would get much too slow very quickly. In the cvs version of Emacs, the font-lock package has a new variable `font-lock-multiline'. It doesn't appear to make a difference in this case. > /.../ The color of function identifiers should always be the same, > and not depend on what kind of whitespace follows it. Indeed, and the font lock patterns installed by CC Mode do consider all syntactic whitespace the same, regardless of amount of newlines, comments and preprocessor directives in it. But it's necessary to fontify the whole region at once to get that into play. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click