From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#50640: 28.0.50; incorrect highlighting in C++ mode Date: Sat, 25 Sep 2021 21:17:06 +0000 Message-ID: References: <87czp79x6s.fsf@vinc17.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35639"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 50640@debbugs.gnu.org To: Stefan Kangas , Vincent Lefevre Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 25 23:18:14 2021 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 1mUF3l-00093U-PQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Sep 2021 23:18:13 +0200 Original-Received: from localhost ([::1]:51728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUF3k-0004r5-0f for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Sep 2021 17:18:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUF3a-0004qv-T1 for bug-gnu-emacs@gnu.org; Sat, 25 Sep 2021 17:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUF3a-0000tj-Lt for bug-gnu-emacs@gnu.org; Sat, 25 Sep 2021 17:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mUF3a-0000gm-IL for bug-gnu-emacs@gnu.org; Sat, 25 Sep 2021 17:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Sep 2021 21:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50640 X-GNU-PR-Package: emacs Original-Received: via spool by 50640-submit@debbugs.gnu.org id=B50640.16326046371208 (code B ref 50640); Sat, 25 Sep 2021 21:18:02 +0000 Original-Received: (at 50640) by debbugs.gnu.org; 25 Sep 2021 21:17:17 +0000 Original-Received: from localhost ([127.0.0.1]:34931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUF2r-0000J8-0x for submit@debbugs.gnu.org; Sat, 25 Sep 2021 17:17:17 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:23597 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1mUF2o-0000CM-AM for 50640@debbugs.gnu.org; Sat, 25 Sep 2021 17:17:15 -0400 Original-Received: (qmail 85445 invoked by uid 3782); 25 Sep 2021 21:17:07 -0000 Original-Received: from acm.muc.de (p2e5d55d2.dip0.t-ipconnect.de [46.93.85.210]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 25 Sep 2021 23:17:07 +0200 Original-Received: (qmail 7856 invoked by uid 1000); 25 Sep 2021 21:17:06 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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:215527 Archived-At: Hello, Vincent and Stefan. On Sat, Sep 25, 2021 at 11:17:07 -0700, Stefan Kangas wrote: > Vincent Lefevre writes: > > Consider a test.cc file containing: > > if (xMin - xt < t3Font->glyphX || > > yMin - yt < t3Font->glyphY || > > xMax - xt > t3Font->glyphX + t3Font->glyphW || > > yMax - yt > t3Font->glyphY + t3Font->glyphH) { > > } > > (this comes from the xpdf source) and open it with "emacs -Q". > > The first two "xt" and "yt" are highlighted in green instead of > > remaining in black. Yes. C++ Mode is recognising the < .. < .. > .. > as two nested templates. The green is font-lock-type-face. :-( > > If I remove the last condition as follows and reopen the file: > > if (xMin - xt < t3Font->glyphX || > > yMin - yt < t3Font->glyphY || > > xMax - xt > t3Font->glyphX + t3Font->glyphW) { > > } > > then only the "yt" is highlighted incorrectly. Yes, then only yt opens a "template", there being no closing > to balance the xt <. There's really not much which can be done about this in CC Mode, sorry. CC Mode's analysis of ambiguous C++ constructs is not very deep, so it sometimes gets it wrong, as here. I would be in favour of closing this bug as "won't fix" (actually, can't fix). There's an intention in the medium future to introduce rigorous analyses of source code into Emacs with a language server protocol program called "Tree Sitter". That should solve problems like this one. In the meantime, a workaround would be to change the order of the terms in that expression so that the s rather than before them, if you have control of the source code. > Alan, could you take a look at this bug report? > (I don't know if you're subscribed to the bug list, my apologies if you > have already seen it.) I'm not actually subscribed to the bug list. I'd have trouble coping with the volume of posts there. I try to skim over the archive on the web every week or so, to try not to miss anything. So thanks, Stefan, for the heads up! -- Alan Mackenzie (Nuremberg, Germany).