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#18378: [Patch] wrong fontification of Java code Date: Sun, 23 Feb 2020 12:50:37 +0000 Message-ID: <20200223125037.GA10370@ACM> References: <87eevtq14x.fsf@marxist.se> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="112922"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Jordon Biondo , 18378-done@debbugs.gnu.org, Paul Pogonyshev To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 23 13:51:12 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 1j5qj2-000TIc-Ai for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Feb 2020 13:51:12 +0100 Original-Received: from localhost ([::1]:52354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j5qj1-00061x-Dd for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Feb 2020 07:51:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37170) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j5qit-0005xv-8Q for bug-gnu-emacs@gnu.org; Sun, 23 Feb 2020 07:51:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j5qis-0006gg-4A for bug-gnu-emacs@gnu.org; Sun, 23 Feb 2020 07:51:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j5qis-0006gZ-0D for bug-gnu-emacs@gnu.org; Sun, 23 Feb 2020 07:51:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j5qis-00005T-02 for bug-gnu-emacs@gnu.org; Sun, 23 Feb 2020 07:51:02 -0500 Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Feb 2020 12:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 18378 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 18378@debbugs.gnu.org, acm@muc.de, pogonyshev@gmail.com Original-Received: via spool by 18378-done@debbugs.gnu.org id=D18378.158246224332764 (code D ref 18378); Sun, 23 Feb 2020 12:51:01 +0000 Original-Received: (at 18378-done) by debbugs.gnu.org; 23 Feb 2020 12:50:43 +0000 Original-Received: from localhost ([127.0.0.1]:50512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j5qiY-0008WO-NG for submit@debbugs.gnu.org; Sun, 23 Feb 2020 07:50:42 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:52221 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1j5qiW-0008WE-B3 for 18378-done@debbugs.gnu.org; Sun, 23 Feb 2020 07:50:41 -0500 Original-Received: (qmail 4733 invoked by uid 3782); 23 Feb 2020 12:50:38 -0000 Original-Received: from acm.muc.de (p2E5D5A43.dip0.t-ipconnect.de [46.93.90.67]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 23 Feb 2020 13:50:37 +0100 Original-Received: (qmail 10392 invoked by uid 1000); 23 Feb 2020 12:50:37 -0000 Content-Disposition: inline In-Reply-To: <87eevtq14x.fsf@marxist.se> 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:176419 Archived-At: Hello, all. I've committed a fix to this bug to the emacs-27 branch at savannah. I'm closing the bug with this post. -- Alan Mackenzie (Nuremberg, Germany). On Mon, Jan 20, 2020 at 22:16:46 +0100, Stefan Kangas wrote: > Hi Alan, > Could you please help review the below patch for cc-fonts.el? > Thanks in advance. > Best regards, > Stefan Kangas > Paul Pogonyshev writes: > > class X > > { > > public void x () > > { > > for (int this_is_not_a_function_name : getX ()) { > > } > > } > > } > > In current trunk (compiled five minutes ago) > > 'this_is_not_a_function_name' above is fontified as a function > > name. This seems to depend on whether I have '()' after 'getX' or > > not. > > Paul > Jordon Biondo writes: > > I have a potential solution for this bug, as it has impacted me as well. > > Not sure what the best solution would be but I have included a patch that does > > solve the problem. From what I can tell there are no tests for java > > fortification but I have not seen any issues arising in my own java > > projects. The issue was that in java, a “:” can mark the end of a declaration in > > a foreach, not just a “;” or “,”. > > === modified file 'lisp/ChangeLog' > > *** lisp/ChangeLog 2014-09-01 15:03:45 +0000 > > --- lisp/ChangeLog 2014-09-01 19:11:46 +0000 > > *************** > > *** 1,3 **** > > --- 1,8 ---- > > + 2014-09-01 Jordon Biondo > > + > > + * progmodes/cc-fonts.el (c-font-lock-declarators): Special > > + case for declarations inside Java foreach loops (Bug#18378) > > + > > 2014-09-01 Eli Zaretskii > > * ls-lisp.el (ls-lisp-use-string-collate) > > === modified file 'lisp/progmodes/cc-fonts.el' > > *** lisp/progmodes/cc-fonts.el 2014-08-24 20:50:11 +0000 > > --- lisp/progmodes/cc-fonts.el 2014-09-01 19:11:59 +0000 > > *************** casts and declarations are fontified. U > > *** 1116,1123 **** > > ;; initializing brace lists. > > (let (found) > > (while > > ! (and (setq found (c-syntactic-re-search-forward > > ! "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t)) > > (eq (char-before) ?\[) > > (c-go-up-list-forward)) > > (setq brackets-after-id t)) > > --- 1116,1128 ---- > > ;; initializing brace lists. > > (let (found) > > (while > > ! (and (setq found (c-syntactic-re-search-forward > > ! (concat "[;,]\\|\\s)\\|\\'\\|\\(=\\|" > > ! (if (c-major-mode-is 'java-mode) > > ! ":\\|" > > ! "") > > ! "\\s(\\)") > > ! limit t t)) > > (eq (char-before) ?\[) > > (c-go-up-list-forward)) > > (setq brackets-after-id t))