GNU bug report logs - #73291
31.0.50; `clean-buffer-list' activates `midnight-mode'

Previous Next

Package: emacs;

Reported by: Manuel Giraud <manuel <at> ledu-giraud.fr>

Date: Mon, 16 Sep 2024 07:51:02 UTC

Severity: normal

Found in version 31.0.50

Fixed in version 31.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 73291 <at> debbugs.gnu.org (full text, mbox):

From: Manuel Giraud <manuel <at> ledu-giraud.fr>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 73291 <at> debbugs.gnu.org
Subject: Re: bug#73291: 31.0.50; `clean-buffer-list' activates `midnight-mode'
Date: Tue, 17 Sep 2024 15:15:26 +0200
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Manuel Giraud <manuel <at> ledu-giraud.fr>
>> Cc: 73291 <at> debbugs.gnu.org
>> Date: Tue, 17 Sep 2024 10:19:41 +0200
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > 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---
>
> So not only did it activate the timer when loading the package, it
> also relied on that for the mode to work...
>
> The fix is to add
>
>   (midnight-delay-set 'midnight-delay midnight-delay)
>
> to midnight-mode function.

I tried building with the following patch but I get the same error when
doing M-x midnight-mode.

[midnight.patch (text/x-patch, inline)]
diff --git a/lisp/midnight.el b/lisp/midnight.el
index 6e1e7b5ccb7..a4b0ac00c83 100644
--- a/lisp/midnight.el
+++ b/lisp/midnight.el
@@ -57,6 +57,7 @@ midnight-mode
   ;; via setting 'midnight-delay', which calls 'midnight-delay-set',
   ;; which starts the timer.
   (when (timerp midnight-timer) (cancel-timer midnight-timer))
+  (midnight-delay-set 'midnight-delay midnight-delay)
   (if midnight-mode (timer-activate midnight-timer)))
 
 ;;; clean-buffer-list stuff
@@ -206,10 +207,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.
[Message part 3 (text/plain, inline)]
-- 
Manuel Giraud

This bug report was last modified 240 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.