Subject: Re: bug#52235: 29.0.50; Suggestion: refactor time.el into a more general 'clock' framework

From: Eli Zaretskii <[email-masked]>
Date: Thu, 02 Dec 2021 11:55:25 +0200

> From: Arthur Miller <[email-masked]>
> Cc: [email-masked]
> Date: Thu, 02 Dec 2021 10:19:37 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Isn't that what timers are for?  Why can't you use run-with-timer for
> > what you want to do?
> 
> Becaue it does not syncrhonize with clock that Emacs displays, if it
> displays.

Because it doesn't synchronize with clock... what happens?

And what do you mean by "doesn't synchronize with clock that Emacs
displays"?  The time comes from the same source, so how can it be not
synchronized? in what sense?

> As mentioned, not pretty, if different application will like to be notifed
> at "11:30" clock time, and then one happends like half minut before the other.

Emacs cannot guarantee that the notification will happen exactly at
the requested time anyway.  This limitation is in effect both for
display-time-mode and for timers, and for exactly the same reasons.

> Also there is no reason to create one timer per each application if all
> application is want to be notified when certain clock time occur.

So create a single timer that applications could register to.

> Further, if user is displaying time
> on the modeline, and those variables are all calculated, why should other
> application re-define and re-calculate them.

Because the way users customize time display on the mode line doesn't
necessarily fits the needs of an arbitrary other application which
wants to be notified at some time.  For example, users can control the
frequency and the resolution of the time display, and their
preferences for that can be correct for some other application only by
sheer luck.

My point is that I don't see why this feature has to touch
display-time-mode.  That is not clean, IMO.  It should be a separate
feature that uses timers.  The feature could create a timer the first
time it is requested, and then any additional clients could reuse the
same timer.  Of course, if you want to use a single timer, you'd still
need to solve the potentially different needs of each application: for
example, one of them may wish to be notified each second, the other
each hour.