From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bill Sacks Newsgroups: gmane.emacs.bugs Subject: bug#56818: 28.1; c-mode font-lock issues in Emacs 28 Date: Fri, 29 Jul 2022 14:38:53 -0600 Message-ID: <00abbbce-f72d-dd4a-7430-f85722c9d9b0@ucar.edu> References: <83edy48nsq.fsf@gnu.org> <343d4736-8c6e-eacb-5d7f-3ae10ef486e6@ucar.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------58D387DAB5C6D194A2C3C1B6" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30586"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:52.0) Gecko/20100101 PostboxApp/7.0.56 Cc: Eli Zaretskii , 56818@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 29 22:40:16 2022 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 1oHWmO-0007mi-0O for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Jul 2022 22:40:16 +0200 Original-Received: from localhost ([::1]:58192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHWmM-0004Vu-KK for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Jul 2022 16:40:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHWmA-0004VW-Ot for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 16:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHWmA-0005VI-FG for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 16:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oHWmA-0001Od-7j for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 16:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Bill Sacks Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Jul 2022 20:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56818 X-GNU-PR-Package: emacs Original-Received: via spool by 56818-submit@debbugs.gnu.org id=B56818.16591271455290 (code B ref 56818); Fri, 29 Jul 2022 20:40:02 +0000 Original-Received: (at 56818) by debbugs.gnu.org; 29 Jul 2022 20:39:05 +0000 Original-Received: from localhost ([127.0.0.1]:33552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHWlE-0001NE-NJ for submit@debbugs.gnu.org; Fri, 29 Jul 2022 16:39:05 -0400 Original-Received: from mail-oi1-f176.google.com ([209.85.167.176]:34664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHWlB-0001Mf-HY for 56818@debbugs.gnu.org; Fri, 29 Jul 2022 16:39:02 -0400 Original-Received: by mail-oi1-f176.google.com with SMTP id r13so6980403oie.1 for <56818@debbugs.gnu.org>; Fri, 29 Jul 2022 13:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucar-edu.20210112.gappssmtp.com; s=20210112; h=content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:from:to:cc; bh=vPhu3Gru70h5L8bbJmnVcsn+f3xb2JHb/MlmK2f9gfc=; b=RSis+nv1asbIzauSXzp2fyiNH5/l2uLbyvVRLbZDTZe1dhfyU3KA1bLQNzjxt/L9US pOshH6qaF+RP8HXpglqhFjxt9jFx+14tpgPovLTjG49dCuo0eYuGdw5gdhHYP50N6J9h 18GOmZjYQBjpf2r0dMyWQcdq+GeKcy36gCD6Fntornt7aKYFgEnIVnHFI6hT4HG0SZyh hrrIvUpqsEgnTpKW8iJxCzFeLoe1PoFd9y9TAf4TA1MQfW4IEhXo1bQ7oZdkQsILHgdK UDeZKMzYOt+2H2k8rPM+Lez2KzWpKKya0Cwz57/qX0V3VSn/ARFjeakLfm/jD67eVVMz IrAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:x-gm-message-state:from:to :cc; bh=vPhu3Gru70h5L8bbJmnVcsn+f3xb2JHb/MlmK2f9gfc=; b=Xjb/KzRt17JfsSkaFOV8ONw3VVxru+uOYh9SjULhq0RjMVmHwdlpl/lj/kTYSWXNPa kmyXE4/EyTV8KL4e17+5MTcaO2cIXku1wQQPsAIPUqyRW2pc6IwaFoGjuUdOrSVv6NSO qQ9ude6iXYhBMpKlHurlMZ7+cYleYJOFyREo+bYN2A4qfANMZBw/17iySwcg+7fyPeaI 2yMv7Z2Jryy4/YDsnZkBWRCLcxK6ZJiomqFEH0pq2zl5cqn3tRFBsrUhtrI5TEdHWGud N6WsXQGk58NC7rSiGAo50jYl/mP+NLsw5kW4kakfg9ygj3p+J79aNGFQjwupzx2kqEmy 3VGA== X-Gm-Message-State: AJIora/amceEayhMY+hw5KTpRlKVBId7kySBN6EpqdJ8ve/BExuTZ0gW TZWNl0tpAa/D8xli/DMND0kqIJpO8W0G1mUDoipuOoRhn6TvGASqZbLRzhKPceXzrh65Idx5nuJ amCT0FzScHX7R3ACkQwuDIprPcReDiifeJDDOy21KwlPdSdzN7XmGRo9ttQFXKw== X-Google-Smtp-Source: AGRyM1uDiT9eLelnD/WKxS4d8MkMwuwK2gbNbdUIUq6i7KS9gwN3EZRRKLdf9KAmpFnThAx8EkI9Jw== X-Received: by 2002:a05:6808:159d:b0:33a:7ebf:5385 with SMTP id t29-20020a056808159d00b0033a7ebf5385mr2587031oiw.68.1659127135128; Fri, 29 Jul 2022 13:38:55 -0700 (PDT) Original-Received: from [192.168.0.79] (97-118-158-229.hlrn.qwest.net. [97.118.158.229]) by smtp.gmail.com with ESMTPSA id u71-20020acaab4a000000b0033ac08dc485sm1293844oie.28.2022.07.29.13.38.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jul 2022 13:38:54 -0700 (PDT) In-Reply-To: <343d4736-8c6e-eacb-5d7f-3ae10ef486e6@ucar.edu> Content-Language: en-US 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:238224 Archived-At: This is a multi-part message in MIME format. --------------58D387DAB5C6D194A2C3C1B6 Content-Type: multipart/alternative; boundary="------------D72FC58177FE8846F7089851" --------------D72FC58177FE8846F7089851 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Unfortunately, I still see an issue in a slightly different context. The issue appears when function arguments appear on a line following the function name. This one is harder to provide screen shots for, because it is a bit more dynamic, but I'll try to walk through how to reproduce it, referencing two attachments: The starting point is testing_start.c and the end point is testing.c. If you start with testing_start.c and then take some steps to get to testing.c, you will notice a few issues with fontification of "somevar": (1) Position the cursor at the start of line 2 and hit Tab to put the cursor on line 2, column 12. Type "int somevar" and notice that "somevar" remains in the default face rather than being given font-lock-variable-name-face. (2) Run M-x font-lock-fontify-buffer to make "somevar" correctly take on font-lock-variable-name-face. (Interestingly, it seems fixed as soon as I type "M-x" and get into the minibuffer.) (3) Delete then retype the "r" in "somevar", noticing that it again reverts to default face (4) Repeat step (2) to temporarily fix the fontification (5) Type " // comment", noticing that "somevar" again loses its fontification (6) Repeat step (2) to temporarily fix the fontification (7) Delete and retype the "t" in "comment", noticing that "somevar" again loses its fontification. If my instructions are unclear or you cannot reproduce this, I can provide a screencast where I illustrate this behavior. I tested briefly with Emacs 27, and it appears that the problems in (1) and (3) are new issues in Emacs 28, but (5) and (7) appear in Emacs 27 as well. Bill Bill Sacks wrote on 7/29/22 2:23 PM: > Thank you very much for this quick reply and fix, Alan! Yes, from a > couple of tests, this fixes the issue I was having (and stops me from > getting distracted by constantly changing fontification while writing > a comment – thank you!). I'll let you know if I notice any remaining > issues. > > This does not fix the issue I'm seeing with fontification of variable > names in python-mode (which also appears to be an Emacs 28 > regression), but given that this fix is specific to cc-engine, the > python-mode issue is apparently different. That one seems a little > harder to reproduce, so it may take me a while to develop a simple > reproducer for it, especially since I haven't been doing much python > programming recently. However, please let me know if you would like me > to prioritize opening an issue for that one: I can do so sooner if it > would be helpful. > > Thanks again, > Bill > > Alan Mackenzie wrote on 7/29/22 11:44 AM: >> Hello, Bill and Eli. >> >> On Fri, Jul 29, 2022 at 08:56:21 +0300, Eli Zaretskii wrote: >>>> From: Bill Sacks >>>> Date: Thu, 28 Jul 2022 14:32:09 -0600 >> First of all (Bill), thanks for taking the trouble to report this bug, >> and thanks even more for cutting the test case down to the short fragment >> in your screenshots. >> >>>> Starting with Emacs 28, I have been seeing font-lock issues when >>>> editing C and C++ code. The situation where I see this the most >>>> (though I'm not sure if it's the only situation) is when I am writing >>>> a comment and currently have a space at the end of the comment line: >>>> in this situation, the fontification of a variable name or function >>>> name on the next line becomes broken until I type a non-space >>>> character to end the current line. >>>> The attached screen shots illustrate the problem: nospaces.png shows >>>> the correct fontification; space_before_var.png and >>>> space_before_function.png show that variable and function names lose >>>> their fontification when there is a space at the end of the previous >>>> comment line. Running M-x font-lock-fontify-buffer temporarily fixes >>>> the issue. >>>> The problem occurs even when using emacs -Q. I have tried the latest >>>> emacs28 pretest and the latest nightly build available from >>>> emacsformacosx (though with my customizations – NOT with emacs -Q) >>>> and those also exhibit the problem. The latest emacs27 from >>>> emacsformacosx does NOT have this issue. >> This is a coding bug in an optimisation from March 2020, where the >> complaint was that scrolling over a 2,000 line macro was slow. The fix >> neglected the possibility of spaces at the end of comment lines. >> >> Could you please apply the following patch in your Emacs-28.1, byte >> compile the file ..../lisp/progmodes/cc-engine.el, then try out the >> result on your real code. (If you want any help with the patching or >> byte compiling, feel free to send me private mail.) Then please confirm >> that the bug is fixed, or tell us how it's not fixed. Thanks! >> >> >> >> diff -r 9c649274b259 cc-engine.el >> --- a/cc-engine.el Tue Jul 26 20:08:39 2022 +0000 >> +++ b/cc-engine.el Fri Jul 29 17:25:16 2022 +0000 >> @@ -1679,9 +1679,13 @@ >> Return the result of `forward-comment' if it gets called, nil otherwise." >> `(if (not comment-end-can-be-escaped) >> (forward-comment -1) >> - (when (and (< (skip-syntax-backward " >") 0) >> - (eq (char-after) ?\n)) >> - (forward-char)) >> + (let ((dist (skip-syntax-backward " >"))) >> + (when (and >> + (< dist 0) >> + (progn >> + (skip-syntax-forward " " (- (point) dist 1)) >> + (eq (char-after) ?\n))) >> + (forward-char))) >> (cond >> ((and (eq (char-before) ?\n) >> (eq (char-before (1- (point))) ?\\)) >> >> >> >> >>> Alan, this seems to be a regression in Emacs 28, so could you please >>> look into it? >> Eli, Do I understand you want the fix in the release branch? >> > --------------D72FC58177FE8846F7089851 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Unfortunately, I still see an issue in a slightly different context. The issue appears when function arguments appear on a line following the function name. This one is harder to provide screen shots for, because it is a bit more dynamic, but I'll try to walk through how to reproduce it, referencing two attachments: The starting point is testing_start.c and the end point is testing.c. If you start with testing_start.c and then take some steps to get to testing.c, you will notice a few issues with fontification of "somevar":

(1) Position the cursor at the start of line 2 and hit Tab to put the cursor on line 2, column 12. Type "int somevar" and notice that "somevar" remains in the default face rather than being given font-lock-variable-name-face.

(2) Run M-x font-lock-fontify-buffer to make "somevar" correctly take on font-lock-variable-name-face. (Interestingly, it seems fixed as soon as I type "M-x" and get into the minibuffer.)

(3) Delete then retype the "r" in "somevar", noticing that it again reverts to default face

(4) Repeat step (2) to temporarily fix the fontification

(5) Type " // comment", noticing that "somevar" again loses its fontification

(6) Repeat step (2) to temporarily fix the fontification

(7) Delete and retype the "t" in "comment", noticing that "somevar" again loses its fontification.

If my instructions are unclear or you cannot reproduce this, I can provide a screencast where I illustrate this behavior.

I tested briefly with Emacs 27, and it appears that the problems in (1) and (3) are new issues in Emacs 28, but (5) and (7) appear in Emacs 27 as well.

Bill

Bill Sacks wrote on 7/29/22 2:23 PM:
Thank you very much for this quick reply and fix, Alan! Yes, from a couple of tests, this fixes the issue I was having (and stops me from getting distracted by constantly changing fontification while writing a comment – thank you!). I'll let you know if I notice any remaining issues.

This does not fix the issue I'm seeing with fontification of variable names in python-mode (which also appears to be an Emacs 28 regression), but given that this fix is specific to cc-engine, the python-mode issue is apparently different. That one seems a little harder to reproduce, so it may take me a while to develop a simple reproducer for it, especially since I haven't been doing much python programming recently. However, please let me know if you would like me to prioritize opening an issue for that one: I can do so sooner if it would be helpful.

Thanks again,
Bill

Alan Mackenzie wrote on 7/29/22 11:44 AM:
Hello, Bill and Eli.

On Fri, Jul 29, 2022 at 08:56:21 +0300, Eli Zaretskii wrote:
From: Bill Sacks <sacks@ucar.edu>
Date: Thu, 28 Jul 2022 14:32:09 -0600
First of all (Bill), thanks for taking the trouble to report this bug,
and thanks even more for cutting the test case down to the short fragment
in your screenshots.

Starting with Emacs 28, I have been seeing font-lock issues when
editing C and C++ code. The situation where I see this the most
(though I'm not sure if it's the only situation) is when I am writing
a comment and currently have a space at the end of the comment line:
in this situation, the fontification of a variable name or function
name on the next line becomes broken until I type a non-space
character to end the current line.
The attached screen shots illustrate the problem: nospaces.png shows
the correct fontification; space_before_var.png and
space_before_function.png show that variable and function names lose
their fontification when there is a space at the end of the previous
comment line. Running M-x font-lock-fontify-buffer temporarily fixes
the issue.
The problem occurs even when using emacs -Q. I have tried the latest
emacs28 pretest and the latest nightly build available from
emacsformacosx (though with my customizations – NOT with emacs -Q)
and those also exhibit the problem. The latest emacs27 from
emacsformacosx does NOT have this issue.
This is a coding bug in an optimisation from March 2020, where the
complaint was that scrolling over a 2,000 line macro was slow.  The fix
neglected the possibility of spaces at the end of comment lines.

Could you please apply the following patch in your Emacs-28.1, byte
compile the file ..../lisp/progmodes/cc-engine.el, then try out the
result on your real code.  (If you want any help with the patching or
byte compiling, feel free to send me private mail.)  Then please confirm
that the bug is fixed, or tell us how it's not fixed.  Thanks!



diff -r 9c649274b259 cc-engine.el
--- a/cc-engine.el	Tue Jul 26 20:08:39 2022 +0000
+++ b/cc-engine.el	Fri Jul 29 17:25:16 2022 +0000
@@ -1679,9 +1679,13 @@
 Return the result of `forward-comment' if it gets called, nil otherwise."
   `(if (not comment-end-can-be-escaped)
        (forward-comment -1)
-     (when (and (< (skip-syntax-backward " >") 0)
-		(eq (char-after) ?\n))
-       (forward-char))
+     (let ((dist (skip-syntax-backward " >")))
+       (when (and
+	      (< dist 0)
+	      (progn
+		(skip-syntax-forward " " (- (point) dist 1))
+		(eq (char-after) ?\n)))
+	 (forward-char)))
      (cond
       ((and (eq (char-before) ?\n)
 	    (eq (char-before (1- (point))) ?\\))




Alan, this seems to be a regression in Emacs 28, so could you please
look into it?
Eli, Do I understand you want the fix in the release branch?



--------------D72FC58177FE8846F7089851-- --------------58D387DAB5C6D194A2C3C1B6 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="testing.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="testing.c" dm9pZCBteWZ1bmMoCgkgICAgaW50IHNvbWV2YXIgLy8gY29tbWVudAogICkgewogIAp9Cg== --------------58D387DAB5C6D194A2C3C1B6 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="testing_start.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="testing_start.c" dm9pZCBteWZ1bmMoCgogICkgewogIAp9Cg== --------------58D387DAB5C6D194A2C3C1B6--