diff options
| author | Kim F. Storm | 2004-05-14 23:09:35 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-05-14 23:09:35 +0000 |
| commit | 6160f9334ebdf9fb4c1b06b4da1044e03b6b7459 (patch) | |
| tree | df536a8ed4630c247823015adbf62e42d8b9a15e | |
| parent | 62f3da3b1a8e4a8d89573c761fde3dccaf08cace (diff) | |
| download | emacs-6160f9334ebdf9fb4c1b06b4da1044e03b6b7459.tar.gz emacs-6160f9334ebdf9fb4c1b06b4da1044e03b6b7459.zip | |
(timer-activate): Add optional arg triggered-p.
Use it to set triggered-p element of timer.
(timer-event-handler): Set triggered-p element non-nil while running
the timer function.
| -rw-r--r-- | lisp/emacs-lisp/timer.el | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index 4ab2ac8e0d4..395d1e70484 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el | |||
| @@ -161,7 +161,7 @@ fire repeatedly that many seconds apart." | |||
| 161 | (aset timer 6 args) | 161 | (aset timer 6 args) |
| 162 | timer) | 162 | timer) |
| 163 | 163 | ||
| 164 | (defun timer-activate (timer) | 164 | (defun timer-activate (timer &optional triggered-p) |
| 165 | "Put TIMER on the list of active timers." | 165 | "Put TIMER on the list of active timers." |
| 166 | (if (and (timerp timer) | 166 | (if (and (timerp timer) |
| 167 | (integerp (aref timer 1)) | 167 | (integerp (aref timer 1)) |
| @@ -184,7 +184,7 @@ fire repeatedly that many seconds apart." | |||
| 184 | (if last | 184 | (if last |
| 185 | (setcdr last (cons timer timers)) | 185 | (setcdr last (cons timer timers)) |
| 186 | (setq timer-list (cons timer timers))) | 186 | (setq timer-list (cons timer timers))) |
| 187 | (aset timer 0 nil) | 187 | (aset timer 0 triggered-p) |
| 188 | (aset timer 7 nil) | 188 | (aset timer 7 nil) |
| 189 | nil) | 189 | nil) |
| 190 | (error "Invalid or uninitialized timer"))) | 190 | (error "Invalid or uninitialized timer"))) |
| @@ -270,7 +270,7 @@ This function is called, by name, directly by the C code." | |||
| 270 | (setq timer-event-last timer) | 270 | (setq timer-event-last timer) |
| 271 | (let ((inhibit-quit t)) | 271 | (let ((inhibit-quit t)) |
| 272 | (if (timerp timer) | 272 | (if (timerp timer) |
| 273 | (progn | 273 | (let (retrigger) |
| 274 | ;; Delete from queue. | 274 | ;; Delete from queue. |
| 275 | (cancel-timer timer) | 275 | (cancel-timer timer) |
| 276 | ;; Re-schedule if requested. | 276 | ;; Re-schedule if requested. |
| @@ -287,13 +287,16 @@ This function is called, by name, directly by the C code." | |||
| 287 | (aref timer 4)))) | 287 | (aref timer 4)))) |
| 288 | (if (> repeats timer-max-repeats) | 288 | (if (> repeats timer-max-repeats) |
| 289 | (timer-inc-time timer (* (aref timer 4) repeats))))) | 289 | (timer-inc-time timer (* (aref timer 4) repeats))))) |
| 290 | (timer-activate timer))) | 290 | (timer-activate timer t) |
| 291 | (setq retrigger t))) | ||
| 291 | ;; Run handler. | 292 | ;; Run handler. |
| 292 | ;; We do this after rescheduling so that the handler function | 293 | ;; We do this after rescheduling so that the handler function |
| 293 | ;; can cancel its own timer successfully with cancel-timer. | 294 | ;; can cancel its own timer successfully with cancel-timer. |
| 294 | (condition-case nil | 295 | (condition-case nil |
| 295 | (apply (aref timer 5) (aref timer 6)) | 296 | (apply (aref timer 5) (aref timer 6)) |
| 296 | (error nil))) | 297 | (error nil)) |
| 298 | (if retrigger | ||
| 299 | (aset timer 7 nil))) | ||
| 297 | (error "Bogus timer event")))) | 300 | (error "Bogus timer event")))) |
| 298 | 301 | ||
| 299 | ;; This function is incompatible with the one in levents.el. | 302 | ;; This function is incompatible with the one in levents.el. |