From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#40421: 26.2; (And 27.0.90) Inconsistent fontifying in c-mode Date: Mon, 13 Apr 2020 18:32:57 +0000 Message-ID: <20200413183257.GB5898@ACM> References: <87369k9hwx.fsf@pointsman.de> <20200404090919.52048.qmail@mail.muc.de> <87wo6o88qj.fsf@pointsman.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="11776"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 40421@debbugs.gnu.org To: Rolf Ade Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 13 20:34:18 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jO3uS-0002ud-Qs for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Apr 2020 20:34:16 +0200 Original-Received: from localhost ([::1]:47606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jO3uR-0001Ne-Qg for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Apr 2020 14:34:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50231) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jO3uG-0001NK-A5 for bug-gnu-emacs@gnu.org; Mon, 13 Apr 2020 14:34:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jO3uE-0001UF-Um for bug-gnu-emacs@gnu.org; Mon, 13 Apr 2020 14:34:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jO3uD-0001Tg-V9 for bug-gnu-emacs@gnu.org; Mon, 13 Apr 2020 14:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jO3uD-000454-Ri for bug-gnu-emacs@gnu.org; Mon, 13 Apr 2020 14:34:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Apr 2020 18:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40421 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 40421-submit@debbugs.gnu.org id=B40421.158680278415610 (code B ref 40421); Mon, 13 Apr 2020 18:34:01 +0000 Original-Received: (at 40421) by debbugs.gnu.org; 13 Apr 2020 18:33:04 +0000 Original-Received: from localhost ([127.0.0.1]:60766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jO3tI-00043i-Fq for submit@debbugs.gnu.org; Mon, 13 Apr 2020 14:33:04 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:10121 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1jO3tF-00043H-Tp for 40421@debbugs.gnu.org; Mon, 13 Apr 2020 14:33:02 -0400 Original-Received: (qmail 92973 invoked by uid 3782); 13 Apr 2020 18:33:00 -0000 Original-Received: from acm.muc.de (p4FE15D33.dip0.t-ipconnect.de [79.225.93.51]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Mon, 13 Apr 2020 20:32:58 +0200 Original-Received: (qmail 15359 invoked by uid 1000); 13 Apr 2020 18:32:57 -0000 Content-Disposition: inline In-Reply-To: <87wo6o88qj.fsf@pointsman.de> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:178325 Archived-At: Hello, Rolf On Fri, Apr 10, 2020 at 02:50:12 +0200, Rolf Ade wrote: > Hello Alan, > Alan Mackenzie writes: > > In article you wrote: > >> Recipt: > >> emacs -Q > >> Insert: > >> /* 11 */ > >> EXTERN int XML_GetCurrentByteCount(XML_Parser parser); > >> /* 12 */ > >> EXTERN enum XML_Status XML_SetBase(XML_Parser parser, const XML_Char *base); > >> /* 13 */ > >> EXTERN const XML_Char * XML_GetBase(XML_Parser parser); > >> /* 14 */ > >> EXTERN int XML_GetSpecifiedAttributeCount(XML_Parser parser); > >> /* 15 */ > >> and M-x c-mode. The font-look seems randomly. Some EXTERN colered, some > >> not, some function names black, some blue. > > Yes. The problem here is that these declarations aren't syntactically > > correct C. To C Mode, "EXTERN" just looks like an ordinary identifier, > > not a macro which (presumably) expands to "extern". > To that, or, depending on the build evironment, to something similar, > yes. > I can understand, that c-mode doesn't get this right. But part of the > point was the apparent randomly switching of the fontification. Getting > the colors wrong is one thing (but c-mode don't even got it wrong, for > the first handful of function prototypes), but getting it wrong > inconstently irritates particularly. Sorry, I don't think I can offer anything constructive, here. Macro occurrences in text are difficult to handle well, since they can expand to anything at all (or nothing). Only if (?when) CC Mode starts doing deeper analysis of the code, something compiler-like, is there really any hope for anything better. > But, yes ... > > I would recommend you to use CC Mode's "noise macro" facility here. > > (See the CC Mode manual.) With this, you would tell CC Mode that > > "EXTERN" just "expands to nothing", and thus won't interfere with the > > syntactic analysis. One way to do this is to set c-noise-macro-names in > > a hook function, probably c-mode-common-hook. Another way (if you don't > > have many source files) would be to set that variable in a file local > > variables section (see the Emacs manual) - for example, put the > > following at the end of your C file: > > /* Local Variables: */ > > /* c-noise-macro-names: ("EXTERN") */ > > /* END: */ > > . Then restart C Mode with M-x c-mode. The fontification should now > > look OK. > ... that works well, thanks. Good! :-) > Sorry for the noise. Not a problem. I'll close the bug report (as notabug). Sorry I can't offer anything better. > >> The whole (small) file is here > >> http://tdom.org/index.html/raw/generic/tdomDecls.h?name=cccb9227. With > >> this syntactically correct file (at least gcc and clang consume it > >> without complain) there is similiar font-lock flicker around the lines > >> commented with 12, 13, 14. > > Thanks for taking the trouble to reduce the problem to a minimal test > > case. That's appreciated. > >> I report this (and see it) on my working-place emacs-26.2 but have > >> verified, that a freshly build emacs-27.0.90 shows the same behaviour. -- Alan Mackenzie (Nuremberg, Germany).