From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Allen Li Newsgroups: gmane.emacs.bugs Subject: bug#39638: 26.3; recentf-auto-cleanup deceptive Date: Sun, 16 Feb 2020 23:33:36 -0800 Message-ID: <80wo8lacrz.fsf@felesatra.moe> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="48395"; mail-complaints-to="usenet@ciao.gmane.io" To: 39638@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 17 08:34:13 2020 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 1j3auy-000CV3-Ug for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Feb 2020 08:34:13 +0100 Original-Received: from localhost ([::1]:41256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3auy-0001xp-0D for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Feb 2020 02:34:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38406) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3aup-0001xP-Ja for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 02:34:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3auo-0001O8-4G for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 02:34:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60210) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3auo-0001O1-08 for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 02:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j3aun-0008Op-UP for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 02:34:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Allen Li Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Feb 2020 07:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39638 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.158192482632264 (code B ref -1); Mon, 17 Feb 2020 07:34:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Feb 2020 07:33:46 +0000 Original-Received: from localhost ([127.0.0.1]:37950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j3auX-0008OK-Qx for submit@debbugs.gnu.org; Mon, 17 Feb 2020 02:33:46 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45233) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j3auW-0008OC-7R for submit@debbugs.gnu.org; Mon, 17 Feb 2020 02:33:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38388) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3auU-0001wZ-Bp for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 02:33:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3auS-0001Br-OH for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 02:33:42 -0500 Original-Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:43495) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3auS-0001Ao-4I for bug-gnu-emacs@gnu.org; Mon, 17 Feb 2020 02:33:40 -0500 Original-Received: by mail-pl1-x62e.google.com with SMTP id p11so6342024plq.10 for ; Sun, 16 Feb 2020 23:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=felesatra-moe.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=3wdTIR70VQBf1zEyqv/txcWNJgACQ4IMElXPrSHXHkg=; b=yQu8upa/yz+zOM2/eQwDBWVqLjE1OScZxG7uK/3YiKjz3Aopz0k8b6xiwV7Klwqlo4 1mbHsn8jzxjhR4nNy4zig5KUGO0IF3yAaVAbkjVdLwtWxUZex45s6Lr80L6QplZdASg9 5x5peqMHgOa2xP9q1mhvNo/NJgFnu8kgcVr7Y0BJpssrgMyf156h/5sCb3kImd+hOkTd oktzUF5U1Yjdl4DK6OBZTJTTvKW5DBqSMSmdfwY/Xddk641mYNnd/c5VMIakC6pDsOT3 EvqXHm7QwBe7Kc0rVuWqu6tXcmfyEDhFJdgWXZIb+580sfC0iKBD3iMHZRgki6kydCwV DuUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=3wdTIR70VQBf1zEyqv/txcWNJgACQ4IMElXPrSHXHkg=; b=mccEa++8tRe83E7YzY7m3QbG9y9Qm/IMELZxQFfN3tD1LxOn5aQa+0Hz4Wx/jSPM7x XHE4nDdqOW3AqJJRad9vpmX7YJ4yPsghPCY8yH1dQbMxWcRPDI8S6HgBGwvZzCUSEgaZ E+A+qN1drn3ZjHysNcPO4QYeNXLnwsqgJbQadG4C7lVYut+cZ2huwFdv4OYUFsKoAVkn PMjmGPSJaoFiTh3EHMOgpdBxP8zIQLHzxe0xvMJJVEvG/Loe/R4haPCCvv3D06eFCO+G 5lU1Cc0i1LERxK/WNjAspqwY7aMlaQx56lKKmJCNPXu1FgFQvz8OEOglagJSSNkZAtAT sf+A== X-Gm-Message-State: APjAAAU8PSOyNH/HryGSTyq90ZAhA+tqId+tK/XuMlobJlLiDUXVwnMR BQfFuDyeazrNCef8GNMv2lLacKSVeOY= X-Google-Smtp-Source: APXvYqwwrwuU9cEk8UhK3RRs1HNk/iP/4mMMb6Zq08TE/w9CFBM1N/Er1SCYK5U5hYJkzPtpZIigVA== X-Received: by 2002:a17:902:d909:: with SMTP id c9mr14489434plz.337.1581924818485; Sun, 16 Feb 2020 23:33:38 -0800 (PST) Original-Received: from localhost ([2600:1700:7270:7d1f:fa59:71ff:fe00:10cc]) by smtp.gmail.com with ESMTPSA id 196sm15455439pfy.86.2020.02.16.23.33.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 23:33:37 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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" Xref: news.gmane.io gmane.emacs.bugs:176135 Archived-At: --=-=-= Content-Type: text/plain This covers two bugs around recentf-auto-cleanup being deceptive/unintuitive. Both bugs are present at 26.3 and on Emacs master as of 556cc727e5076d590f8286406e4f46cff3cee41e at Sun, 16 Feb 2020 11:37:07 -0800 1. When setting recentf-auto-cleanup to a string, the timer does not repeat. It is only set once. This is in contrast to midnight-mode, which repeats its timer every day. The documentation for recentf-auto-cleanup does not make this clear, and I'm not even sure if this was the intended behavior. (defun recentf-auto-cleanup () "Automatic cleanup of the recent list." (when (timerp recentf-auto-cleanup-timer) (cancel-timer recentf-auto-cleanup-timer)) (when recentf-mode (setq recentf-auto-cleanup-timer (cond ;; snipped ((stringp recentf-auto-cleanup) (run-at-time recentf-auto-cleanup nil 'recentf-cleanup)))))) 2. Due to the behavior of run-at-time, if the time string set was in the past for today, recentf-cleanup runs immediately when recentf-mode is turned on (e.g., at Emacs startup). This makes it pointless to set it to something like "3:00am" if I want recentf-cleanup to run at a time when I'm likely not using Emacs and I have also set recentf-max-saved-items to something large like 2000. The docstring does not make this obvious. This is also how one would usually customize midnight-mode. 2a. midnight-mode suffers from the same problem of using run-at-time, but the default behavior of midnight-mode does not make it expensive. But this means that adding recentf-cleanup to midnight-hook when using a large recentf-max-saved-items will still be expensive at startup. I have attached a number of patches: 1. Simply fix some awkward wording that is not directly related to this bug. 2. Document the current behavior. 3. Make recentf-auto-cleanup repeat for time strings. The third patch can be skipped if deemed too aggressive, but I think that's the more reasonable behavior to expect. I have not fixed the problem of recentf-cleanup running immediately if the time is in the past for today, since I'm not sure the best way to do it. In GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.10) of 2019-08-29 built on juergen Windowing system distributor 'The X.Org Foundation', version 11.0.12007000 System Description: Arch Linux --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-recentf-auto-cleanup-customize-wording.patch >From 6882a948b60c03f19f53597acb92b85f52a41cd0 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Sun, 16 Feb 2020 22:59:18 -0800 Subject: [PATCH 1/3] Fix recentf-auto-cleanup customize wording * lisp/recentf.el (recentf-auto-cleanup): Fix wording --- lisp/recentf.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/recentf.el b/lisp/recentf.el index 27918a9739..94241b00d5 100644 --- a/lisp/recentf.el +++ b/lisp/recentf.el @@ -257,7 +257,7 @@ recentf-auto-cleanup :value mode) (const :tag "Never" :value never) - (number :tag "When idle that seconds" + (number :tag "When idle after (seconds)" :value 300) (string :tag "At time" :value "11:00pm")) -- 2.25.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Clarify-behavior-of-setting-recentf-auto-cleanup-to-.patch >From a47a121c983b9062079ae4aa2e687bcf138dd8a5 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Sun, 16 Feb 2020 23:06:02 -0800 Subject: [PATCH 2/3] Clarify behavior of setting recentf-auto-cleanup to string * lisp/recentf.el (recentf-auto-cleanup): Clarify docstring --- lisp/recentf.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lisp/recentf.el b/lisp/recentf.el index 94241b00d5..9c4ef21b52 100644 --- a/lisp/recentf.el +++ b/lisp/recentf.el @@ -247,6 +247,12 @@ recentf-auto-cleanup - A time string Cleanup at specified time string, for example at \"11:00pm\". +If a time string is provided, cleanup is only scheduled once each +time the mode is turned on; it does not repeat daily. +Furthermore, the time is for the current day. If it is already +past the specified time for the day, cleanup happens immediately +as for `mode'. + Setting this variable directly does not take effect; use \\[customize]. -- 2.25.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-Make-recentf-auto-cleanup-repeat-when-set-to-string.patch >From b1c40cdeac3bf806a140bbc527604163d1818468 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Sun, 16 Feb 2020 23:15:35 -0800 Subject: [PATCH 3/3] Make recentf-auto-cleanup repeat when set to string * lisp/recentf.el (recentf-auto-cleanup): Make timer repeat, update docstring * etc/NEWS: Update news --- etc/NEWS | 7 +++++++ lisp/recentf.el | 12 +++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1f8e6049a8..b79d4f8fb8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -146,6 +146,13 @@ key binding / v package-menu-filter-by-version / / package-menu-filter-clear +** recentf + +--- +*** 'recentf-auto-cleanup' time string now repeats. +When 'recentf-auto-cleanup' is set to a time string, it now repeats +every day, rather than only running once after the mode is turned on. + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/recentf.el b/lisp/recentf.el index 9c4ef21b52..dd8c2135e8 100644 --- a/lisp/recentf.el +++ b/lisp/recentf.el @@ -245,13 +245,10 @@ recentf-auto-cleanup - A number Cleanup each time Emacs has been idle that number of seconds. - A time string - Cleanup at specified time string, for example at \"11:00pm\". + Cleanup at specified time string daily, for example at \"11:00pm\". -If a time string is provided, cleanup is only scheduled once each -time the mode is turned on; it does not repeat daily. -Furthermore, the time is for the current day. If it is already -past the specified time for the day, cleanup happens immediately -as for `mode'. +If a time string is provided and it is already past the specified time +for the current day, the first cleanup happens immediately as for `mode'. Setting this variable directly does not take effect; use \\[customize]. @@ -377,7 +374,8 @@ recentf-auto-cleanup recentf-auto-cleanup t 'recentf-cleanup)) ((stringp recentf-auto-cleanup) (run-at-time - recentf-auto-cleanup nil 'recentf-cleanup)))))) + ;; Repeat every 24 hours. + recentf-auto-cleanup (* 24 60 60) 'recentf-cleanup)))))) ;;; File functions ;; -- 2.25.0 --=-=-=--