Subject: Re: bug#73291: 31.0.50; `clean-buffer-list' activates `midnight-mode'

From: Michael Heerdegen <[email-masked]>
Date: Tue, 17 Sep 2024 21:07:04 +0200

Eli Zaretskii <[email-masked]> writes:

> Alternatively, we could call run-at-time directly from midnight-mode.

Short answer: This would be better.

Long answer: The current design is bad: `midnight-delay-set', the custom
setter of the user option `midnight-delay', is the _only_ place in the
whole library where a timer is ever created.  The mode function itself
does not start a timer (also not indirectly).

`midnight-delay-set' OTOH starts the timer unconditionally, no matter if
`midnight-mode' is on or off.  The timer function also doesn't check
whether the mode is on.

We need to redesign: we should make the mode start and stop the timer.
The setter function should only manipulate the timer, and only when the
mode is really turned on.

Michael.