From 6160f9334ebdf9fb4c1b06b4da1044e03b6b7459 Mon Sep 17 00:00:00 2001 From: "Kim F. Storm" Date: Fri, 14 May 2004 23:09:35 +0000 Subject: [PATCH] (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. --- lisp/emacs-lisp/timer.el | 13 ++++++++----- 1 file 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." (aset timer 6 args) timer) -(defun timer-activate (timer) +(defun timer-activate (timer &optional triggered-p) "Put TIMER on the list of active timers." (if (and (timerp timer) (integerp (aref timer 1)) @@ -184,7 +184,7 @@ fire repeatedly that many seconds apart." (if last (setcdr last (cons timer timers)) (setq timer-list (cons timer timers))) - (aset timer 0 nil) + (aset timer 0 triggered-p) (aset timer 7 nil) nil) (error "Invalid or uninitialized timer"))) @@ -270,7 +270,7 @@ This function is called, by name, directly by the C code." (setq timer-event-last timer) (let ((inhibit-quit t)) (if (timerp timer) - (progn + (let (retrigger) ;; Delete from queue. (cancel-timer timer) ;; Re-schedule if requested. @@ -287,13 +287,16 @@ This function is called, by name, directly by the C code." (aref timer 4)))) (if (> repeats timer-max-repeats) (timer-inc-time timer (* (aref timer 4) repeats))))) - (timer-activate timer))) + (timer-activate timer t) + (setq retrigger t))) ;; Run handler. ;; We do this after rescheduling so that the handler function ;; can cancel its own timer successfully with cancel-timer. (condition-case nil (apply (aref timer 5) (aref timer 6)) - (error nil))) + (error nil)) + (if retrigger + (aset timer 7 nil))) (error "Bogus timer event")))) ;; This function is incompatible with the one in levents.el. -- 2.39.5