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 10:41:03 -0800 Message-ID: <8734trq6gw.fsf@ericabrahamsen.net> References: <878rhvhsyu.fsf@alfa.kjonca> <86ttmz86o3.fsf@gnu.org> <86h6igvj1n.fsf@gnu.org> <87bk8oz0u0.fsf@ericabrahamsen.net> <87plwvgdio.fsf@posteo.net> <87msrzgdak.fsf@posteo.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="2211"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 61002@debbugs.gnu.org, Eli Zaretskii , kjonca@poczta.onet.pl, Jakub =?UTF-8?Q?Je=C4=8Dm=C3=ADnek?= , larsi@gnus.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 17 19:41:59 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 1rbPdP-0000KW-Ng for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Feb 2024 19:41:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbPdA-0005JY-Um; Sat, 17 Feb 2024 13:41: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 1rbPd8-0005JJ-Jr for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 13:41: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 1rbPd8-0005jq-Bj for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 13:41:42 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rbPdR-0008Mr-QN for bug-gnu-emacs@gnu.org; Sat, 17 Feb 2024 13:42:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Feb 2024 18:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61002 X-GNU-PR-Package: emacs Original-Received: via spool by 61002-submit@debbugs.gnu.org id=B61002.170819529532121 (code B ref 61002); Sat, 17 Feb 2024 18:42:01 +0000 Original-Received: (at 61002) by debbugs.gnu.org; 17 Feb 2024 18:41:35 +0000 Original-Received: from localhost ([127.0.0.1]:33861 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbPd0-0008M1-EQ for submit@debbugs.gnu.org; Sat, 17 Feb 2024 13:41:34 -0500 Original-Received: from mail.ericabrahamsen.net ([52.70.2.18]:49542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbPcx-0008Lo-Im for 61002@debbugs.gnu.org; Sat, 17 Feb 2024 13:41:32 -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 C7A5EFA183; Sat, 17 Feb 2024 18:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1708195265; bh=p1uK7C4Y1f2sodll4A2HRU664J8LRun74mN0nDiC4uo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=QRBC7WnQys7pH11IqiDQ0Hfhv+7H1pmZ8ykc8uzmLRVbc8WTCW9YL5CsDlHgPCVrk pgxPwMepNRtBshBmF9xXdrhA/TJwgVfBc9b+zHk9QFLJj15t3kl5Yh4M4y5qdnP3Nz KMj74BgfqaaovWNtzvAiG/l+vlKQ1aT1a6hUyBnQ= In-Reply-To: <87msrzgdak.fsf@posteo.net> (Philip Kaludercic's message of "Sat, 17 Feb 2024 18:23:47 +0000") 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:280144 Archived-At: Philip Kaludercic writes: > Philip Kaludercic writes: > >> 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 n= ew >>>> 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 hea= der. >>> --- >>> 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 no= n-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)) 8= 6400) >>> + (/ (car (time-convert (gnus-date-get-time = match) 1)) >>> + 86400)))) >>> + (t match))))) >>> >>> ;; If this is an integer comparison, we transform from string to i= nt. >>> (if (eq (nth 2 (assoc header gnus-header-index)) 'gnus-score-integ= er) >>> -- >>> 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.