GNU bug report logs - #43270
27.1; [PATCH] Enhance gnus-score-date to support scoring by article age

Previous Next

Package: emacs;

Reported by: Alex Bochannek <alex <at> bochannek.com>

Date: Tue, 8 Sep 2020 08:43:01 UTC

Severity: normal

Tags: fixed, patch

Found in version 27.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43270 in the body.
You can then email your comments to 43270 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#43270; Package emacs. (Tue, 08 Sep 2020 08:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alex Bochannek <alex <at> bochannek.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 08 Sep 2020 08:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article
 age
Date: Mon, 07 Sep 2020 18:28:34 -0700
[Message part 1 (text/plain, inline)]
The below patch to Gnus allows for scoring based on article age.

For example:

(("date"
  (7 10 nil <)
  (7 -10 nil >)
  (14 -10 nil >)))

results in articles less than a week old to get a 10 point increase,
older than a week a 10 point decrease, and older than two weeks a
cumulative 20 point decrease.

I am also including a documentation change. I have not made any changes
to interactive scoring.

[gnus-score.el.diff (text/x-patch, inline)]
*** /Users/awb/Desktop/gnus-score.el.~1~	2020-07-27 14:21:49.000000000 -0700
--- /Users/awb/Desktop/gnus-score.el	2020-09-07 12:21:36.000000000 -0700
***************
*** 1370,1378 ****
  	       (setq
  		err
  		(cond
! 		 ((if (member (downcase type) '("lines" "chars"))
! 		      (not (numberp (car s)))
! 		    (not (stringp (car s))))
  		  (format "Invalid match %s in %s" (car s) file))
  		 ((and (cadr s) (not (integerp (cadr s))))
  		  (format "Non-integer score %s in %s" (cadr s) file))
--- 1370,1381 ----
  	       (setq
  		err
  		(cond
! 		 ((cond ((member (downcase type) '("lines" "chars"))
! 			 (not (numberp (car s))))
! 			((string= (downcase type) "date")
! 			 (not (or (numberp (car s))
! 				  (stringp (car s)))))
! 			(t (not (stringp (car s)))))
  		  (format "Invalid match %s in %s" (car s) file))
  		 ((and (cadr s) (not (integerp (cadr s))))
  		  (format "Non-integer score %s in %s" (cadr s) file))
***************
*** 1690,1698 ****
--- 1693,1711 ----
  	   ((eq type 'after)
  	    (setq match-func 'string<
  		  match (gnus-date-iso8601 (nth 0 kill))))
+ 	   ((eq type '<)
+ 	    (setq type 'after
+ 		  match-func 'gnus-string>
+ 		  match (gnus-time-iso8601
+ 			 (time-add (current-time) (* 86400 (nth 0 kill))))))
  	   ((eq type 'before)
  	    (setq match-func 'gnus-string>
  		  match (gnus-date-iso8601 (nth 0 kill))))
+ 	   ((eq type '>)
+ 	    (setq type 'before
+ 		  match-func 'gnus-string>
+ 		  match (gnus-time-iso8601
+ 			 (time-add (current-time) (* -86400 (nth 0 kill))))))
  	   ((eq type 'at)
  	    (setq match-func 'string=
  		  match (gnus-date-iso8601 (nth 0 kill))))
[gnus.info.diff (text/x-patch, inline)]
*** /Users/awb/Desktop/gnus.info.~1~	2020-08-11 22:15:17.000000000 -0700
--- /Users/awb/Desktop/gnus.info	2020-09-07 18:14:22.000000000 -0700
***************
*** 16155,16160 ****
--- 16155,16168 ----
                 from.  Time zones are such wholesome fun for the whole
                 family, eh?)
  
+                The two additional match types ‘<’ and ‘>’ take an integer
+                number of days as a match, similar to ‘lines’:
+ 
+                       (7 -10 nil >)
+ 
+               The above reduces the score for articles older than 7 days
+               at scoring time by 10.
+ 
            “Head, Body, All”
                 These three match keys use the same match types as the
                 ‘From’ (etc.) header uses.
[Message part 4 (text/plain, inline)]
-- 
Alex.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43270; Package emacs. (Tue, 08 Sep 2020 09:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 43270 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: 43270 <at> debbugs.gnu.org
Subject: Re: bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support
 scoring by article age
Date: Tue, 08 Sep 2020 11:51:06 +0200
Alex Bochannek <alex <at> bochannek.com> writes:

> The below patch to Gnus allows for scoring based on article age.
>
> For example:
>
> (("date"
>   (7 10 nil <)
>   (7 -10 nil >)
>   (14 -10 nil >)))
>
> results in articles less than a week old to get a 10 point increase,
> older than a week a 10 point decrease, and older than two weeks a
> cumulative 20 point decrease.

Thanks; applied with one change:

> *** /Users/awb/Desktop/gnus.info.~1~	2020-08-11 22:15:17.000000000 -0700
> --- /Users/awb/Desktop/gnus.info	2020-09-07 18:14:22.000000000 -0700

[...]

> +                The two additional match types ‘<’ and ‘>’ take an integer
> +                number of days as a match, similar to ‘lines’:

The .info files are generated files -- the documentation goes into
doc/misc/gnus.texi (and I expanded upon the feature somewhat based on
your email).

The patch is just small enough to go through without a copyright
assignment (and I forgot to mark the commit as such; sigh), but for any
future patches you might send, we'd need to have the copyright assigned
to the FSF.  Would you be willing to do that?  If so, we could start the
ball rolling now on the paperwork, so that any subsequent patches can be
applied faster.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 08 Sep 2020 09:52:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 43270 <at> debbugs.gnu.org and Alex Bochannek <alex <at> bochannek.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 08 Sep 2020 09:52:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43270; Package emacs. (Thu, 10 Sep 2020 00:15:02 GMT) Full text and rfc822 format available.

Message #15 received at 43270 <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43270 <at> debbugs.gnu.org
Subject: Re: bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support
 scoring by article age
Date: Wed, 09 Sep 2020 16:59:03 -0700
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> The .info files are generated files -- the documentation goes into
> doc/misc/gnus.texi (and I expanded upon the feature somewhat based on
> your email).

Thanks for the reminder, forgot about that.

Looks like I inverted the logic for '<'. New patch attached.

> The patch is just small enough to go through without a copyright
> assignment (and I forgot to mark the commit as such; sigh), but for any
> future patches you might send, we'd need to have the copyright assigned
> to the FSF.  Would you be willing to do that?  If so, we could start the
> ball rolling now on the paperwork, so that any subsequent patches can be
> applied faster.

I believe my employer is already on file, so if there are any more
substantial contributions, I can use that.

Thanks!

-- 
Alex.
[gnus-score.el.diff (text/x-patch, inline)]
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index c5156a195a..12f733ac13 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -1695,9 +1695,9 @@ gnus-score-date
 		  match (gnus-date-iso8601 (nth 0 kill))))
 	   ((eq type '<)
 	    (setq type 'after
-		  match-func 'gnus-string>
+		  match-func 'string<
 		  match (gnus-time-iso8601
-			 (time-add (current-time) (* 86400 (nth 0 kill))))))
+			 (time-subtract (current-time) (* 86400 (nth 0 kill))))))
 	   ((eq type 'before)
 	    (setq match-func 'gnus-string>
 		  match (gnus-date-iso8601 (nth 0 kill))))
@@ -1705,7 +1705,7 @@ gnus-score-date
 	    (setq type 'before
 		  match-func 'gnus-string>
 		  match (gnus-time-iso8601
-			 (time-add (current-time) (* -86400 (nth 0 kill))))))
+			 (time-subtract (current-time) (* 86400 (nth 0 kill))))))
 	   ((eq type 'at)
 	    (setq match-func 'string=
 		  match (gnus-date-iso8601 (nth 0 kill))))

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43270; Package emacs. (Thu, 10 Sep 2020 13:17:02 GMT) Full text and rfc822 format available.

Message #18 received at 43270 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: 43270 <at> debbugs.gnu.org
Subject: Re: bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support
 scoring by article age
Date: Thu, 10 Sep 2020 15:16:20 +0200
Alex Bochannek <alex <at> bochannek.com> writes:

> Looks like I inverted the logic for '<'. New patch attached.

Thanks; applied.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43270; Package emacs. (Fri, 11 Sep 2020 00:59:02 GMT) Full text and rfc822 format available.

Message #21 received at 43270 <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43270 <at> debbugs.gnu.org
Subject: Re: bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support
 scoring by article age
Date: Thu, 10 Sep 2020 17:58:30 -0700
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Alex Bochannek <alex <at> bochannek.com> writes:
>
>> Looks like I inverted the logic for '<'. New patch attached.
>
> Thanks; applied.

Thanks, Lars! Below is another small patch to also support article age
in interactive scoring. I wasn't sure about the error handling, so feel
free to change that if there is a preferred style.

-- 
Alex.
[gnus-score.el.diff (text/x-patch, inline)]
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index 6a0e8ceb99..fce7b68db1 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -862,6 +862,18 @@ gnus-summary-score-entry
 	    (setq match (string-to-number match)))
       (set-text-properties 0 (length match) nil match))
 
+    ;; Modify match and type for article age scoring.
+    (if (string= "date" (nth 0 (assoc header gnus-header-index)))
+	(let ((age (string-to-number match)))
+	  (if (or (< age 0)
+		  (string= "0" match))
+	      (user-error "Article age must be a positive number"))
+    	  (setq match age
+		type (cond ((eq type 'after)
+			    '<)
+			   ((eq type 'before)
+			    '>)))))
+
     (unless (eq date 'now)
       ;; Add the score entry to the score file.
       (when (= score gnus-score-interactive-default-score)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43270; Package emacs. (Fri, 11 Sep 2020 12:18:01 GMT) Full text and rfc822 format available.

Message #24 received at 43270 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: 43270 <at> debbugs.gnu.org
Subject: Re: bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support
 scoring by article age
Date: Fri, 11 Sep 2020 14:17:27 +0200
Alex Bochannek <alex <at> bochannek.com> writes:

> Thanks, Lars! Below is another small patch to also support article age
> in interactive scoring. I wasn't sure about the error handling, so feel
> free to change that if there is a preferred style.

Looks good -- you said your employer was on file (for the copyright
assignment), but you didn't say who your employer was.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43270; Package emacs. (Sat, 12 Sep 2020 06:15:01 GMT) Full text and rfc822 format available.

Message #27 received at 43270 <at> debbugs.gnu.org (full text, mbox):

From: Alex Bochannek <alex <at> bochannek.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43270 <at> debbugs.gnu.org
Subject: Re: bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support
 scoring by article age
Date: Fri, 11 Sep 2020 23:14:19 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Alex Bochannek <alex <at> bochannek.com> writes:
>
>> Thanks, Lars! Below is another small patch to also support article age
>> in interactive scoring. I wasn't sure about the error handling, so feel
>> free to change that if there is a preferred style.
>
> Looks good -- you said your employer was on file (for the copyright
> assignment), but you didn't say who your employer was.  :-)

Yes, I heard back from the folks in Legal and they confirmed a CLA is in
place. I am at Google <abochannek <at> google.com>

Thanks!

-- 
Alex.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43270; Package emacs. (Sat, 12 Sep 2020 12:05:02 GMT) Full text and rfc822 format available.

Message #30 received at 43270 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Alex Bochannek <alex <at> bochannek.com>
Cc: 43270 <at> debbugs.gnu.org
Subject: Re: bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support
 scoring by article age
Date: Sat, 12 Sep 2020 14:04:26 +0200
Alex Bochannek <alex <at> bochannek.com> writes:

> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
>> Alex Bochannek <alex <at> bochannek.com> writes:
>>
>>> Thanks, Lars! Below is another small patch to also support article age
>>> in interactive scoring. I wasn't sure about the error handling, so feel
>>> free to change that if there is a preferred style.
>>
>> Looks good -- you said your employer was on file (for the copyright
>> assignment), but you didn't say who your employer was.  :-)
>
> Yes, I heard back from the folks in Legal and they confirmed a CLA is in
> place. I am at Google <abochannek <at> google.com>

Thanks for checking; I've now applied your patch to the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 11 Oct 2020 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 252 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.