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

From: Manuel Giraud <[email-masked]>
Date: Tue, 17 Sep 2024 10:19:41 +0200

Eli Zaretskii <[email-masked]> writes:

[...]

> diff --git a/lisp/midnight.el b/lisp/midnight.el
> index bfa99d6..73d049a 100644
> --- a/lisp/midnight.el
> +++ b/lisp/midnight.el
> @@ -205,10 +205,11 @@ midnight-delay-set
>    (cl-assert (eq symb 'midnight-delay) t
>               "Invalid argument to `midnight-delay-set': `%s'")
>    (set symb tm)
> -  (when (timerp midnight-timer) (cancel-timer midnight-timer))
> -  (setq midnight-timer
> -        (run-at-time (if (numberp tm) (+ (midnight-next) tm) tm)
> -                     midnight-period #'run-hooks 'midnight-hook)))
> +  (when (timerp midnight-timer)
> +    (cancel-timer midnight-timer)
> +    (setq midnight-timer
> +          (run-at-time (if (numberp tm) (+ (midnight-next) tm) tm)
> +                       midnight-period #'run-hooks 'midnight-hook))))
>  
>  (defcustom midnight-delay 3600
>    "The number of seconds after the midnight when the `midnight-timer' is run.
>
> Can you try this and see if it solves the problem, and doesn't break
> the other uses of midnight-mode and or clean-buffer-list?

Thanks.  It solves the issue of activacting the midnight-mode: now
`clean-buffer-list' is just done once and won't run the next day.  But
now, when I do M-x midnight-mode, I get the following error:

--8<---------------cut here---------------start------------->8---
timer--activate: Invalid or uninitialized timer
--8<---------------cut here---------------end--------------->8---
-- 
Manuel Giraud