45 |
(defun timer-set-time (timer time &optional delta) |
(defun timer-set-time (timer time &optional delta) |
46 |
"Set the trigger time of TIMER to TIME. |
"Set the trigger time of TIMER to TIME. |
47 |
TIME must be in the internal format returned by, e.g., `current-time'. |
TIME must be in the internal format returned by, e.g., `current-time'. |
48 |
If optional third argument DELTA is a non-zero integer, make the timer |
If optional third argument DELTA is a positive number, make the timer |
49 |
fire repeatedly that many seconds apart." |
fire repeatedly that many seconds apart." |
50 |
(or (timerp timer) |
(or (timerp timer) |
51 |
(error "Invalid timer")) |
(error "Invalid timer")) |
127 |
|
|
128 |
(defun timer-inc-time (timer secs &optional usecs) |
(defun timer-inc-time (timer secs &optional usecs) |
129 |
"Increment the time set in TIMER by SECS seconds and USECS microseconds. |
"Increment the time set in TIMER by SECS seconds and USECS microseconds. |
130 |
SECS may be a fraction." |
SECS may be a fraction. If USECS is omitted, that means it is zero." |
131 |
(let ((time (timer-relative-time |
(let ((time (timer-relative-time |
132 |
(list (aref timer 1) (aref timer 2) (aref timer 3)) |
(list (aref timer 1) (aref timer 2) (aref timer 3)) |
133 |
secs |
secs |
137 |
(aset timer 3 (or (nth 2 time) 0)))) |
(aset timer 3 (or (nth 2 time) 0)))) |
138 |
|
|
139 |
(defun timer-set-time-with-usecs (timer time usecs &optional delta) |
(defun timer-set-time-with-usecs (timer time usecs &optional delta) |
140 |
"Set the trigger time of TIMER to TIME. |
"Set the trigger time of TIMER to TIME plus USECS. |
141 |
TIME must be in the internal format returned by, e.g., `current-time'. |
TIME must be in the internal format returned by, e.g., `current-time'. |
142 |
If optional third argument DELTA is a non-zero integer, make the timer |
The microsecond count from TIME is ignored, and USECS is used instead. |
143 |
|
If optional fourth argument DELTA is a positive number, make the timer |
144 |
fire repeatedly that many seconds apart." |
fire repeatedly that many seconds apart." |
145 |
(or (timerp timer) |
(or (timerp timer) |
146 |
(error "Invalid timer")) |
(error "Invalid timer")) |
147 |
(aset timer 1 (car time)) |
(aset timer 1 (nth 0 time)) |
148 |
(aset timer 2 (if (consp (cdr time)) (car (cdr time)) (cdr time))) |
(aset timer 2 (nth 1 time)) |
149 |
(aset timer 3 usecs) |
(aset timer 3 usecs) |
150 |
(aset timer 4 (and (numberp delta) (> delta 0) delta)) |
(aset timer 4 (and (numberp delta) (> delta 0) delta)) |
151 |
timer) |
timer) |
152 |
|
(make-obsolete 'timer-set-time-with-usecs |
153 |
|
"use `timer-set-time' and `timer-inc-time' instead." |
154 |
|
"21.4") |
155 |
|
|
156 |
(defun timer-set-function (timer function &optional args) |
(defun timer-set-function (timer function &optional args) |
157 |
"Make TIMER call FUNCTION with optional ARGS when triggering." |
"Make TIMER call FUNCTION with optional ARGS when triggering." |
261 |
(let ((high (- (car time) (aref timer 1))) |
(let ((high (- (car time) (aref timer 1))) |
262 |
(low (- (nth 1 time) (aref timer 2)))) |
(low (- (nth 1 time) (aref timer 2)))) |
263 |
(+ low (* high 65536)))) |
(+ low (* high 65536)))) |
264 |
|
|
265 |
(defun timer-event-handler (timer) |
(defun timer-event-handler (timer) |
266 |
"Call the handler for the timer TIMER. |
"Call the handler for the timer TIMER. |
267 |
This function is called, by name, directly by the C code." |
This function is called, by name, directly by the C code." |