Gnus development mailing list
 help / color / mirror / Atom feed
* [patch] Agent and download scoring etc.
@ 1998-09-05 18:02 Mike McEwan
  1998-09-06  2:49 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Mike McEwan @ 1998-09-05 18:02 UTC (permalink / raw)


I've been tinkering again (I wonder what it's like outside?). I tried
to get the Agent to download articles based on their scores only to
discover (or perhaps rediscover) the Agent way of scoring things is
completely separate from normal score files. 

Lars, I know you're mime, mime, miming at the moment, but since we're
alpha again, I wonder if you might whack on the following if you think
it looks OK :-). It's the ol' `why can't Agent use my normal score files'
patch.
 
The patch allows the Agent to decide what to download with the
permitted subset of the normal score files when the download score
rule of a category, or locally, the `agent-score' parameter of a
group, is `file'. The old stuff still takes precedence.

I wasn't sure how category download score rule or group parameter
`agent-score' are supposed to be specified and couldn't find any doc
so I've made some assumptions:

Category rule

 `file'  -  use normal score files.

 `("filename" ["filename"])' - use the specified file(s) (e.g. `("~/News/agent.SCORE")').

 `(("from" ("Lars Magne Ingebrigtsen" 1000 nil s))' - use specified rules.

 Group Parameters

 `(agent-score . file)'      - use normal score files.

 `(agent-score "filename" ["filename"])' - use the specified file(s).

 `(agent-score ("from" ("Lars Magne Ingebrigtsen" 1000 nil s)))' - use specified rules.


I hope the above doesn't clobber anyone's current usage too
much. Group parameters take precedence over category rules. There's a
couple of other little mods to try and speed things up a bit.

See what you think.

-- 
Mike.

--- ChangeLog.orig	1998/09/03 21:23:53
+++ ChangeLog	1998/09/05 16:28:46
@@ -1,3 +1,14 @@
+1998-09-05  Mike McEwan  <mike@lotusland.demon.co.uk>
+
+	* gnus-agent.el (gnus-agent-scoreable-headers): New variable.
+	(gnus-agent-fetch-group-1): Score article headers using normal
+ 	group score files if the download score rule of a category/group
+ 	is `file'.
+	(gnus-agent-fetch-group-1): Don't parse the entire .overview when
+ 	deciding what articles to download.
+	(gnus-agent-fetch-group-1): Don't push headers through scoring and
+ 	predicate processing if predicate is `true' or `false'.
+
 Thu Sep  3 15:23:22 1998  Lars Magne Ingebrigtsen  <larsi@menja.ifi.uio.no>
 
 	* gnus.el: Pterodactyl Gnus v0.14 is released.

--- gnus-agent.el.orig	Tue Sep  1 20:22:11 1998
+++ gnus-agent.el	Sat Sep  5 17:51:29 1998
@@ -27,7 +27,8 @@
 (require 'gnus-cache)
 (require 'nnvirtual)
 (require 'gnus-sum)
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl)
+		   (require 'gnus-score))
 
 (defcustom gnus-agent-directory (nnheader-concat gnus-directory "agent/")
   "Where the Gnus agent will store its files."
@@ -94,6 +95,13 @@
 (defvar gnus-agent-send-mail-function nil)
 (defvar gnus-agent-article-file-coding-system 'no-conversion)
 
+(defconst gnus-agent-scoreable-headers
+  (list
+   "subject" "from" "date" "message-id" 
+   "references" "chars" "lines" "xref")
+  "Headers that are considered when scoring articles
+for download via the Agent.")
+
 ;; Dynamic variables
 (defvar gnus-headers)
 (defvar gnus-score)
@@ -894,27 +902,63 @@
       ;; Parse them and see which articles we want to fetch.
       (setq gnus-newsgroup-dependencies
 	    (make-vector (length articles) 0))
-      (setq gnus-newsgroup-headers
-	    (gnus-get-newsgroup-headers-xover articles nil nil group))
+      ;; No need to call `gnus-get-newsgroup-headers-xover' with 
+      ;; the entire .overview for group as we still have the just
+      ;; downloaded headers in `gnus-agent-overview-buffer'.
+      (let ((nntp-server-buffer gnus-agent-overview-buffer))
+	(setq gnus-newsgroup-headers
+	      (gnus-get-newsgroup-headers-xover articles nil nil group)))
       (setq category (gnus-group-category group))
       (setq predicate
 	    (gnus-get-predicate 
 	     (or (gnus-group-get-parameter group 'agent-predicate)
 		 (cadr category))))
-      (setq score-param
-	    (or (gnus-group-get-parameter group 'agent-score)
-		(caddr category)))
-      (when score-param
-	(gnus-score-headers (list (list score-param))))
-      (setq arts nil)
-      (while (setq gnus-headers (pop gnus-newsgroup-headers))
-	(setq gnus-score
-	      (or (cdr (assq (mail-header-number gnus-headers)
-			     gnus-newsgroup-scored))
-		  gnus-summary-default-score))
-	(when (funcall predicate)
-	  (push (mail-header-number gnus-headers)
-		arts)))
+      ;; Do we want to download everything, or nothing?
+      (if (or (eq (caaddr predicate) 'gnus-agent-true)
+	      (eq (caaddr predicate) 'gnus-agent-false))
+	  ;; Yes.
+	  (setq arts (symbol-value 
+		      (cadr (assoc (caaddr predicate) 
+				   '((gnus-agent-true articles)
+				     (gnus-agent-false nil))))))
+	;; No, we need to decide what we want.
+	(setq score-param
+	      (let ((score-method (or 
+				   (gnus-group-get-parameter group 'agent-score t)
+				   (caddr category))))
+		(when score-method
+		  (require 'gnus-score)
+		  (if (eq score-method 'file)
+		      (let ((entries
+			     (gnus-score-load-files
+			      (gnus-all-score-files group)))
+			    list score-file)
+			(while (setq list (car entries))
+			  (push (car list) score-file)
+			  (setq list (cdr list))
+			  (while list
+			    (when (member (caar list)
+					  gnus-agent-scoreable-headers)
+			      (push (car list) score-file))
+			    (setq list (cdr list)))
+			  (setq score-param 
+				(append score-param (list (nreverse score-file)))
+				score-file nil entries (cdr entries)))
+			(list score-param))
+		    (if (stringp (car score-method))
+			score-method
+		      (list (list score-method)))))))
+	(when score-param
+	  (gnus-score-headers score-param))
+	(setq arts nil)
+	(while (setq gnus-headers (pop gnus-newsgroup-headers))
+	  (setq gnus-score
+		(or (cdr (assq (mail-header-number gnus-headers)
+			       gnus-newsgroup-scored))
+		    gnus-summary-default-score))
+	  (when (funcall predicate)
+	    (push (mail-header-number gnus-headers)
+		  arts))))
       ;; Fetch the articles.
       (when arts
 	(gnus-agent-fetch-articles group arts)))


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

end of thread, other threads:[~1998-09-06 23:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-05 18:02 [patch] Agent and download scoring etc Mike McEwan
1998-09-06  2:49 ` Lars Magne Ingebrigtsen
1998-09-06 19:17   ` Mike McEwan
1998-09-06 23:40     ` Lars Magne Ingebrigtsen

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 NNTP newsgroup(s).