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: Philip Kaludercic
Subject: bug#61002: 28.2; Gnus - "Date" scoring scores all articles.
Date: Sat, 17 Feb 2024 18:18:55 +0000

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!

--8<---------------cut here---------------start------------->8---
  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)
--8<---------------cut here---------------end--------------->8---


> Best
>
> Jakub Ječmínek
>
>
>
>

-- 
Philip Kaludercic





reply via email to

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