GNU bug report logs - #52297
29.0.50; Error in c-force-redisplay timer

Previous Next

Package: emacs;

Reported by: Eli Zaretskii <eliz <at> gnu.org>

Date: Sun, 5 Dec 2021 07:28:01 UTC

Severity: normal

Merged with 52709

Found in version 29.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #40 received at 52297 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: martin rudalics <rudalics <at> gmx.at>
Cc: acm <at> muc.de, Lars Ingebrigtsen <larsi <at> gnus.org>, 52297 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#52297: 29.0.50; Error in c-force-redisplay timer
Date: Wed, 9 Feb 2022 20:06:18 +0000
Hello again, Martin.

On Wed, Feb 09, 2022 at 19:21:20 +0100, martin rudalics wrote:
>  > Thanks.  With that file, I can reproduce the bug.  I'll set about fixing
>  > it.

> TIA, martin

I think the problem is that the buffer wasn't set in the timer function,
so c-force-redisplay was, in the bug scenario, trying to fontify a
spurious buffer.

Would you try out the following patch, please, which fixes this bug.
I'm optimistic it will have fixed the main bug.

Thanks!



diff -r 67fe5c0a9d03 cc-fonts.el
--- a/cc-fonts.el	Mon Jan 31 17:34:20 2022 +0000
+++ b/cc-fonts.el	Wed Feb 09 19:58:26 2022 +0000
@@ -2256,12 +2256,13 @@
 ;; redisplay.
 (defvar c-re-redisplay-timer nil)
 
-(defun c-force-redisplay (start end)
+(defun c-force-redisplay (buffer start end)
   ;; Force redisplay immediately.  This assumes `font-lock-support-mode' is
   ;; 'jit-lock-mode.  Set the variable `c-re-redisplay-timer' to nil.
-  (save-excursion (c-font-lock-fontify-region start end))
-  (jit-lock-force-redisplay (copy-marker start) (copy-marker end))
-  (setq c-re-redisplay-timer nil))
+  (with-current-buffer buffer
+    (save-excursion (c-font-lock-fontify-region start end))
+    (jit-lock-force-redisplay (copy-marker start) (copy-marker end))
+    (setq c-re-redisplay-timer nil)))
 
 (defun c-fontify-new-found-type (type)
   ;; Cause the fontification of TYPE, a string, wherever it occurs in the
@@ -2291,6 +2292,7 @@
 			 (not c-re-redisplay-timer))
 		(setq c-re-redisplay-timer
 		      (run-with-timer 0 nil #'c-force-redisplay
+				      (current-buffer)
 				      (match-beginning 0) (match-end 0)))))))))))
 
 


-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 3 years and 99 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.