GNU bug report logs -
#71699
29.3; run-at-time early run
Previous Next
Full log
Message #8 received at 71699 <at> debbugs.gnu.org (full text, mbox):
> From: Christopher Howard <christopher <at> librehacker.com>
> Date: Fri, 21 Jun 2024 08:45:53 -0800
>
>
> emacs -Q
> M-x eval-expression
> (run-at-time "04:00" 86400 (lambda () (message "timer ran")))
>
> >From the documentation, I expect this lambda to run in the future, at 4:00 in the morning. However, it also runs once when I first eval this run-at-time expression, i.e., when I setup the timer. From looking at list-timers, I can see that it will run again at 4 in the morning, which is good, but I do not want the function to run when the timer is first setup.
>
> I tried a different approach, passing in a named function instead of a lambda, but got the same result.
I guess you evaluated the expression at time that was after 4AM that
day? If so, this is expected behavior, because times are interpreted
as times _today_. The ELisp manual says:
-- Command: run-at-time time repeat function &rest args
This sets up a timer that calls the function FUNCTION with
arguments ARGS at time 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.
TIME may specify an absolute or a relative time.
Absolute times may be specified using a string with a limited
variety of formats, and are taken to be times _today_, even if
already in the past. The recognized forms are ‘XXXX’, ‘X:XX’, or
‘XX:XX’ (military time), and ‘XXam’, ‘XXAM’, ‘XXpm’, ‘XXPM’,
‘XX:XXam’, ‘XX:XXAM’, ‘XX:XXpm’, or ‘XX:XXPM’.
So I don't think this is a bug.
This bug report was last modified 1 year and 48 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.