unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age
@ 2020-09-08  1:28 Alex Bochannek
  2020-09-08  9:51 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Bochannek @ 2020-09-08  1:28 UTC (permalink / raw)
  To: 43270

[-- Attachment #1: Type: text/plain, Size: 403 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Enhance gnus-score-date to support scoring by article age (code) --]
[-- Type: text/x-patch, Size: 1637 bytes --]

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

[-- Attachment #3: Enhance gnus-score-date to support scoring by article age (info) --]
[-- Type: text/x-patch, Size: 791 bytes --]

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

[-- Attachment #4: Type: text/plain, Size: 11 bytes --]


-- 
Alex.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-12 12:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08  1:28 bug#43270: 27.1; [PATCH] Enhance gnus-score-date to support scoring by article age Alex Bochannek
2020-09-08  9:51 ` Lars Ingebrigtsen
2020-09-09 23:59   ` Alex Bochannek
2020-09-10 13:16     ` Lars Ingebrigtsen
2020-09-11  0:58       ` Alex Bochannek
2020-09-11 12:17         ` Lars Ingebrigtsen
2020-09-12  6:14           ` Alex Bochannek
2020-09-12 12:04             ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).