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#56818: 28.1; c-mode font-lock issues in Emacs 28 Date: Fri, 29 Jul 2022 17:44:58 +0000 Message-ID: References: <83edy48nsq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27663"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56818@debbugs.gnu.org To: Bill Sacks , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 29 19:46:12 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 1oHU3v-00072q-MR for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Jul 2022 19:46:11 +0200 Original-Received: from localhost ([::1]:47232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHU3u-0008M8-7h for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Jul 2022 13:46:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHU3m-0008Lx-Ec for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 13:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHU3m-0001Su-39 for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 13:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oHU3l-00052l-Rk for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 13:46: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: Fri, 29 Jul 2022 17:46:01 +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.165911671019317 (code B ref 56818); Fri, 29 Jul 2022 17:46:01 +0000 Original-Received: (at 56818) by debbugs.gnu.org; 29 Jul 2022 17:45:10 +0000 Original-Received: from localhost ([127.0.0.1]:33387 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHU2v-00051U-UT for submit@debbugs.gnu.org; Fri, 29 Jul 2022 13:45:10 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:33912 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1oHU2r-00050c-MX for 56818@debbugs.gnu.org; Fri, 29 Jul 2022 13:45:09 -0400 Original-Received: (qmail 92396 invoked by uid 3782); 29 Jul 2022 17:44:58 -0000 Original-Received: from acm.muc.de (p4fe1596f.dip0.t-ipconnect.de [79.225.89.111]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 29 Jul 2022 19:44:58 +0200 Original-Received: (qmail 8900 invoked by uid 1000); 29 Jul 2022 17:44:58 -0000 Content-Disposition: inline In-Reply-To: <83edy48nsq.fsf@gnu.org> 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:238204 Archived-At: 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? -- Alan Mackenzie (Nuremberg, Germany).