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

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.

>   ELC      org/ox.elc
>
> In toplevel form:
> org/ox.el:82:11: Error: Eager macro-expansion failure: (void-variable gnus-not-ignore)
> make[3]: *** [Makefile:335: org/ox.elc] Error 1
>   ELC      org/ox-texinfo.elc
>
> In toplevel form:
> org/ox-texinfo.el:33:11: Error: Eager macro-expansion failure: (void-variable gnus-not-ignore)
> make[3]: *** [Makefile:335: org/ox-texinfo.elc] Error 1
>   ELC      org/org-element.elc
>
> In toplevel form:
> org/org-element.el:68:11: Error: Eager macro-expansion failure: (void-variable gnus-not-ignore)
> make[3]: *** [Makefile:335: org/org-element.elc] Error 1
> make[3]: Target 'compile-targets' not remade because of errors.
> make[3]: Leaving directory '/home/philip/Source/emacs/lisp'
> make[2]: *** [Makefile:382: main-first] Error 2
>   GEN      autoloads
>   INFO     Scraping files for loaddefs... 
>   INFO     Scraping files for loaddefs...done
>   INFO     Scraping files for loaddefs... 
>   INFO     Scraping files for loaddefs...done
>   GEN      finder-inf.el
>
> Error: error ("Eager macro-expansion failure: (void-variable gnus-not-ignore)")
>   signal(error ("Eager macro-expansion failure: (void-variable gnus-not-ignore)"))
>   error("Eager macro-expansion failure: %S" (void-variable gnus-not-ignore))
>   internal-macroexpand-for-load((eval-when-compile (require 'mm-decode) (require 'mm-view)) nil)
>   eval-buffer(#<buffer  *load*-165045> nil "/home/philip/Source/emacs/lisp/url/url.el" nil t)
>   load-with-code-conversion("/home/philip/Source/emacs/lisp/url/url.el" "/home/philip/Source/emacs/lisp/url/url.el" nil t)
>   require(url)
>   eval-buffer(#<buffer  *load*-129778> nil "/home/philip/Source/emacs/lisp/net/browse-url.el" nil t)
>   load-with-code-conversion("/home/philip/Source/emacs/lisp/net/browse-url.el" "/home/philip/Source/emacs/lisp/net/browse-url.el" nil t)
>   require(browse-url)
>   eval-buffer(#<buffer  *load*-532718> nil "/home/philip/Source/emacs/lisp/emacs-lisp/package.el" nil t)
>   load-with-code-conversion("/home/philip/Source/emacs/lisp/emacs-lisp/package.el" "/home/philip/Source/emacs/lisp/emacs-lisp/package.el" nil t)
>   require(package)
>   eval-buffer(#<buffer  *load*> nil "/home/philip/Source/emacs/lisp/finder.el" nil t)
>   load-with-code-conversion("/home/philip/Source/emacs/lisp/finder.el" "/home/philip/Source/emacs/lisp/finder.el" nil t)
>   load("finder" nil t)
>   command-line-1(("-l" "finder" "--eval" "(setq generated-finder-keywords-file (unmsys--file-name \"./finder-inf.el\"))" "-f" "finder-compile-keywords-make-dist" "." "./calc" "./calendar" "./cedet" "./cedet/ede" "./cedet/semantic" "./cedet/semantic/analyze" "./cedet/semantic/bovine" "./cedet/semantic/decorate" "./cedet/semantic/symref" "./cedet/semantic/wisent" "./cedet/srecode" "./emacs-lisp" "./emulation" "./erc" "./eshell" "./gnus" "./image" "./international" "./language" "./mail" "./mh-e" "./net" "./nxml" "./org" "./play" "./progmodes" "./textmodes" "./url" "./use-package" "./vc"))
>   command-line()
>   normal-top-level()
> Eager macro-expansion failure: (void-variable gnus-not-ignore)
>
>
>> Best
>>
>> Jakub Ječmínek
>>
>>
>>
>>

-- 
Philip Kaludercic





  reply	other threads:[~2024-02-17 18:23 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 [this message]
2024-02-17 18:41                 ` Eric Abrahamsen

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

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

  git send-email \
    --in-reply-to=87msrzgdak.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=61002@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=eric@ericabrahamsen.net \
    --cc=jecminek.k@gmail.com \
    --cc=kjonca@poczta.onet.pl \
    --cc=larsi@gnus.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.