bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by a


From: Alex Bochannek
Subject: bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age
Date: Mon, 07 Sep 2020 18:28:34 -0700

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.

*** /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))))
*** /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.
-- 
Alex.

reply via email to

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