From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#61002: 28.2; Gnus - "Date" scoring scores all articles. Date: Sat, 17 Feb 2024 09:41:42 -0800 Message-ID: <87jzn3q97t.fsf@ericabrahamsen.net> References: <878rhvhsyu.fsf@alfa.kjonca> <86ttmz86o3.fsf@gnu.org> <86h6igvj1n.fsf@gnu.org> <87bk8oz0u0.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40828"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: kjonca@poczta.onet.pl, Eli Zaretskii , 61002-done@debbugs.gnu.org, larsi@gnus.org To: Jakub =?UTF-8?Q?Je=C4=8Dm=C3=ADnek?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 17 18:42:54 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rbOiE-000APh-9C for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Feb 2024 18:42:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbOi4-0005QU-GC; Sat, 17 Feb 2024 12:42:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbOi2-0005KP-Oy for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 12:42:42 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rbOi2-0003hS-Fw for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 12:42:42 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rbOiL-0006oL-RA for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 12:43:01 -0500 Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Feb 2024 17:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 61002 X-GNU-PR-Package: emacs Mail-Followup-To: 61002@debbugs.gnu.org, eric@ericabrahamsen.net, kjonca@poczta.onet.pl Original-Received: via spool by 61002-done@debbugs.gnu.org id=D61002.170819173326121 (code D ref 61002); Sat, 17 Feb 2024 17:43:01 +0000 Original-Received: (at 61002-done) by debbugs.gnu.org; 17 Feb 2024 17:42:13 +0000 Original-Received: from localhost ([127.0.0.1]:33754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbOhY-0006nF-Kl for submit@debbugs.gnu.org; Sat, 17 Feb 2024 12:42:13 -0500 Original-Received: from mail.ericabrahamsen.net ([52.70.2.18]:54262) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbOhW-0006n1-RC for 61002-done@debbugs.gnu.org; Sat, 17 Feb 2024 12:42:11 -0500 Original-Received: from localhost (71-212-21-65.tukw.qwest.net [71.212.21.65]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id D506BFA183; Sat, 17 Feb 2024 17:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1708191704; bh=kZMf/X7VZVjGRK2EyWYgEFYrJVoWimbdXzJRJaa0ZUY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=KRdJllA9JXFhTPekM55GYbyquX0GVXVlBzIfNPx2LrQYha+UuYh1hdR2oEOx0OTcw 3Z8a3npGFoeCJ6ynZz1i6H2UWKpygjbsrvGuAzjViBeTT7eavGHgh9dMnBHdcYEddR rodKiodhhuPiVzC6LhDbFbLqn0uZCIlH1iXjewGQ= In-Reply-To: ("Jakub =?UTF-8?Q?Je=C4=8Dm=C3=ADnek?="'s message of "Mon, 12 Feb 2024 16:58:30 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280136 Archived-At: Jakub Je=C4=8Dm=C3=ADnek writes: > Hi, thanks for the feedback! > > Eric Abrahamsen 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: =3D?UTF-8?q?Jakub=3D20Je=3DC4=3D8Dm=3DC3=3DADnek?=3D > 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 heade= r. > --- > 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=3D header "date") > + (int-to-string > + (- > + (/ (car (time-convert (current-time) 1)) 864= 00) > + (/ (car (time-convert (gnus-date-get-time ma= tch) 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. Looks good! I've pushed, and am closing this bug, thanks.