emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: jit-lock timer etc.


From: Kim F. Storm
Subject: Re: jit-lock timer etc.
Date: Wed, 23 Aug 2006 15:09:30 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

martin rudalics <address@hidden> writes:

>> I think this ought to use run-with-idle-timer
>> and current-idle-time, as in my patch.
>
> I was not able to accomplish that since the idle timer does not trigger.


I can hardly imagine emacs being idle for more than 2^28 seconds, so
it seems safe to simplify it to return a cons (SECS . USECS)  [see patch below]

> In analogy to your patch I replaced the above by
>
>       (when (and jit-lock-stealth-buffers jit-lock-stealth-time)
>       ;; Call us again.
>       (timer-set-idle-time jit-lock-stealth-repeat-timer (current-idle-time))
>       (timer-inc-time jit-lock-stealth-repeat-timer delay)
>       (timer-activate-when-idle jit-lock-stealth-repeat-timer t)
>
> but I suspect that calling `timer-set-idle-time' with the return value
> of `current-idle-time' does not DTRT:

With the above change to current-idle-time, it seems the following
should work:

       (when (and jit-lock-stealth-buffers jit-lock-stealth-time)
        ;; Call us again.
        (let ((idle (current-idle-time)))
          (when idle
            (timer-set-idle-time jit-lock-stealth-repeat-timer delay)
            (timer-inc-time jit-lock-stealth-repeat-timer (car idle) (cdr idle))
            (timer-activate-when-idle jit-lock-stealth-repeat-timer t)))


Notice the swap in the args in the first two calls.
That's because inc-time accepts an USECS arg, while set-idle-time doesn't.



*** keyboard.c  21 Aug 2006 21:38:31 +0200      1.872
--- keyboard.c  23 Aug 2006 14:54:50 +0200      
***************
*** 4561,4571 ****
  
  DEFUN ("current-idle-time", Fcurrent_idle_time, Scurrent_idle_time, 0, 0, 0,
         /* Return the current length of Emacs idleness.
! The value is returned as a list of three integers.  The first has the
! most significant 16 bits of the seconds, while the second has the
! least significant 16 bits.  The third integer gives the microsecond
! count.
! 
  The microsecond count is zero on systems that do not provide
  resolution finer than a second.  */)
    ()
--- 4561,4567 ----
  
  DEFUN ("current-idle-time", Fcurrent_idle_time, Scurrent_idle_time, 0, 0, 0,
         /* Return the current length of Emacs idleness.
! The value is returned as a cons (SECS . USECS).
  The microsecond count is zero on systems that do not provide
  resolution finer than a second.  */)
    ()
***************
*** 4578,4588 ****
      {
        EMACS_SUB_TIME (idleness_now, now, timer_idleness_start_time);
  
!       XSETINT (result[0], (EMACS_SECS (idleness_now) >> 16) & 0xffff);
!       XSETINT (result[1], (EMACS_SECS (idleness_now) >> 0)  & 0xffff);
!       XSETINT (result[2], EMACS_USECS (idleness_now));
! 
!       return Flist (3, result);
      }
  
    return Qnil;
--- 4574,4581 ----
      {
        EMACS_SUB_TIME (idleness_now, now, timer_idleness_start_time);
  
!       return Fcons (make_number (EMACS_SECS (idleness_now)),
!                   make_number (EMACS_USECS (idleness_now)));
      }
  
    return Qnil;



-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]