From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73291: 31.0.50; `clean-buffer-list' activates `midnight-mode' Date: Wed, 18 Sep 2024 11:06:32 +0200 Message-ID: <87a5g5l49z.fsf@ledu-giraud.fr> References: <87plp4vy08.fsf@ledu-giraud.fr> <86ikuvd9tp.fsf@gnu.org> <87frpyofoi.fsf@ledu-giraud.fr> <87frpyh11i.fsf@web.de> <868qvqbdgl.fsf@gnu.org> <87bk0mgkvb.fsf@web.de> <86y13q9j41.fsf@gnu.org> Reply-To: Manuel Giraud Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20313"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Michael Heerdegen , 73291@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 18 11:07:14 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sqqeY-00059n-1f for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 18 Sep 2024 11:07:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqqe8-0006XS-NI; Wed, 18 Sep 2024 05:06:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqqe7-0006XJ-4a for bug-gnu-emacs@gnu.org; Wed, 18 Sep 2024 05:06:47 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sqqe6-0002X7-Qk for bug-gnu-emacs@gnu.org; Wed, 18 Sep 2024 05:06:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=BWpqVDjLXARSa+T+VluAp4M1v8w9ip88j+dkhxr9nSc=; b=Twy/gLAQ631vOTh3GsaSxL1xDM6QOilaFmluWn7nKt5UaKvpuSIN+bHl5UFzbbxn3dTn7JCcudShKLYEd/EnUXJ4PSnazvg/tKKSK8SWPbJgCox7BK8q8IkhyMK5ITW9reFhmrYhO829P5g6eer/kHaxUpVcNc/7aB118JVqLahZwXlHvcTqx91nTR+RfDyBFVX2UEH//CJ9JIFz5+bsDPXhfz1KeMD1NSZyal+M+y+s305SM6db+h/a+BRJipcswPs8YLwfljMYqzoMEhRAFIiPD/lTEIfSPOpD+CHw9JDwL7ugVCtMm2BHlBo5cz5DfsUd8Gmo3khAWLXTiwoSFQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sqqeM-0006I3-Jj for bug-gnu-emacs@gnu.org; Wed, 18 Sep 2024 05:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Sep 2024 09:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73291 X-GNU-PR-Package: emacs Original-Received: via spool by 73291-submit@debbugs.gnu.org id=B73291.172665041724167 (code B ref 73291); Wed, 18 Sep 2024 09:07:02 +0000 Original-Received: (at 73291) by debbugs.gnu.org; 18 Sep 2024 09:06:57 +0000 Original-Received: from localhost ([127.0.0.1]:57001 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqqeG-0006Hc-BK for submit@debbugs.gnu.org; Wed, 18 Sep 2024 05:06:56 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:14589) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sqqeC-0006HQ-Pl for 73291@debbugs.gnu.org; Wed, 18 Sep 2024 05:06:54 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=LSdee8D1 DaJAjbwlpUIGNLuREOmulN4H2GKsZ+P9RsQ=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=wzf8ZduzzKxgj3Y4qvjMCwnRxANFC1 Xd2BtuMbW4XcI9wQy8bw53VNRpegoPndA/Adaov/1ArkjFYI/RLXMGCA== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=LSdee8D1DaJAjbwl pUIGNLuREOmulN4H2GKsZ+P9RsQ=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=Z9y6mq/sln65Xq1pn0zzkAeieW+uLWbpkVVwfR yxfZx7y3h7ewoOVucO9Q7ZVGT7/MhY6kcWHwEkV/OjiHoiApAMNRG9Zzq/POzRKvE2fN2s qDoGf2oqlSqS27S+N7YoTLTeI+bq48eeNSBPC42qEMqos80fg/ch/eIOeKqFl/vFkeD8NI DDlYDgrExmpPoiBOBGMudl/0qugeQIBDxgPq2v2Mtv4F5v9bMTRHt4G6nqltyuiMRNWXue e2W5NKHx5X/HGG2cj49s00cr9aZRwGFQqmdsgTQEw8ez/zPGgW5KH7iSB4kEeozpGsOLaU GunL/Fl9TKraSbzf67LMJgIg== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id f99edc93 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 18 Sep 2024 11:06:33 +0200 (CEST) In-Reply-To: <86y13q9j41.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 17 Sep 2024 22:26:54 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291997 Archived-At: --=-=-= Content-Type: text/plain Hi, I think the following patch does the trick. Here is what I tested with it: - A call to `clean-buffer-list' cleans up the list once and does not activate the midnight-timer. - The midnight mode is toggled on/off by calling `midnight-mode'. - Calling (customize-variable 'midnight-delay) stops and restarts the midnight-timer with the updated delay. Maybe the line ":initialize #'custom-initialize-default" could be removed, I don't know. WDYT? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=midnight.patch diff --git a/lisp/midnight.el b/lisp/midnight.el index 6e1e7b5ccb7..ff1392abc05 100644 --- a/lisp/midnight.el +++ b/lisp/midnight.el @@ -52,12 +52,11 @@ midnight-mode "Non-nil means run `midnight-hook' at midnight." :global t :initialize #'custom-initialize-default - ;; Disable first, since the ':initialize' function above already - ;; starts the timer when the mode is turned on for the first time, - ;; via setting 'midnight-delay', which calls 'midnight-delay-set', - ;; which starts the timer. - (when (timerp midnight-timer) (cancel-timer midnight-timer)) - (if midnight-mode (timer-activate midnight-timer))) + ;; Call `midnight-delay-set' again because it takes care of starting + ;; the timer if the mode is on. The ':initialize' function above + ;; (which ends up calling `midnight-delay-set') did not know yet if + ;; the mode was on or not. + (midnight-delay-set 'midnight-delay midnight-delay)) ;;; clean-buffer-list stuff @@ -207,9 +206,11 @@ midnight-delay-set "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))) + ;; Only start the timer if the mode is turned on. + (when midnight-mode + (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. --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--