bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#61002: 28.2; Gnus - "Date" scoring scores all articles.


From: Eric Abrahamsen
Subject: bug#61002: 28.2; Gnus - "Date" scoring scores all articles.
Date: Sat, 17 Feb 2024 10:41:03 -0800
User-agent: Gnus/5.13 (Gnus v5.13)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]