From 171d328e8dd84e6d9e8d168e4e91fe989b65b138 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Sun, 20 Aug 2006 12:16:26 +0000 Subject: (run-with-idle-timer): Pass t to timer-activate-when-idle, so timer can run before Emacs becomes non-idle again. --- lisp/emacs-lisp/timer.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/timer.el') diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index a98dd60fc21..ed85bc765f7 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el @@ -413,6 +413,8 @@ This function is for compatibility; see also `run-with-timer'." "Perform an action the next time Emacs is idle for SECS seconds. The action is to call FUNCTION with arguments ARGS. SECS may be an integer or a floating point number. +If Emacs is currently idle, and has been idle for N seconds (N < SECS), +then it will call FUNCTION in SECS - N seconds from now. If REPEAT is non-nil, do the action each time Emacs has been idle for exactly SECS seconds (that is, only once for each time Emacs becomes idle). @@ -425,7 +427,7 @@ This function returns a timer object which you can use in `cancel-timer'." (let ((timer (timer-create))) (timer-set-function timer function args) (timer-set-idle-time timer secs repeat) - (timer-activate-when-idle timer) + (timer-activate-when-idle timer t) timer)) (defun with-timeout-handler (tag) -- cgit v1.2.1 From 1063efe807c0195c62f2dc22bcc78c61cf25c376 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Thu, 24 Aug 2006 23:40:00 +0000 Subject: * emacs-lisp/timer.el (timer-set-idle-time, run-with-idle-timer): Accept internal time format for SECS arg. (timer-relative-time): Doc fix. * jit-lock.el: "Stealth fontification by requeuing timers" patch, adapted from Martin Rudalics. (jit-lock-stealth-repeat-timer, jit-lock-stealth-buffers): New vars. (jit-lock-mode): Create jit-lock-stealth-repeat-timer. (jit-lock-stealth-fontify): Reschedule as a idle timer instead of using sit-for. --- lisp/emacs-lisp/timer.el | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp/timer.el') diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index ed85bc765f7..82eac50c874 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el @@ -60,14 +60,22 @@ fire repeatedly that many seconds apart." (defun timer-set-idle-time (timer secs &optional repeat) "Set the trigger idle time of TIMER to SECS. +SECS may be an integer, floating point number, or the internal +time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'. If optional third argument REPEAT is non-nil, make the timer fire each time Emacs is idle for that many seconds." (or (timerp timer) (error "Invalid timer")) - (aset timer 1 0) - (aset timer 2 0) - (aset timer 3 0) - (timer-inc-time timer secs) + (if (consp secs) + (progn (aset timer 1 (car secs)) + (aset timer 2 (if (consp (cdr secs)) (car (cdr secs)) (cdr secs))) + (aset timer 3 (or (and (consp (cdr secs)) (consp (cdr (cdr secs))) + (nth 2 secs)) + 0))) + (aset timer 1 0) + (aset timer 2 0) + (aset timer 3 0) + (timer-inc-time timer secs)) (aset timer 4 repeat) timer) @@ -104,7 +112,7 @@ of SECS seconds since the epoch. SECS may be a fraction." (defun timer-relative-time (time secs &optional usecs) "Advance TIME by SECS seconds and optionally USECS microseconds. -SECS may be a fraction." +SECS may be either an integer or a floating point number." (let ((high (car time)) (low (if (consp (cdr time)) (nth 1 time) (cdr time))) (micro (if (numberp (car-safe (cdr-safe (cdr time)))) @@ -412,7 +420,8 @@ This function is for compatibility; see also `run-with-timer'." (defun run-with-idle-timer (secs repeat function &rest args) "Perform an action the next time Emacs is idle for SECS seconds. The action is to call FUNCTION with arguments ARGS. -SECS may be an integer or a floating point number. +SECS may be an integer, a floating point number, or the internal +time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'. If Emacs is currently idle, and has been idle for N seconds (N < SECS), then it will call FUNCTION in SECS - N seconds from now. -- cgit v1.2.1