GNU bug report logs - #58820
[PATCH] Calculate age cutoff at n-th midnight instead of n*24h mark

Previous Next

Package: emacs;

Reported by: Łukasz Stelmach <stlman <at> poczta.fm>

Date: Thu, 27 Oct 2022 18:58:02 UTC

Severity: wishlist

Tags: patch

Fixed in version 30.1

Done: Eric Abrahamsen <eric <at> ericabrahamsen.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58820 in the body.
You can then email your comments to 58820 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#58820; Package emacs. (Thu, 27 Oct 2022 18:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Łukasz Stelmach <stlman <at> poczta.fm>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 27 Oct 2022 18:58:02 GMT) Full text and rfc822 format available.

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

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: bug-gnu-emacs <at> gnu.org
Cc: Łukasz Stelmach <stlman <at> poczta.fm>
Subject: [PATCH] Calculate age cutoff at n-th midnight instead of n*24h mark
Date: Thu, 27 Oct 2022 20:50:06 +0200
* 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.
---
 lisp/gnus/gnus-sum.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 18ba55a439..a15dedeccf 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -8323,8 +8323,9 @@ articles."
 
 (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 at midnight so with AGE equal 1 messages sent before 00:00
+today will be included (or excluded).  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)
@@ -8347,15 +8348,17 @@ articles that are younger than AGE 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))
-- 
2.30.2





Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 11 Nov 2022 13:17:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58820; Package emacs. (Thu, 07 Sep 2023 20:30:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Łukasz Stelmach <stlman <at> poczta.fm>
Cc: 58820 <at> debbugs.gnu.org, Eric Abrahamsen <eric <at> ericabrahamsen.net>
Subject: Re: bug#58820: [PATCH] Calculate age cutoff at n-th midnight instead
 of n*24h mark
Date: Thu, 7 Sep 2023 13:29:05 -0700
Łukasz Stelmach <stlman <at> poczta.fm> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58820; Package emacs. (Sat, 23 Sep 2023 23:37:02 GMT) Full text and rfc822 format available.

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

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 58820 <at> debbugs.gnu.org, Łukasz Stelmach <stlman <at> poczta.fm>
Subject: Re: 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 part 1 (text/plain, inline)]
Stefan Kangas <stefankangas <at> gmail.com> writes:

> Łukasz Stelmach <stlman <at> poczta.fm> 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 Łukasz for the report.
I'd like to apply the attached, which is mostly Łukasz'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

[0001-Have-gnus-summary-limit-to-age-operate-on-calendar-d.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58820; Package emacs. (Wed, 11 Oct 2023 14:58:02 GMT) Full text and rfc822 format available.

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

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 58820 <at> debbugs.gnu.org, Łukasz Stelmach <stlman <at> poczta.fm>
Subject: Re: bug#58820: [PATCH] Calculate age cutoff at n-th midnight
 instead of n*24h mark
Date: Wed, 11 Oct 2023 07:57:24 -0700
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> Stefan Kangas <stefankangas <at> gmail.com> writes:
>
>> Łukasz Stelmach <stlman <at> poczta.fm> 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 Łukasz for the report.
> I'd like to apply the attached, which is mostly Łukasz'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?

I feel fairly okay about this patch, so will apply tomorrow unless
anyone complains.

Thanks,
Eric




bug marked as fixed in version 30.1, send any further explanations to 58820 <at> debbugs.gnu.org and Łukasz Stelmach <stlman <at> poczta.fm> Request was from Eric Abrahamsen <eric <at> ericabrahamsen.net> to control <at> debbugs.gnu.org. (Sat, 14 Oct 2023 00:03:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 11 Nov 2023 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 164 days ago.

Previous Next


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