From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 30 09:05:32 2022 Received: (at submit) by debbugs.gnu.org; 30 Jul 2022 13:05:32 +0000 Received: from localhost ([127.0.0.1]:34297 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHm9s-0007KC-GD for submit@debbugs.gnu.org; Sat, 30 Jul 2022 09:05:32 -0400 Received: from lists.gnu.org ([209.51.188.17]:50312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHm9q-0007K5-VK for submit@debbugs.gnu.org; Sat, 30 Jul 2022 09:05:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHm9q-0006HH-QK for bug-gnu-emacs@gnu.org; Sat, 30 Jul 2022 09:05:30 -0400 Received: from colin.muc.de ([193.149.48.1]:63998 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1oHm9o-0000ND-NP for bug-gnu-emacs@gnu.org; Sat, 30 Jul 2022 09:05:30 -0400 Received: (qmail 16615 invoked by uid 3782); 30 Jul 2022 13:05:25 -0000 Received: from acm.muc.de (p2e5d52c1.dip0.t-ipconnect.de [46.93.82.193]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 30 Jul 2022 15:05:25 +0200 Received: (qmail 5176 invoked by uid 1000); 30 Jul 2022 13:05:24 -0000 Date: Sat, 30 Jul 2022 13:05:24 +0000 To: bug-gnu-emacs@gnu.org Subject: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: Bill Sacks X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Hello, Emacs. This is (a version of) a bug reported by Bill Sacks in the correspondence for bug #56818. I am separating it from that bug, since it is a distinct bug, despite having similar symptoms. In Emacs-28: 1. Start emacs -Q. 2. Insert the following file in C Mode: void myfunc( ) { } 3. In line 2 (the first blank line) type "int somevar". 4. Note that somevar is not fontified. This is a bug, given that the arglist to myfunc is terminated with a ) on line 3. 5. Do something (e.g. typing M-x) to cause a redisplay. somevar gets its correct face. 6. Note that any insertion or deletion in L2 causes somevar to lose its fontification. This is a bug. 7. (After 6). Move point onto somevar and do C-u C-x =. This shows that the face text property is set on the character despite the face not appearing on the screen. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 30 10:15:04 2022 Received: (at 56841) by debbugs.gnu.org; 30 Jul 2022 14:15:04 +0000 Received: from localhost ([127.0.0.1]:35544 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHnFA-0005Xl-Ad for submit@debbugs.gnu.org; Sat, 30 Jul 2022 10:15:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHnF6-0005Mi-J3 for 56841@debbugs.gnu.org; Sat, 30 Jul 2022 10:15:02 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHnEz-0002GG-KP; Sat, 30 Jul 2022 10:14:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=6GYr6n/yzvKAR3Y84a1AajdvtfDBSheDapwZEvAkG78=; b=N+6htVGfsbLg tbNzRuVfLOcq1j/tKCaPe8RwU86fb04NeT73goxZkqguF8UzVwFUqa7pdJPIORPcx1AxWHfw0cow8 s2Q0vAsBN+jDMJ6F6z/IKqJy/T1ECJJKWOHuyRDJoVaECBwK8BsfhYGhRezVBufg00EsCGzTXVC45 q1xyH3DOOz44lZAw4Zr1wXumitlynOvETmQAGlXIyAKjv4dyR5Yypr8/Q3ZEmt+LRyR2sslOCtY2Z tWy9S2nAW9fgHVSMUk/R7ubpjonzoeuDA38VW3TbPC7OYgFW/bPeADvfNHItCE+35KppoLYNIaMnf KGBHJzAdD0QvP0n01gf4NA==; Received: from [87.69.77.57] (port=4171 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHnEz-0006wb-3l; Sat, 30 Jul 2022 10:14:53 -0400 Date: Sat, 30 Jul 2022 17:14:43 +0300 Message-Id: <83a68q6624.fsf@gnu.org> From: Eli Zaretskii To: Alan Mackenzie In-Reply-To: (message from Alan Mackenzie on Sat, 30 Jul 2022 13:05:24 +0000) Subject: Re: bug#56841: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56841 Cc: 56841@debbugs.gnu.org, sacks@ucar.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: Bill Sacks > Date: Sat, 30 Jul 2022 13:05:24 +0000 > From: Alan Mackenzie > > 1. Start emacs -Q. > 2. Insert the following file in C Mode: > > void myfunc( > > ) { > > } > > 3. In line 2 (the first blank line) type "int somevar". > 4. Note that somevar is not fontified. This is a bug, given that the > arglist to myfunc is terminated with a ) on line 3. > 5. Do something (e.g. typing M-x) to cause a redisplay. somevar gets > its correct face. > 6. Note that any insertion or deletion in L2 causes somevar to lose its > fontification. This is a bug. > 7. (After 6). Move point onto somevar and do C-u C-x =. This shows > that the face text property is set on the character despite the face > not appearing on the screen. Are you saying this is not a bug in CC mode but somewhere else? Or are you saying that you don't yet know what is the culprit and will investigate? From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 30 10:28:04 2022 Received: (at 56841) by debbugs.gnu.org; 30 Jul 2022 14:28:04 +0000 Received: from localhost ([127.0.0.1]:35558 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHnRk-0007s2-BY for submit@debbugs.gnu.org; Sat, 30 Jul 2022 10:28:04 -0400 Received: from colin.muc.de ([193.149.48.1]:10578 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1oHnRh-0007rT-0t for 56841@debbugs.gnu.org; Sat, 30 Jul 2022 10:28:02 -0400 Received: (qmail 71838 invoked by uid 3782); 30 Jul 2022 14:27:54 -0000 Received: from acm.muc.de (p2e5d52c1.dip0.t-ipconnect.de [46.93.82.193]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 30 Jul 2022 16:27:53 +0200 Received: (qmail 5346 invoked by uid 1000); 30 Jul 2022 14:27:53 -0000 Date: Sat, 30 Jul 2022 14:27:53 +0000 To: Eli Zaretskii Subject: Re: bug#56841: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line Message-ID: References: <83a68q6624.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83a68q6624.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 56841 Cc: 56841@debbugs.gnu.org, sacks@ucar.edu, acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Eli. On Sat, Jul 30, 2022 at 17:14:43 +0300, Eli Zaretskii wrote: > > Cc: Bill Sacks > > Date: Sat, 30 Jul 2022 13:05:24 +0000 > > From: Alan Mackenzie > > 1. Start emacs -Q. > > 2. Insert the following file in C Mode: > > void myfunc( > > ) { > > } > > 3. In line 2 (the first blank line) type "int somevar". > > 4. Note that somevar is not fontified. This is a bug, given that the > > arglist to myfunc is terminated with a ) on line 3. > > 5. Do something (e.g. typing M-x) to cause a redisplay. somevar gets > > its correct face. > > 6. Note that any insertion or deletion in L2 causes somevar to lose its > > fontification. This is a bug. > > 7. (After 6). Move point onto somevar and do C-u C-x =. This shows > > that the face text property is set on the character despite the face > > not appearing on the screen. > Are you saying this is not a bug in CC mode but somewhere else? Or > are you saying that you don't yet know what is the culprit and will > investigate? It is most definitely a bug in CC Mode, and I'm looking at it at the moment. My feeling right now is that the fix will be too involved to go into the release branch. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 30 11:10:34 2022 Received: (at 56841) by debbugs.gnu.org; 30 Jul 2022 15:10:34 +0000 Received: from localhost ([127.0.0.1]:35598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHo6r-0000di-SS for submit@debbugs.gnu.org; Sat, 30 Jul 2022 11:10:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHo6o-0000dO-0h for 56841@debbugs.gnu.org; Sat, 30 Jul 2022 11:10:32 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHo6h-0001RM-V8; Sat, 30 Jul 2022 11:10:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+MWD1mGcLob6NCQ4hVRDIDBYRtMb+nZwwEG9eqhLPBM=; b=WbKaH0MufIpi I9S5Ml37M+3AidU8mheDLLN4F9JcIIzQixt6ydXEhr8eCgez3VmgLjShwkE4yf48+Uy9VnPpHkcFK xnVSXQkc5xn2r8J9GAK06hPlNY6sTx4xeEPGYiJY7fY6JXUfb8PaR/GnJyXUQcHo4vufC7lA0NfcK wLeWRyPDR80936AeI1FDUJsOGROcSCL39YlWyN0OxIDGAb9lJMNbJM3i55AcfxDndun9sh1kw5795 N7iQBSHlFzesxOuWdt0ogAPCBFZMQq1Zq8Eeaq4kCfwgymceWvsw5TEcIT2vtsifbZEFW8bVosIi3 aGvDftxv9EU6RHjuCFqmFA==; Received: from [87.69.77.57] (port=3625 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHo6h-0002fJ-Dy; Sat, 30 Jul 2022 11:10:23 -0400 Date: Sat, 30 Jul 2022 18:10:12 +0300 Message-Id: <838roa63hn.fsf@gnu.org> From: Eli Zaretskii To: Alan Mackenzie In-Reply-To: (message from Alan Mackenzie on Sat, 30 Jul 2022 14:27:53 +0000) Subject: Re: bug#56841: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line References: <83a68q6624.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56841 Cc: 56841@debbugs.gnu.org, sacks@ucar.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sat, 30 Jul 2022 14:27:53 +0000 > Cc: 56841@debbugs.gnu.org, sacks@ucar.edu, acm@muc.de > From: Alan Mackenzie > > > Are you saying this is not a bug in CC mode but somewhere else? Or > > are you saying that you don't yet know what is the culprit and will > > investigate? > > It is most definitely a bug in CC Mode, and I'm looking at it at the > moment. Thanks. > My feeling right now is that the fix will be too involved to go into the > release branch. Let's talk when you have a fix. But generally, this doesn't sound like a too grave problem to me, especially since there's an easy way of asking Emacs to fontify correctly. From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 31 11:49:07 2022 Received: (at 56841) by debbugs.gnu.org; 31 Jul 2022 15:49:07 +0000 Received: from localhost ([127.0.0.1]:38500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIBBj-0003Y8-2U for submit@debbugs.gnu.org; Sun, 31 Jul 2022 11:49:07 -0400 Received: from colin.muc.de ([193.149.48.1]:49038 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1oIBBg-0003Xb-IC for 56841@debbugs.gnu.org; Sun, 31 Jul 2022 11:49:05 -0400 Received: (qmail 45738 invoked by uid 3782); 31 Jul 2022 15:48:58 -0000 Received: from acm.muc.de (p2e5d56e1.dip0.t-ipconnect.de [46.93.86.225]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 31 Jul 2022 17:48:58 +0200 Received: (qmail 7146 invoked by uid 1000); 31 Jul 2022 15:48:56 -0000 Date: Sun, 31 Jul 2022 15:48:56 +0000 To: Eli Zaretskii , sacks@ucar.edu Subject: Re: bug#56841: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line Message-ID: References: <83a68q6624.fsf@gnu.org> <838roa63hn.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <838roa63hn.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 56841 Cc: 56841@debbugs.gnu.org, acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Eli and Bill. On Sat, Jul 30, 2022 at 18:10:12 +0300, Eli Zaretskii wrote: > > Date: Sat, 30 Jul 2022 14:27:53 +0000 > > Cc: 56841@debbugs.gnu.org, sacks@ucar.edu, acm@muc.de > > From: Alan Mackenzie > > > Are you saying this is not a bug in CC mode but somewhere else? Or > > > are you saying that you don't yet know what is the culprit and will > > > investigate? > > It is most definitely a bug in CC Mode, and I'm looking at it at the > > moment. > Thanks. > > My feeling right now is that the fix will be too involved to go into the > > release branch. > Let's talk when you have a fix. But generally, this doesn't sound > like a too grave problem to me, especially since there's an easy way > of asking Emacs to fontify correctly. Here's a proposed version of the fix, which seems to work. The diff is probably best perused with diff -b. The patch will apply to both the master branch and Emacs-28.1. CC Mode: Fontify args correctly when arglist closing ) is not on the same line This should fix bug #56841. * lisp/progmodes/cc-engine.el (c-forward-declarator): Fix an off-by-one comparing the position after a c-forward-name with a limit. * lisp/progmodes/cc-mode.el (c-fl-decl-end): Handle correctly point starting inside a literal. Insert a missing c-backward-syntactic-ws in the handling of C++ attributes. Better handle point starting inside a [ or (. Tidy up the handling of syntactic whitespace at the end of the buffer. diff -r e4e62074b8a6 cc-engine.el --- a/cc-engine.el Sat Jul 30 09:15:53 2022 +0000 +++ b/cc-engine.el Sun Jul 31 15:39:26 2022 +0000 @@ -9576,7 +9576,7 @@ (or (= paren-depth 0) (c-safe (goto-char (scan-lists (point) 1 paren-depth)))) - (<= (point) limit) + (< (point) limit) ;; Skip over any trailing bit, such as "__attribute__". (progn diff -r e4e62074b8a6 cc-mode.el --- a/cc-mode.el Sat Jul 30 09:15:53 2022 +0000 +++ b/cc-mode.el Sun Jul 31 15:39:26 2022 +0000 @@ -2412,49 +2412,59 @@ (and (/= new-pos pos) new-pos)))) (defun c-fl-decl-end (pos) - ;; If POS is inside a declarator, return the end of the token that follows - ;; the declarator, otherwise return nil. POS being in a literal does not - ;; count as being in a declarator (on pragmatic grounds). POINT is not - ;; preserved. + ;; If POS is inside a declarator, return the end of the paren pair that + ;; terminates it, or the token that follows the declarator, otherwise return + ;; nil. If there is no such token, the end of the last token in the buffer + ;; is used. POS being in a literal is now (2022-07) handled correctly. + ;; POINT is not preserved. (goto-char pos) (let ((lit-start (c-literal-start)) (lim (c-determine-limit 1000)) enclosing-attribute pos1) - (unless lit-start - (c-backward-syntactic-ws - lim) - (when (setq enclosing-attribute (c-enclosing-c++-attribute)) - (goto-char (car enclosing-attribute))) ; Only happens in C++ Mode. - (when (setq pos1 (c-on-identifier)) - (goto-char pos1) - (let ((lim (save-excursion - (and (c-beginning-of-macro) - (progn (c-end-of-macro) (point)))))) - (and (c-forward-declarator lim) - (if (eq (char-after) ?\() - (and - (c-go-list-forward nil lim) - (progn (c-forward-syntactic-ws lim) - (not (eobp))) - (progn - (if (looking-at c-symbol-char-key) - ;; Deal with baz (foo((bar)) type var), where - ;; foo((bar)) is not semantically valid. The result - ;; must be after var). - (and - (goto-char pos) - (setq pos1 (c-on-identifier)) - (goto-char pos1) - (progn - (c-backward-syntactic-ws lim) - (eq (char-before) ?\()) - (c-fl-decl-end (1- (point)))) - (c-backward-syntactic-ws lim) - (point)))) - (and (progn (c-forward-syntactic-ws lim) - (not (eobp))) + (if lit-start + (goto-char lit-start)) + (c-backward-syntactic-ws lim) + (when (setq enclosing-attribute (c-enclosing-c++-attribute)) + (goto-char (car enclosing-attribute)) ; Only happens in C++ Mode. + (c-backward-syntactic-ws lim)) + (while (and (> (point) lim) + (memq (char-before) '(?\[ ?\())) + (backward-char) + (c-backward-syntactic-ws lim)) + (when (setq pos1 (c-on-identifier)) + (goto-char pos1) + (let ((lim (save-excursion + (and (c-beginning-of-macro) + (progn (c-end-of-macro) (point)))))) + (and (c-forward-declarator lim) + (if (eq (char-after) ?\() + (and + (c-go-list-forward nil lim) + (progn (c-forward-syntactic-ws lim) + (not (eobp))) + (progn + (if (looking-at c-symbol-char-key) + ;; Deal with baz (foo((bar)) type var), where + ;; foo((bar)) is not semantically valid. The result + ;; must be after var). + (and + (goto-char pos) + (setq pos1 (c-on-identifier)) + (goto-char pos1) + (progn + (c-backward-syntactic-ws lim) + (eq (char-before) ?\()) + (c-fl-decl-end (1- (point)))) (c-backward-syntactic-ws lim) - (point))))))))) + (point)))) + (if (progn (c-forward-syntactic-ws lim) + (not (eobp))) + (c-forward-over-token) + (let ((lit-start (c-literal-start))) + (when lit-start + (goto-char lit-start)) + (c-backward-syntactic-ws))) + (and (>= (point) pos) (point)))))))) (defun c-change-expand-fl-region (_beg _end _old-len) ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 31 11:54:19 2022 Received: (at 56841) by debbugs.gnu.org; 31 Jul 2022 15:54:19 +0000 Received: from localhost ([127.0.0.1]:38512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIBGl-0003hB-BR for submit@debbugs.gnu.org; Sun, 31 Jul 2022 11:54:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46942) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIBGj-0003gz-4W for 56841@debbugs.gnu.org; Sun, 31 Jul 2022 11:54:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:58192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIBGd-0003BI-Lv; Sun, 31 Jul 2022 11:54:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=3KbjOJ8rMAyJwOdZeBTqvcJQJkBYHTB8xzLa8S2QzKo=; b=No0xCVHzPBpz KD8molwd3MZOlAz+0eOXFy0eV5hrg0f2lm/pUTnLxLfQ/+i7FSoYKmBsLf9iaIrqex6eX1MVJ5CQW L9xpl287PM+1Q+RrNZuL6vZ9EC7dXFeA1tTT7Epm7yI6E8f+32Z5psUjfSsjFAVX/8Lu15lmGgcvK fZM0jGSU+flG+f7Qm45S4ac1Sh4ybMeWilGAMnr0ORNKOqloYXyFIRRCJ4ymBBM8z1+16AeuKRYNn hP7iLfegGphczRRMJiRCGUSpwaj3IA435E1Ktn8CHqnv0JQOMtTFAEMGNKZl9O2RyGE+eUPpnWUYW rn7FpuLR9ySgANmiStB4ZA==; Received: from [87.69.77.57] (port=3479 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIBGd-00061B-55; Sun, 31 Jul 2022 11:54:11 -0400 Date: Sun, 31 Jul 2022 18:53:58 +0300 Message-Id: <83czdl46sp.fsf@gnu.org> From: Eli Zaretskii To: Alan Mackenzie In-Reply-To: (message from Alan Mackenzie on Sun, 31 Jul 2022 15:48:56 +0000) Subject: Re: bug#56841: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line References: <83a68q6624.fsf@gnu.org> <838roa63hn.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56841 Cc: 56841@debbugs.gnu.org, sacks@ucar.edu, acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sun, 31 Jul 2022 15:48:56 +0000 > Cc: 56841@debbugs.gnu.org, acm@muc.de > From: Alan Mackenzie > > > Let's talk when you have a fix. But generally, this doesn't sound > > like a too grave problem to me, especially since there's an easy way > > of asking Emacs to fontify correctly. > > Here's a proposed version of the fix, which seems to work. The diff is > probably best perused with diff -b. The patch will apply to both the master > branch and Emacs-28.1. Thanks. I guess this should go to master. From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 02 15:30:56 2022 Received: (at 56841) by debbugs.gnu.org; 2 Aug 2022 19:30:56 +0000 Received: from localhost ([127.0.0.1]:45116 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIxbT-0007tm-Gk for submit@debbugs.gnu.org; Tue, 02 Aug 2022 15:30:55 -0400 Received: from colin.muc.de ([193.149.48.1]:17781 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1oIxbO-0007tU-NU for 56841@debbugs.gnu.org; Tue, 02 Aug 2022 15:30:54 -0400 Received: (qmail 12285 invoked by uid 3782); 2 Aug 2022 19:30:44 -0000 Received: from acm.muc.de (p4fe15cce.dip0.t-ipconnect.de [79.225.92.206]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 02 Aug 2022 21:30:43 +0200 Received: (qmail 18463 invoked by uid 1000); 2 Aug 2022 19:30:43 -0000 Date: Tue, 2 Aug 2022 19:30:43 +0000 To: sacks@ucar.edu Subject: Re: bug#56841: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line Message-ID: References: <83a68q6624.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83a68q6624.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 56841 Cc: 56841@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello again, Bill. On Sat, Jul 30, 2022 at 17:14:43 +0300, Eli Zaretskii wrote: > > Cc: Bill Sacks > > Date: Sat, 30 Jul 2022 13:05:24 +0000 > > From: Alan Mackenzie > > 1. Start emacs -Q. > > 2. Insert the following file in C Mode: > > void myfunc( > > ) { > > } > > 3. In line 2 (the first blank line) type "int somevar". > > 4. Note that somevar is not fontified. This is a bug, given that the > > arglist to myfunc is terminated with a ) on line 3. > > 5. Do something (e.g. typing M-x) to cause a redisplay. somevar gets > > its correct face. > > 6. Note that any insertion or deletion in L2 causes somevar to lose its > > fontification. This is a bug. > > 7. (After 6). Move point onto somevar and do C-u C-x =. This shows > > that the face text property is set on the character despite the face > > not appearing on the screen. This bug, although the symptoms were similar to the other bug you reported, was an entirely different bug, more difficult to fix. I now have a patch for it, and would ask you to apply the patch to your Emacs 28.1 and byte compile the files in it, as before. (As before, help is available from me by private email.) Then please test it on your actual C code and let us know how it went. Thanks! diff -r e4e62074b8a6 cc-engine.el --- a/cc-engine.el Sat Jul 30 09:15:53 2022 +0000 +++ b/cc-engine.el Tue Aug 02 19:14:15 2022 +0000 @@ -9576,7 +9576,7 @@ (or (= paren-depth 0) (c-safe (goto-char (scan-lists (point) 1 paren-depth)))) - (<= (point) limit) + (< (point) limit) ;; Skip over any trailing bit, such as "__attribute__". (progn diff -r e4e62074b8a6 cc-mode.el --- a/cc-mode.el Sat Jul 30 09:15:53 2022 +0000 +++ b/cc-mode.el Tue Aug 02 19:14:15 2022 +0000 @@ -2412,49 +2412,59 @@ (and (/= new-pos pos) new-pos)))) (defun c-fl-decl-end (pos) - ;; If POS is inside a declarator, return the end of the token that follows - ;; the declarator, otherwise return nil. POS being in a literal does not - ;; count as being in a declarator (on pragmatic grounds). POINT is not - ;; preserved. + ;; If POS is inside a declarator, return the position of the end of the + ;; paren pair that terminates it, or of the end of the token that follows + ;; the declarator, otherwise return nil. If there is no such token, the end + ;; of the last token in the buffer is used. POS being in a literal is now + ;; (2022-07) handled correctly. POINT is not preserved. (goto-char pos) (let ((lit-start (c-literal-start)) (lim (c-determine-limit 1000)) enclosing-attribute pos1) - (unless lit-start - (c-backward-syntactic-ws - lim) - (when (setq enclosing-attribute (c-enclosing-c++-attribute)) - (goto-char (car enclosing-attribute))) ; Only happens in C++ Mode. - (when (setq pos1 (c-on-identifier)) - (goto-char pos1) - (let ((lim (save-excursion - (and (c-beginning-of-macro) - (progn (c-end-of-macro) (point)))))) - (and (c-forward-declarator lim) - (if (eq (char-after) ?\() - (and - (c-go-list-forward nil lim) - (progn (c-forward-syntactic-ws lim) - (not (eobp))) - (progn - (if (looking-at c-symbol-char-key) - ;; Deal with baz (foo((bar)) type var), where - ;; foo((bar)) is not semantically valid. The result - ;; must be after var). - (and - (goto-char pos) - (setq pos1 (c-on-identifier)) - (goto-char pos1) - (progn - (c-backward-syntactic-ws lim) - (eq (char-before) ?\()) - (c-fl-decl-end (1- (point)))) - (c-backward-syntactic-ws lim) - (point)))) - (and (progn (c-forward-syntactic-ws lim) - (not (eobp))) + (if lit-start + (goto-char lit-start)) + (c-backward-syntactic-ws lim) + (when (setq enclosing-attribute (c-enclosing-c++-attribute)) + (goto-char (car enclosing-attribute)) ; Only happens in C++ Mode. + (c-backward-syntactic-ws lim)) + (while (and (> (point) lim) + (memq (char-before) '(?\[ ?\())) + (backward-char) + (c-backward-syntactic-ws lim)) + (when (setq pos1 (c-on-identifier)) + (goto-char pos1) + (let ((lim (save-excursion + (and (c-beginning-of-macro) + (progn (c-end-of-macro) (point)))))) + (and (c-forward-declarator lim) + (if (and (eq (char-after) ?\() + (c-go-list-forward nil lim)) + (and + (progn (c-forward-syntactic-ws lim) + (not (eobp))) + (progn + (if (looking-at c-symbol-char-key) + ;; Deal with baz (foo((bar)) type var), where + ;; foo((bar)) is not semantically valid. The result + ;; must be after var). + (and + (goto-char pos) + (setq pos1 (c-on-identifier)) + (goto-char pos1) + (progn + (c-backward-syntactic-ws lim) + (eq (char-before) ?\()) + (c-fl-decl-end (1- (point)))) (c-backward-syntactic-ws lim) - (point))))))))) + (point)))) + (if (progn (c-forward-syntactic-ws lim) + (not (eobp))) + (c-forward-over-token) + (let ((lit-start (c-literal-start))) + (when lit-start + (goto-char lit-start)) + (c-backward-syntactic-ws))) + (and (>= (point) pos) (point)))))))) (defun c-change-expand-fl-region (_beg _end _old-len) ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 04 09:58:07 2022 Received: (at control) by debbugs.gnu.org; 4 Aug 2022 13:58:07 +0000 Received: from localhost ([127.0.0.1]:54048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oJbMV-0006w7-1k for submit@debbugs.gnu.org; Thu, 04 Aug 2022 09:58:07 -0400 Received: from mail-vs1-f44.google.com ([209.85.217.44]:36790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oJbMR-0006uX-IZ for control@debbugs.gnu.org; Thu, 04 Aug 2022 09:58:04 -0400 Received: by mail-vs1-f44.google.com with SMTP id o123so2252726vsc.3 for ; Thu, 04 Aug 2022 06:58:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=QiDs4LaLl4SBDPcw3ZQK7jQnw5pwYrwfokD7Fxf9fqI=; b=sRCNVVeGqkwbzmox6EtlvkbafMX4e3qScXMe0QO+3xmb828iKeBSr1h020teaxFprL jHyV/wzDEe/6X4KkaWKalW+kkyLGpK4ClpZ7UbNNASQz0KgDZ7p6hgl9GkEMU/8RTaEh QaxhAe91g9SyNPehoqVK51rh4L7VEbnkv3OxVjQ+KB8iWL3Ya65PeT/HYaIaBC2YmQDh +zViMDt2iq+Pciur+LCGs9cqo9Anokx113jYcrelAgGPHPdkf67qB5kB2RZ5tdz8g+0q gh6RU34rtoT0TC+izX44RaWySnN6kDKMRFD3L/DjoJRgmB3PY/k8V4SC39u5nkQCKOUV ymOw== X-Gm-Message-State: ACgBeo0c4Zq+L9IQzGdgCmTGhnrmGaTDIDa7suAmDiGX5Q2CQhoZs2G1 xKS4SbrOLlMp3dJ8h7JA69wjcXIvPHQm63UgqZs96eu6 X-Google-Smtp-Source: AA6agR7an3xdkh1uWXXSxhx9h2SN5kOdYEJjzkeacVBpufW4351r75SCxuPl9C4EKfgGpn4HB0hkUtSMW/JUgJzCqEk= X-Received: by 2002:a67:ab09:0:b0:387:ebbb:848 with SMTP id u9-20020a67ab09000000b00387ebbb0848mr862008vse.23.1659621477925; Thu, 04 Aug 2022 06:57:57 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 4 Aug 2022 13:57:57 +0000 X-Hashcash: 1:21:220804:control@debbugs.gnu.org::Hdkju7RBGL6PmCHo:0g7V From: Stefan Kangas MIME-Version: 1.0 Date: Thu, 4 Aug 2022 13:57:57 +0000 Message-ID: Subject: control message for bug #56841 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) severity 56841 minor quit From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 22 12:09:01 2022 Received: (at 56841) by debbugs.gnu.org; 22 Aug 2022 16:09:01 +0000 Received: from localhost ([127.0.0.1]:41575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQ9z2-0000uq-FF for submit@debbugs.gnu.org; Mon, 22 Aug 2022 12:09:01 -0400 Received: from mail-io1-f48.google.com ([209.85.166.48]:41526) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQ9yy-0000ub-W2 for 56841@debbugs.gnu.org; Mon, 22 Aug 2022 12:08:59 -0400 Received: by mail-io1-f48.google.com with SMTP id p187so1219623iod.8 for <56841@debbugs.gnu.org>; Mon, 22 Aug 2022 09:08:56 -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:from:references:cc:to:subject:from:to:cc; bh=uHixNa2vkpTeqjhclPwQRTiewnNwk7HANHWAslCAoNc=; b=U/i4llNVl6tpg+bZ7gFHvxhdStP7UnC12mNjjuaTOESerT7OSUKU6LKIBZP1oQnBT0 d443BkTIUVu2WeGYn8QFJFJFNhltP+1WxkBi4Xw/nUuyfpvG6ve1EwwPNXz+qmIggzMt DJwX/G+OjmVrltJarh7FNoYvgtc3+RIdaNKGiY5xcKD78dmXY0uv7IxI6aY2RJqx/I/7 9UXIZcnypiy9d4D4kXHIOAsbk0GRpAe6U31dgPW75XznEg0SUEU4frReDn2m6gFy6wqP hdiai08OcU9pFF1jbyFnBTmtgMPf53WmOTeqc3RXwSGAxHKGhtFhGPQzm0160Ai3fn5e w2vg== 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:from:references:cc:to:subject:x-gm-message-state:from:to :cc; bh=uHixNa2vkpTeqjhclPwQRTiewnNwk7HANHWAslCAoNc=; b=0wAQ4S6JKo739DavS2NNElrmkWvRU6qlpSfZa5RZ88BDwaT0a5mqxKTD46RWvSf7To 0YA6ASBGsbPJFpfeE8iToHayWhgiIXbezGoGIocM2wEJG8kd+sq0MzFuFzDLtzIpSQs1 jlNAOgVFeZcQ9YhvqUpT4vL+6nliIhXoJPpzwCeuTeSwNaV5QlT7YEqSNcbMi5UvzPTp uisOQoPweUwSkxvTEj9Fv7qmoJHg5k9O61SGSjbCMdo1zd5GmZU05+BzunxiyoaSbxxv VKZhtmTAj1+rggYImnV5Xueym8SvYOODz7bEwlrBTexkhuiHlmOxKKCybMRDZYSmP7xl PVxQ== X-Gm-Message-State: ACgBeo2m4weW/5o0SzAiU3HkMMyFLA9tO5dqLDF9gPA30tGeiAhCHCJU 9s3g/i72kgRaxvLQ8GI0GDwjVWja9+9tYhGoNS/xQD2BLPxQ1DNS56A76/mn2XDVKg2ldsaq+Nt WM6tET8dHz6FMJ0f0yKTZ5H1a32r4tAu4QmwVrSlbwitC/znvLEyqBzl6EDSwTA== X-Google-Smtp-Source: AA6agR7KjIkf8BZ65GIaIhBJIIwhDruADVGh16biQPi+l7+Fni69AJTPzRow9HIkk79J6n7Ux/zZTQ== X-Received: by 2002:a05:6638:379a:b0:349:e1ff:ed2c with SMTP id w26-20020a056638379a00b00349e1ffed2cmr1882608jal.114.1661184530254; Mon, 22 Aug 2022 09:08:50 -0700 (PDT) Received: from [192.168.0.79] (97-118-158-229.hlrn.qwest.net. [97.118.158.229]) by smtp.gmail.com with ESMTPSA id i36-20020a023b64000000b003434b40289dsm5241993jaf.165.2022.08.22.09.08.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Aug 2022 09:08:49 -0700 (PDT) Subject: Re: bug#56841: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line To: Alan Mackenzie References: <83a68q6624.fsf@gnu.org> From: Bill Sacks Message-ID: <94a87aa6-63d1-dcd9-cbb3-2c9b585fad28@ucar.edu> Date: Mon, 22 Aug 2022 10:08:48 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:52.0) Gecko/20100101 PostboxApp/7.0.56 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------D3124A73698BF7E5EC3EFD49" Content-Language: en-US X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 56841 Cc: 56841@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------D3124A73698BF7E5EC3EFD49 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Thank you very much for this fix, Alan. I have now tested it both with my test case and in more realistic code, and it seems to fix the issues I was encountering – thank you! Sorry for the delay on getting back to you about this. Bill Alan Mackenzie wrote on 8/2/22 1:30 PM: > Hello again, Bill. > > On Sat, Jul 30, 2022 at 17:14:43 +0300, Eli Zaretskii wrote: >>> Cc: Bill Sacks >>> Date: Sat, 30 Jul 2022 13:05:24 +0000 >>> From: Alan Mackenzie >>> 1. Start emacs -Q. >>> 2. Insert the following file in C Mode: >>> void myfunc( >>> ) { >>> } >>> 3. In line 2 (the first blank line) type "int somevar". >>> 4. Note that somevar is not fontified. This is a bug, given that the >>> arglist to myfunc is terminated with a ) on line 3. >>> 5. Do something (e.g. typing M-x) to cause a redisplay. somevar gets >>> its correct face. >>> 6. Note that any insertion or deletion in L2 causes somevar to lose its >>> fontification. This is a bug. >>> 7. (After 6). Move point onto somevar and do C-u C-x =. This shows >>> that the face text property is set on the character despite the face >>> not appearing on the screen. > This bug, although the symptoms were similar to the other bug you > reported, was an entirely different bug, more difficult to fix. > > I now have a patch for it, and would ask you to apply the patch to your > Emacs 28.1 and byte compile the files in it, as before. (As before, > help is available from me by private email.) Then please test it on > your actual C code and let us know how it went. Thanks! > > > > diff -r e4e62074b8a6 cc-engine.el > --- a/cc-engine.el Sat Jul 30 09:15:53 2022 +0000 > +++ b/cc-engine.el Tue Aug 02 19:14:15 2022 +0000 > @@ -9576,7 +9576,7 @@ > (or (= paren-depth 0) > (c-safe (goto-char (scan-lists (point) 1 paren-depth)))) > > - (<= (point) limit) > + (< (point) limit) > > ;; Skip over any trailing bit, such as "__attribute__". > (progn > diff -r e4e62074b8a6 cc-mode.el > --- a/cc-mode.el Sat Jul 30 09:15:53 2022 +0000 > +++ b/cc-mode.el Tue Aug 02 19:14:15 2022 +0000 > @@ -2412,49 +2412,59 @@ > (and (/= new-pos pos) new-pos)))) > > (defun c-fl-decl-end (pos) > - ;; If POS is inside a declarator, return the end of the token that follows > - ;; the declarator, otherwise return nil. POS being in a literal does not > - ;; count as being in a declarator (on pragmatic grounds). POINT is not > - ;; preserved. > + ;; If POS is inside a declarator, return the position of the end of the > + ;; paren pair that terminates it, or of the end of the token that follows > + ;; the declarator, otherwise return nil. If there is no such token, the end > + ;; of the last token in the buffer is used. POS being in a literal is now > + ;; (2022-07) handled correctly. POINT is not preserved. > (goto-char pos) > (let ((lit-start (c-literal-start)) > (lim (c-determine-limit 1000)) > enclosing-attribute pos1) > - (unless lit-start > - (c-backward-syntactic-ws > - lim) > - (when (setq enclosing-attribute (c-enclosing-c++-attribute)) > - (goto-char (car enclosing-attribute))) ; Only happens in C++ Mode. > - (when (setq pos1 (c-on-identifier)) > - (goto-char pos1) > - (let ((lim (save-excursion > - (and (c-beginning-of-macro) > - (progn (c-end-of-macro) (point)))))) > - (and (c-forward-declarator lim) > - (if (eq (char-after) ?\() > - (and > - (c-go-list-forward nil lim) > - (progn (c-forward-syntactic-ws lim) > - (not (eobp))) > - (progn > - (if (looking-at c-symbol-char-key) > - ;; Deal with baz (foo((bar)) type var), where > - ;; foo((bar)) is not semantically valid. The result > - ;; must be after var). > - (and > - (goto-char pos) > - (setq pos1 (c-on-identifier)) > - (goto-char pos1) > - (progn > - (c-backward-syntactic-ws lim) > - (eq (char-before) ?\()) > - (c-fl-decl-end (1- (point)))) > - (c-backward-syntactic-ws lim) > - (point)))) > - (and (progn (c-forward-syntactic-ws lim) > - (not (eobp))) > + (if lit-start > + (goto-char lit-start)) > + (c-backward-syntactic-ws lim) > + (when (setq enclosing-attribute (c-enclosing-c++-attribute)) > + (goto-char (car enclosing-attribute)) ; Only happens in C++ Mode. > + (c-backward-syntactic-ws lim)) > + (while (and (> (point) lim) > + (memq (char-before) '(?\[ ?\())) > + (backward-char) > + (c-backward-syntactic-ws lim)) > + (when (setq pos1 (c-on-identifier)) > + (goto-char pos1) > + (let ((lim (save-excursion > + (and (c-beginning-of-macro) > + (progn (c-end-of-macro) (point)))))) > + (and (c-forward-declarator lim) > + (if (and (eq (char-after) ?\() > + (c-go-list-forward nil lim)) > + (and > + (progn (c-forward-syntactic-ws lim) > + (not (eobp))) > + (progn > + (if (looking-at c-symbol-char-key) > + ;; Deal with baz (foo((bar)) type var), where > + ;; foo((bar)) is not semantically valid. The result > + ;; must be after var). > + (and > + (goto-char pos) > + (setq pos1 (c-on-identifier)) > + (goto-char pos1) > + (progn > + (c-backward-syntactic-ws lim) > + (eq (char-before) ?\()) > + (c-fl-decl-end (1- (point)))) > (c-backward-syntactic-ws lim) > - (point))))))))) > + (point)))) > + (if (progn (c-forward-syntactic-ws lim) > + (not (eobp))) > + (c-forward-over-token) > + (let ((lit-start (c-literal-start))) > + (when lit-start > + (goto-char lit-start)) > + (c-backward-syntactic-ws))) > + (and (>= (point) pos) (point)))))))) > > (defun c-change-expand-fl-region (_beg _end _old-len) > ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock > > --------------D3124A73698BF7E5EC3EFD49 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Thank you very much for this fix, Alan. I have now tested it both with my test case and in more realistic code, and it seems to fix the issues I was encountering – thank you!

Sorry for the delay on getting back to you about this.

Bill

Alan Mackenzie wrote on 8/2/22 1:30 PM:
Hello again, Bill.

On Sat, Jul 30, 2022 at 17:14:43 +0300, Eli Zaretskii wrote:
Cc: Bill Sacks <sacks@ucar.edu>
Date: Sat, 30 Jul 2022 13:05:24 +0000
From: Alan Mackenzie <acm@muc.de>

  
1. Start emacs -Q.
2. Insert the following file in C Mode:

  
void myfunc(

  
  ) {

  
}

  
3. In line 2 (the first blank line) type "<TAB>int somevar".
4. Note that somevar is not fontified.  This is a bug, given that the
  arglist to myfunc is terminated with a ) on line 3.
5. Do something (e.g. typing M-x) to cause a redisplay.  somevar gets
  its correct face.
6. Note that any insertion or deletion in L2 causes somevar to lose its
  fontification.  This is a bug.
7. (After 6).  Move point onto somevar and do C-u C-x =.  This shows
  that the face text property is set on the character despite the face
  not appearing on the screen.
This bug, although the symptoms were similar to the other bug you
reported, was an entirely different bug, more difficult to fix.

I now have a patch for it, and would ask you to apply the patch to your
Emacs 28.1 and byte compile the files in it, as before.  (As before,
help is available from me by private email.)  Then please test it on
your actual C code and let us know how it went.  Thanks!



diff -r e4e62074b8a6 cc-engine.el
--- a/cc-engine.el	Sat Jul 30 09:15:53 2022 +0000
+++ b/cc-engine.el	Tue Aug 02 19:14:15 2022 +0000
@@ -9576,7 +9576,7 @@
 	 (or (= paren-depth 0)
 	     (c-safe (goto-char (scan-lists (point) 1 paren-depth))))
 
-	 (<= (point) limit)
+	 (< (point) limit)
 
 	 ;; Skip over any trailing bit, such as "__attribute__".
 	 (progn
diff -r e4e62074b8a6 cc-mode.el
--- a/cc-mode.el	Sat Jul 30 09:15:53 2022 +0000
+++ b/cc-mode.el	Tue Aug 02 19:14:15 2022 +0000
@@ -2412,49 +2412,59 @@
       (and (/= new-pos pos) new-pos))))
 
 (defun c-fl-decl-end (pos)
-  ;; If POS is inside a declarator, return the end of the token that follows
-  ;; the declarator, otherwise return nil.  POS being in a literal does not
-  ;; count as being in a declarator (on pragmatic grounds).  POINT is not
-  ;; preserved.
+  ;; If POS is inside a declarator, return the position of the end of the
+  ;; paren pair that terminates it, or of the end of the token that follows
+  ;; the declarator, otherwise return nil.  If there is no such token, the end
+  ;; of the last token in the buffer is used.  POS being in a literal is now
+  ;; (2022-07) handled correctly.  POINT is not preserved.
   (goto-char pos)
   (let ((lit-start (c-literal-start))
 	(lim (c-determine-limit 1000))
 	enclosing-attribute pos1)
-    (unless lit-start
-      (c-backward-syntactic-ws
-       lim)
-      (when (setq enclosing-attribute (c-enclosing-c++-attribute))
-	(goto-char (car enclosing-attribute))) ; Only happens in C++ Mode.
-      (when (setq pos1 (c-on-identifier))
-	(goto-char pos1)
-	(let ((lim (save-excursion
-		     (and (c-beginning-of-macro)
-			  (progn (c-end-of-macro) (point))))))
-	  (and (c-forward-declarator lim)
-	       (if (eq (char-after) ?\()
-		   (and
-		    (c-go-list-forward nil lim)
-		    (progn (c-forward-syntactic-ws lim)
-			   (not (eobp)))
-		    (progn
-		      (if (looking-at c-symbol-char-key)
-			  ;; Deal with baz (foo((bar)) type var), where
-			  ;; foo((bar)) is not semantically valid.  The result
-			  ;; must be after var).
-			  (and
-			   (goto-char pos)
-			   (setq pos1 (c-on-identifier))
-			   (goto-char pos1)
-			   (progn
-			     (c-backward-syntactic-ws lim)
-			     (eq (char-before) ?\())
-			   (c-fl-decl-end (1- (point))))
-			(c-backward-syntactic-ws lim)
-			(point))))
-		 (and (progn (c-forward-syntactic-ws lim)
-			     (not (eobp)))
+    (if lit-start
+	(goto-char lit-start))
+    (c-backward-syntactic-ws lim)
+    (when (setq enclosing-attribute (c-enclosing-c++-attribute))
+      (goto-char (car enclosing-attribute)) ; Only happens in C++ Mode.
+      (c-backward-syntactic-ws lim))
+    (while (and (> (point) lim)
+		(memq (char-before) '(?\[ ?\()))
+      (backward-char)
+      (c-backward-syntactic-ws lim))
+    (when (setq pos1 (c-on-identifier))
+      (goto-char pos1)
+      (let ((lim (save-excursion
+		   (and (c-beginning-of-macro)
+			(progn (c-end-of-macro) (point))))))
+	(and (c-forward-declarator lim)
+	     (if (and (eq (char-after) ?\()
+		      (c-go-list-forward nil lim))
+		 (and
+		  (progn (c-forward-syntactic-ws lim)
+			 (not (eobp)))
+		  (progn
+		    (if (looking-at c-symbol-char-key)
+			;; Deal with baz (foo((bar)) type var), where
+			;; foo((bar)) is not semantically valid.  The result
+			;; must be after var).
+			(and
+			 (goto-char pos)
+			 (setq pos1 (c-on-identifier))
+			 (goto-char pos1)
+			 (progn
+			   (c-backward-syntactic-ws lim)
+			   (eq (char-before) ?\())
+			 (c-fl-decl-end (1- (point))))
 		      (c-backward-syntactic-ws lim)
-		      (point)))))))))
+		      (point))))
+	       (if (progn (c-forward-syntactic-ws lim)
+			  (not (eobp)))
+		   (c-forward-over-token)
+		 (let ((lit-start (c-literal-start)))
+		   (when lit-start
+		       (goto-char lit-start))
+		   (c-backward-syntactic-ws)))
+	       (and (>= (point) pos) (point))))))))
 
 (defun c-change-expand-fl-region (_beg _end _old-len)
   ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock



--------------D3124A73698BF7E5EC3EFD49-- From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 24 11:10:27 2022 Received: (at 56841-done) by debbugs.gnu.org; 24 Aug 2022 15:10:27 +0000 Received: from localhost ([127.0.0.1]:47656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oQs1T-0008Ho-A3 for submit@debbugs.gnu.org; Wed, 24 Aug 2022 11:10:27 -0400 Received: from colin.muc.de ([193.149.48.1]:36791 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1oQs1Q-0008HO-JV for 56841-done@debbugs.gnu.org; Wed, 24 Aug 2022 11:10:26 -0400 Received: (qmail 89364 invoked by uid 3782); 24 Aug 2022 15:10:17 -0000 Received: from acm.muc.de (p4fe15720.dip0.t-ipconnect.de [79.225.87.32]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 24 Aug 2022 17:10:17 +0200 Received: (qmail 22700 invoked by uid 1000); 24 Aug 2022 15:10:17 -0000 Date: Wed, 24 Aug 2022 15:10:17 +0000 To: Bill Sacks Subject: Re: bug#56841: Emacs-28 C Mode: Fontification errors when arglist closing ) is on next line Message-ID: References: <83a68q6624.fsf@gnu.org> <94a87aa6-63d1-dcd9-cbb3-2c9b585fad28@ucar.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <94a87aa6-63d1-dcd9-cbb3-2c9b585fad28@ucar.edu> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 56841-done Cc: Eli Zaretskii , 56841-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Bill. On Mon, Aug 22, 2022 at 10:08:48 -0600, Bill Sacks wrote: > Thank you very much for this fix, Alan. I have now tested it both with > my test case and in more realistic code, and it seems to fix the issues > I was encountering – thank you! Thanks for the testing! > Sorry for the delay on getting back to you about this. No problem! I've now committed the fix to the master branch of Emacs at savannah, and I'm closing the bug with this post. > Bill [ .... ] -- Alan Mackenzie (Nuremberg, Germany). From unknown Sun Aug 17 04:19:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 22 Sep 2022 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator