unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Philip Kaludercic <philipk@posteo.net>
Cc: 61002@debbugs.gnu.org, "Eli Zaretskii" <eliz@gnu.org>,
	kjonca@poczta.onet.pl, "Jakub Ječmínek" <jecminek.k@gmail.com>,
	larsi@gnus.org
Subject: bug#61002: 28.2; Gnus - "Date" scoring scores all articles.
Date: Sat, 17 Feb 2024 10:41:03 -0800	[thread overview]
Message-ID: <8734trq6gw.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87msrzgdak.fsf@posteo.net> (Philip Kaludercic's message of "Sat,  17 Feb 2024 18:23:47 +0000")

Philip Kaludercic <philipk@posteo.net> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> Jakub Ječmínek <jecminek.k@gmail.com> writes:
>>
>>> Hi, thanks for the feedback!
>>>
>>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>>
>>>> Thanks for the ping. TBH I've never used scoring in Gnus, so this is new
>>>> territory for me. I tried the patch and it worked correctly, but...
>>>>
>>>> The patch is doing this:
>>>>
>>>> (gnus-date-get-time (gnus-date-iso8601 match))
>>>>
>>>> This is the definition of `gnus-date-iso8601':
>>>>
>>>> (defun gnus-date-iso8601 (date)
>>>>   "Convert the DATE to YYYYMMDDTHHMMSS."
>>>>   (condition-case ()
>>>>       (gnus-time-iso8601 (gnus-date-get-time date))
>>>>     (error "")))
>>>>
>>>> So error handling aside, the patch ends up doing the equivalent of:
>>>>
>>>> (let ((ds "Sun, 22 Jan 2023 09:30:17 +0100"))
>>>>   (gnus-date-get-time
>>>>    (gnus-time-iso8601
>>>>     (gnus-date-get-time ds))))
>>>>
>>>> which effectively round-trips the date string through two different
>>>> formats.
>>>
>>> You're right. I've replaced the offending form with this:
>>>
>>> (car (time-convert (gnus-date-get-time match) 1))
>>>
>>>> [...] I think we should just keep the inner
>>>> `gnus-date-get-time' call, and wrap the whole `int-to-string' form in a
>>>> `condition-case'. If anything at all goes wrong we really don't care, we
>>>> can just skip it and return a "1" or something.
>>>>
>>>> WDYT?
>>>
>>> I believe that error handling is now redundant, because even if we try to
>>> parse invalid date using `gnus-date-get-time' we still end up with valid
>>> value (0).
>>>
>>> (/ (car (time-convert (gnus-date-get-time "invalid date") 1)) 86400)
>>>
>>> But, there's one important thing I failed to realize - the code I wrote
>>> would break prompts for other headers. Therefore I propose we add `cond'
>>> and distinguish which header we're scoring on.
>>>
>>> Please let me know what you think, here's the patch:
>>>
>>>>>From 4e2174503c1d69345536929a22483ae309048271 Mon Sep 17 00:00:00 2001
>>> From: =?UTF-8?q?Jakub=20Je=C4=8Dm=C3=ADnek?= <jecminek.k@gmail.com>
>>> Date: Mon, 12 Feb 2024 14:03:24 +0100
>>> Subject: [PATCH] Provide valid match string when scoring on date header
>>>  (Bug#61002)
>>>
>>> * lisp/gnus/gnus-score.el (gnus-summary-score-entry): Fix invalid
>>> default match string when creating score file interactively on date header.
>>> ---
>>>  lisp/gnus/gnus-score.el | 11 ++++++++---
>>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
>>> index bd19e7d7cd7..479b7496cf1 100644
>>> --- a/lisp/gnus/gnus-score.el
>>> +++ b/lisp/gnus/gnus-score.el
>>> @@ -893,9 +893,14 @@ If optional argument `EXTRA' is non-nil, it's a non-standard overview header."
>>>  				 (t "permanent"))
>>>  			   header
>>>  			   (if (< score 0) "lower" "raise"))
>>> -		   (if (numberp match)
>>> -		       (int-to-string match)
>>> -		     match))))
>>> +                   (cond ((numberp match) (int-to-string match))
>>> +                         ((string= header "date")
>>> +                          (int-to-string
>>> +                           (-
>>> +                            (/ (car (time-convert (current-time) 1)) 86400)
>>> +                            (/ (car (time-convert (gnus-date-get-time match) 1))
>>> +                               86400))))
>>> +                         (t match)))))
>>>
>>>      ;; If this is an integer comparison, we transform from string to int.
>>>      (if (eq (nth 2 (assoc header gnus-header-index)) 'gnus-score-integer)
>>> --
>>> 2.39.3 (Apple Git-145)
>>>
>>> The patch should be correctly indented even though it doesn't look like
>>> it is. The reason is that previous lines contain mixture of tabs and
>>> spaces.
>>
>> This results in an error while building Emacs!
>
> Turns out this was due to the above change, but a typo in the previous
> commit (db5e84af202532b138918295ea6dd1b0ea910d78).  I have taken the
> liberty to push a commit fixing the issue.  Hope that is ok with
> everyone.

Yes, thank you! Sorry for not testing that better.





      reply	other threads:[~2024-02-17 18:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-22  8:30 bug#61002: 28.2; Gnus - "Date" scoring scores all articles Kamil Jońca
2024-01-20  0:14 ` bug#61002: [PATCH] " Jakub Ječmínek
2024-01-20 11:33   ` Jakub Ječmínek
2024-01-27  9:30     ` Eli Zaretskii
2024-02-10  8:07       ` Eli Zaretskii
2024-02-10 17:27         ` Eric Abrahamsen
2024-02-12 15:58           ` Jakub Ječmínek
2024-02-17 17:41             ` Eric Abrahamsen
2024-02-17 18:18             ` Philip Kaludercic
2024-02-17 18:23               ` Philip Kaludercic
2024-02-17 18:41                 ` Eric Abrahamsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734trq6gw.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=61002@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jecminek.k@gmail.com \
    --cc=kjonca@poczta.onet.pl \
    --cc=larsi@gnus.org \
    --cc=philipk@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).