From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#58820: [PATCH] Calculate age cutoff at n-th midnight instead of n*24h mark Date: Sat, 23 Sep 2023 16:36:11 -0700 Message-ID: <87il80laxg.fsf@ericabrahamsen.net> References: <20221027185006.1033130-1-stlman@poczta.fm> 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="1603"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 58820@debbugs.gnu.org, =?UTF-8?Q?=C5=81ukasz?= Stelmach To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 24 01:37:14 2023 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 1qkCBU-0000Ah-6k for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Sep 2023 01:37:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qkCBC-0008PB-3m; Sat, 23 Sep 2023 19:36:54 -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 1qkCB9-0008Om-LG for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2023 19:36:52 -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 1qkCB9-0003ND-DH for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2023 19:36:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qkCBK-0001Ml-Eb for bug-gnu-emacs@gnu.org; Sat, 23 Sep 2023 19:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Sep 2023 23:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58820 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58820-submit@debbugs.gnu.org id=B58820.16955121985221 (code B ref 58820); Sat, 23 Sep 2023 23:37:02 +0000 Original-Received: (at 58820) by debbugs.gnu.org; 23 Sep 2023 23:36:38 +0000 Original-Received: from localhost ([127.0.0.1]:40760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qkCAv-0001M8-Ip for submit@debbugs.gnu.org; Sat, 23 Sep 2023 19:36:38 -0400 Original-Received: from mail.ericabrahamsen.net ([52.70.2.18]:39980) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qkCAp-0001Lo-Vi for 58820@debbugs.gnu.org; Sat, 23 Sep 2023 19:36:35 -0400 Original-Received: from localhost (71-212-75-26.tukw.qwest.net [71.212.75.26]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 33853FA059; Sat, 23 Sep 2023 23:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1695512173; bh=gsaueSbc83haP2Jz1NlmpFXPUTNL6PhoExYjVhEe8t4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=QIt98LZH7wEtSFEhYex66tm6CdsmjNHcuhp9P/H27BF7JudktiGg1tTEk7zIwH6bS gic/FQqhzLoijKQrfQFiC3mGOdw0mXAjdiMQvpV3vDQjohrlLxN8td1Cn/br8jur2+ 0qUobLR4dm0QQjSeH8Y5RUMJEq1RKN5cs/2oCkgs= In-Reply-To: (Stefan Kangas's message of "Thu, 7 Sep 2023 13:29:05 -0700") 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:271201 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Stefan Kangas writes: > =C5=81ukasz Stelmach writes: > >> * lisp/gnus/gnus-sum.el (gnus-summary-limit-to-age): Calculate cutoff to >> point to n-th past midnight (1st is 00:00 today). This way messages sent >> between n*24h mark and the next midnight will be excluded (or included >> if limitting to younger messages), which seems more intuitive when users >> are asked to enter age in days. > > Eric, do you have any comments on this patch? Thanks in advance. Hi! I do think this a reasonable change, thanks to =C5=81ukasz for the report. I'd like to apply the attached, which is mostly =C5=81ukasz's code with the addition of a simplification of the argument reading. I've also changed the docstring a bit, as I found the original change a little hard to understand. However, this might not be any better! WDYT? Eric --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Have-gnus-summary-limit-to-age-operate-on-calendar-d.patch Content-Transfer-Encoding: quoted-printable >From 5b050f666dce02636921f4d1f7529efae6aec856 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sat, 23 Sep 2023 16:31:10 -0700 Subject: [PATCH] Have gnus-summary-limit-to-age operate on calendar days MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Reported and patched by =C5=81ukasz Stelmach . * lisp/gnus/gnus-sum.el (gnus-summary-limit-to-age): Rather than 24-hour blocks. Also use `read-number', and drop the confusing option to reverse younger/older both with the prefix argument and with a negative number. --- lisp/gnus/gnus-sum.el | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index a3be5577f7a..f576d4e6147 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -8331,39 +8331,29 @@ gnus-summary-limit-to-predicate =20 (defun gnus-summary-limit-to-age (age &optional younger-p) "Limit the summary buffer to articles that are older than (or equal) AGE= days. -If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to -articles that are younger than AGE days." +Days are counted from midnight to midnight, and now to the +previous midnight counts as day one. If YOUNGER-P (the prefix) +is non-nil, limit the summary buffer to articles that are younger +than AGE days." (interactive - (let ((younger current-prefix-arg) - (days-got nil) - days) - (while (not days-got) - (setq days (if younger - (read-string "Limit to articles younger than (in days, older when = negative): ") - (read-string - "Limit to articles older than (in days, younger when negative): "))) - (when (> (length days) 0) - (setq days (read days))) - (if (numberp days) - (progn - (setq days-got t) - (when (< days 0) - (setq younger (not younger)) - (setq days (* days -1)))) - (message "Please enter a number.") - (sleep-for 1))) + (let* ((younger current-prefix-arg) + (days (read-number + (if younger "Limit to articles younger than days: " + "Limit to articles older than days: ")))) (list days younger)) gnus-summary-mode) (prog1 - (let ((data gnus-newsgroup-data) - (cutoff (days-to-time age)) - articles d date is-younger) + (let* ((data gnus-newsgroup-data) + (now (append '(0 0 0) (cdddr (decode-time)))) + (delta (make-decoded-time :day (* -1 (- age 1)))) + (cutoff (encode-time (decoded-time-add now delta))) + articles d date is-younger) (while (setq d (pop data)) (when (and (mail-header-p (gnus-data-header d)) (setq date (mail-header-date (gnus-data-header d)))) (setq is-younger (time-less-p - (time-since (gnus-date-get-time date)) - cutoff)) + cutoff + (gnus-date-get-time date))) (when (if younger-p is-younger (not is-younger)) --=20 2.42.0 --=-=-=--