The documentation for `run-at-time' states:
TIME should be a string recognized by `timer-parse-time', like
[...]
nil meaning now, [...]
Unfortunately, timer-func's run-at-time rewrite represents this by
passing zero into `start-itimer'... and, as it always has,
`start-itimer' keels over backwards with `itimer timeout value not
positive'. There's existing code that depends on this (even if it
weren't an ancient interface present partly for GNU Emacs compatibility,
which therefore *has* to conform to its docs).
This breaks, among other things, Dave Pearson's uptimes.el, in a nicely
catastrophic fashion (an exception's thrown during auto-autoloads
reading). It probably breaks other stuff but I wasn't going to go
hunting with an XEmacs that wouldn't start. :)
I submit that the problem here is not in the `run-at-time' rewrite, but
in `start-itimer'. There's nothing conceptually wrong in submitting a
timer that should fire instantly, or as near to `instantly' as itimer
permits: you can't quite do it `instantly' or the subprocess
implementation could well end up firing a timer in the past, and we've
already had bugs in that area in the *previous* implementation of
`run-at-time'...
More significantly, itimer.el isn't even internally consistent: pretty
much everything else that checks time ranges in itimer does it through
`check-nonnegative-number', and *that* accepts zero as a valid value,
even though we know that zero itself is a bad idea with itimer (as
opposed to a very small number, which is fine).
It seems to me that it's valid programming practice to have a fires-now
instantly-repeats itimer, because the itimer function might reset its
own repeat period to something else. So for now I'm running with this
staggeringly exciting patch (against 21.4.16), reasoning that the
difference between `now' and `a millisecond in the future' had better
not make a difference to any sane code, and leaving `start-itimer'
as is, on the basis that if a zero gets into the interval field now,
it's a sign of a bug:
2005-01-24 Nix <nix(a)esperi.org.uk>
* itimer.el (set-itimer-value): Set zero timer intervals to
the minimum time instead.
Index: lisp/itimer.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/itimer.el,v
retrieving revision 1.8.2.1
diff -u -r1.8.2.1 itimer.el
--- lisp/itimer.el 2004/01/31 03:35:49 1.8.2.1
+++ lisp/itimer.el 2005/01/24 23:44:23
@@ -226,6 +226,8 @@
must be an integer.
Returns VALUE."
(check-itimer itimer)
+ (if (= value 0)
+ (setq value itimer-short-interval))
(check-nonnegative-number value)
(let ((inhibit-quit t))
;; If the itimer is in the active list, and under the new
--
`Blish is clearly in love with language. Unfortunately,
language dislikes him intensely.' --- Russ Allbery