From 7fe165d7c7d0bcdd7be93457658504aed76df67c Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Mon, 24 Jul 2000 22:05:31 +0000 Subject: [PATCH] (timer-activate-when-idle): Add optional parameter DONT-WAIT. Update docstring. (run-with-idle-timer): Specify extra parameter to timer-activate-when-idle, so that timer will be activated immediately if Emacs is already idle. --- lisp/timer.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/timer.el b/lisp/timer.el index 66b16b60fb1..e91fd64ab2f 100644 --- a/lisp/timer.el +++ b/lisp/timer.el @@ -183,8 +183,11 @@ fire repeatedly that many seconds apart." nil) (error "Invalid or uninitialized timer"))) -(defun timer-activate-when-idle (timer) - "Arrange to activate TIMER whenever Emacs is next idle." +(defun timer-activate-when-idle (timer &optional dont-wait) + "Arrange to activate TIMER whenever Emacs is next idle. +If optional argument DONT-WAIT is non-nil, then enable the +timer to activate immediately, or at the right time, if Emacs +is already idle." (if (and (timerp timer) (integerp (aref timer 1)) (integerp (aref timer 2)) @@ -206,7 +209,7 @@ fire repeatedly that many seconds apart." (if last (setcdr last (cons timer timers)) (setq timer-idle-list (cons timer timers))) - (aset timer 0 t) + (aset timer 0 (not dont-wait)) (aset timer 7 t) nil) (error "Invalid or uninitialized timer"))) @@ -384,7 +387,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) -- 2.39.2