Next: Idle Timers, Up: Timers [Index]
timerp OBJECTThis predicate function returns non-nil if object is a timer.
run-at-timeThis sets up a timer that calls the function ‘FUNCTION’ with arguments ‘ARGS’ at time ‘TIME’.
may specify an absolute or a relative time.
encode-time can also be used to specify an absolute value
for time.
If ‘REPEAT’ is a number (integer or floating point), the timer is scheduled to run again every ‘REPEAT’ seconds after time. If ‘REPEAT’ is ‘nil’, the timer runs only once.
Any invocation of a timer can be late. Lateness of one repetition has no effect on the scheduled time of the next repetition. If you want a timer to run again no less than ‘n’ seconds after the last invocation, don’t use the ‘REPEAT’ argument. Instead, the timer function should explicitly reschedule the timer.
In most cases, ‘REPEAT’ has no effect on when first call takes
place—‘TIME’ alone specifies that. There is one exception: if ‘TIME’ is
‘t’, then the timer runs whenever the time is a multiple of repeat seconds
after the epoch. This is useful for functions like display-time.
The function run-at-time returns a timer value that
identifies the particular scheduled future action. You can use this value to
call cancel-timer.
run-with-timerThis is exactly the same as run-at-time (so see that definition for an
explanation of the parameters; ‘SECS’ is passed as ‘TIME’ to that function),
but is meant to be used when the delay is specified in seconds.
timer-max-repeatsThis variable’s value specifies the maximum number of times to repeat calling a timer function in a row, when many previously scheduled calls were unavoidably delayed.
with-timeoutThis macro works by setting a timer to run after ‘SECONDS’ seconds. If ‘BODY’ finishes before that time, it cancels the timer. If the timer actually runs, it terminates execution of ‘BODY’, then executes ‘TIMEOUT-FORMS’.
Execute ‘BODY’, but give up after ‘SECONDS’ seconds. If ‘BODY’ finishes before
the time is up, with-timeout returns the value of the last form in body. If,
however, the execution of body is cut short by the timeout, then
with-timeout executes all the ‘TIMEOUT-FORMS’ and returns the value of the
last of them.
Since timers can run within a Lisp program only when the program calls a
primitive that can wait, with-timeout cannot stop executing ‘BODY’ while it
is in the midst of a computation—only when it calls one of those primitives.
So use with-timeout only with a body that waits for input, not one that does
a long computation.
The function y-or-n-p-with-timeout provides a simple way to use a timer to
avoid waiting too long for an answer.
cancel-timerThis cancels the requested action for timer, which should be a
timer—usually, one previously returned by run-at-time or
run-with-idle-timer. This cancels the effect of that call to one of these
functions; the arrival of the specified time will not cause anything special
to happen.
list-timersNext: Idle Timers, Up: Timers [Index]