Subject: bug#20404: 25.0.50; Sometimes no fontification with jit-lock-defer-time

From: Tassilo Horn <[email-masked]>
Date: Thu, 23 Apr 2015 07:59:15 +0200

Eli Zaretskii <[email-masked]> writes:

>> > Sounds like the idle timer that is started by jit-lock-defer-time
>> > never runs after the buffer is displayed.
>> 
>> Indeed, that's the case.  Or wait, it eventually runs but much later
>> than `jit-lock-defer-time' defines.
>> 
>> > Could it be that it already ran before the display?
>> 
>> No.  The bug report buffer is displayed first, and then it takes two
>> or three seconds until the first jit-lock kicks in.  And then the
>> buffer will be redisplayed and appears fontified.
>
> So you are saying that something prevents the timer to run at the
> prescribed time?

That seems to be the case.

> I suggest to add trace printf's in the code that traverses the
> idle-timers' list, and see why this timer doesn't run on time.

That would be

  static struct timespec
  timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers)

right?

So first I wanted to see if the deferred font-lock timer gets selected
as being ripe in the first place.  But I already failed with that; emacs
now dumps core.

--8<---------------cut here---------------start------------->8---
diff --git a/src/keyboard.c b/src/keyboard.c
index 068a47c..6231747 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -4419,6 +4419,8 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers)
   Lisp_Object chosen_timer;
   struct gcpro gcpro1;
 
+  printf ("timer_check2 ()");
+  
   nexttime = invalid_timespec ();
 
   chosen_timer = Qnil;
@@ -4513,6 +4515,10 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers)
 	  idle_timers = XCDR (idle_timers);
 	  difference = idle_timer_difference;
 	  ripe = idle_timer_ripe;
+	  if (ripe)
+	    {
+	      printf("Idle timer calling %s is ripe.", AREF (5, chosen_timer));
+	    }
 	}
 
       /* If timer is ripe, run it if it hasn't been run.  */
--8<---------------cut here---------------end--------------->8---

I think the problem is that the AREF returns the timer's function or
maybe the symbol whose function definition is the timer's function.  In
any case, that's not a char* required by printf's %s.  How do I get the
function's name in order to print that?

Bye,
Tassilo