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: Thu, 24 Aug 2006 11:07:49 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

address@hidden (Kim F. Storm) writes:

> address@hidden (Kim F. Storm) writes:
>
>>> However, returning the value in floating point might be a good method.
>>
>> That would be much better and cleaner, IMO.
>> And we can leave time-to-seconds where it is!
>>
>>> But if we do that, we should call it float-idle-time.
>>
>> The doc string will tell that the return value is a float.
>
> Actually, the return value of the new `current-idle-time' will be
> either a float or nil (if not idle).
>
> So the name `float-idle-time' would be misleading!
>
> Shall I fix current-idle-time to return a float or nil?

Here's a patch.


*** keyboard.c  21 Aug 2006 21:38:31 +0200      1.872
--- keyboard.c  24 Aug 2006 10:55:26 +0200      
***************
*** 4560,4588 ****
  }
  
  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.  */)
    ()
  {
-   EMACS_TIME now, idleness_now;
-   Lisp_Object result[3];
  
-   EMACS_GET_TIME (now);
    if (! EMACS_TIME_NEG_P (timer_idleness_start_time))
      {
!       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;
--- 4560,4578 ----
  }
  
  DEFUN ("current-idle-time", Fcurrent_idle_time, Scurrent_idle_time, 0, 0, 0,
!        /* Return the current length of Emacs idleness in seconds.
! The value is a floating point number, or nil if Emacs is not idle.  */)
    ()
  {
  
    if (! EMACS_TIME_NEG_P (timer_idleness_start_time))
      {
!       EMACS_TIME now, idle_time;
!       EMACS_GET_TIME (now);
!       EMACS_SUB_TIME (idle_time, now, timer_idleness_start_time);
  
!       return make_float ((EMACS_SECS (idle_time) * 1e6
!                         + EMACS_USECS (idle_time)) / 1e6);
      }
  
    return Qnil;

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





reply via email to

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