Gnus development mailing list
 help / color / mirror / Atom feed
* [patch] gnus agent
@ 2000-07-01 18:24 Simon Josefsson
  2000-07-01 19:25 ` Harry Putnam
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Simon Josefsson @ 2000-07-01 18:24 UTC (permalink / raw)


This patch make all articles eligible for agent download, filtered
only by predicates, instead of the hardcoded algorithm that choses
what to download from unread articles only.

Any agent users that care to verify that this doesn't break anything?

Wouldn't it be nice if there was a OGnus beta branch?  Lars?

2000-07-01  Simon Josefsson  <simon@josefsson.org>

	* gnus-agent.el (gnus-agent-fetch-headers): Make all articles
	eligible for agent download.  Load gnus-agent-article-alist.
	(gnus-category-read): Update default.
	(gnus-category-predicate-alist): Add read.
	(gnus-agent-read-p): New predicate.

	* gnus-sum.el (gnus-update-marks): Don't propagate download and
	unsend flags.

2000-07-01  Simon Josefsson  <simon@josefsson.org>

	* gnus.texi (Category Syntax): Fix.

Index: lisp/gnus-agent.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-agent.el,v
retrieving revision 5.53
diff -w -u -r5.53 gnus-agent.el
--- lisp/gnus-agent.el	2000/06/26 20:39:15	5.53
+++ lisp/gnus-agent.el	2000/06/30 18:22:26
@@ -552,9 +552,8 @@
 	       (gnus-agent-method-p gnus-command-method))
       (gnus-agent-load-alist gnus-newsgroup-name)
       ;; First mark all undownloaded articles as undownloaded.
-      (let ((articles (append gnus-newsgroup-unreads
-			      gnus-newsgroup-marked
-			      gnus-newsgroup-dormant))
+      (let ((articles (gnus-uncompress-sequence 
+		       (gnus-active gnus-newsgroup-name)))
 	    article)
 	(while (setq article (pop articles))
 	  (unless (or (cdr (assq article gnus-agent-article-alist))
@@ -867,21 +866,19 @@
       (pop gnus-agent-group-alist))))
 
 (defun gnus-agent-fetch-headers (group &optional force)
-  (let ((articles (gnus-list-of-unread-articles group))
+  (let ((articles (gnus-uncompress-range (gnus-active group)))
 	(gnus-decode-encoded-word-function 'identity)
 	(file (gnus-agent-article-name ".overview" group)))
-    ;; Add article with marks to list of article headers we want to fetch.
-    (dolist (arts (gnus-info-marks (gnus-get-info group)))
-      (setq articles (union (gnus-uncompress-sequence (cdr arts))
-			    articles)))
-    (setq articles (sort articles '<))
+    (gnus-agent-load-alist gnus-newsgroup-name)
     ;; Remove known articles.
-    (when (gnus-agent-load-alist group)
-      (setq articles (gnus-sorted-intersection
-		      articles
-		      (gnus-uncompress-range
-		       (cons (1+ (caar (last gnus-agent-article-alist)))
-			     (cdr (gnus-active group)))))))
+    (while (and articles
+		(cdr (assq (car articles) gnus-agent-article-alist)))
+      (pop articles))
+    (let ((arts articles))
+      (while (cdr arts)
+	(if (assq (cadr arts) gnus-agent-article-alist)
+	    (setcdr arts (cddr arts))
+	  (setq arts (cdr arts)))))
     ;; Fetch them.
     (gnus-make-directory (nnheader-translate-file-chars
 			  (file-name-directory file) t))
@@ -1267,7 +1264,7 @@
   (setq gnus-category-alist
 	(or (gnus-agent-read-file
 	     (nnheader-concat gnus-agent-directory "lib/categories"))
-	    (list (list 'default 'short nil nil)))))
+	    (list (list 'default '(and short (not read)) nil nil)))))
 
 (defun gnus-category-write ()
   "Write the category alist."
@@ -1360,6 +1357,7 @@
     (long . gnus-agent-long-p)
     (low . gnus-agent-low-scored-p)
     (high . gnus-agent-high-scored-p)
+    (read . gnus-agent-read-p)
     (true . gnus-agent-true)
     (false . gnus-agent-false))
   "Mapping from short score predicate symbols to predicate functions.")
@@ -1390,6 +1388,11 @@
 (defun gnus-agent-high-scored-p ()
   "Say whether an article has a high score or not."
   (> gnus-score gnus-agent-high-score))
+
+(defun gnus-agent-read-p ()
+  "Say whether an article is read or not."
+  (gnus-member-of-range (mail-header-number gnus-headers)
+			(gnus-info-read (gnus-get-info gnus-newsgroup-name))))
 
 (defun gnus-category-make-function (cat)
   "Make a function from category CAT."
Index: lisp/gnus-sum.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-sum.el,v
retrieving revision 5.122
diff -w -u -r5.122 gnus-sum.el
--- lisp/gnus-sum.el	2000/06/16 23:13:10	5.122
+++ lisp/gnus-sum.el	2000/06/30 18:22:28
@@ -4416,9 +4416,14 @@
        
 	(when (gnus-check-backend-function
 	       'request-set-mark gnus-newsgroup-name)
+	  ;; propagate flags to server, with the following exceptions:
 	  ;; uncompressed:s are not proper flags (they are cons cells)
 	  ;; cache is a internal gnus flag
-	  (unless (memq (cdr type) (cons 'cache uncompressed))
+	  ;; download are local to one gnus installation (well)
+	  ;; unsend are for nndraft groups only
+	  ;; xxx: generality of this?  this suits nnimap anyway
+	  (unless (memq (cdr type) (append '(cache download unsend)
+					   uncompressed))
 	    (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
 		   (del (gnus-remove-from-range (gnus-copy-sequence old) list))
 		   (add (gnus-remove-from-range
Index: texi/gnus.texi
===================================================================
RCS file: /usr/local/cvsroot/gnus/texi/gnus.texi,v
retrieving revision 5.177
diff -w -u -r5.177 gnus.texi
--- texi/gnus.texi	2000/06/27 13:16:20	5.177
+++ texi/gnus.texi	2000/06/30 18:22:32
@@ -14157,8 +14157,7 @@
 
 Perhaps some examples are in order.
 
-Here's a simple predicate.  (It's the default predicate, in fact, used
-for all groups that don't belong to any other category.)
+Here's a simple predicate.
 
 @lisp
 short
@@ -14180,6 +14179,15 @@
 or if the score is not low and the article is not long.  You get the
 drift.
 
+The following predicate is the default, and is used for all groups
+that don't belong to any other category.  It downloads short unread
+articles.
+
+@lisp
+(and short
+     (not read))
+@end lisp
+
 The available logical operators are @code{or}, @code{and} and
 @code{not}.  (If you prefer, you can use the more ``C''-ish operators
 @samp{|}, @code{&} and @code{!} instead.)
@@ -14209,6 +14217,9 @@
 heuristics may change over time, but at present it just computes a
 checksum and sees whether articles match.
 
+@item read
+True iff the article is marked as read.
+
 @item true
 Always true.
 
@@ -14271,9 +14282,14 @@
 (agent-predicate . short)
 @end lisp
 
-This is the group parameter equivalent of the agent category default.
 Note that when specifying a single word predicate like this, the
 @code{agent-predicate} specification must be in dotted pair notation.
+
+This is the group parameter equivalent of the agent category default.
+
+@lisp
+(agent-predicate and short (not read))
+@end lisp
 
 The equivalent of the longer example from above would be:
 




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

end of thread, other threads:[~2000-08-14 19:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-01 18:24 [patch] gnus agent Simon Josefsson
2000-07-01 19:25 ` Harry Putnam
2000-07-02  3:49   ` John Prevost
2000-07-03  8:43   ` Simon Josefsson
2000-08-08 19:06 ` Christoph Rohland
2000-08-10 11:03 ` Christoph Rohland
2000-08-10 12:44   ` simon
2000-08-10 13:17     ` Christoph Rohland
2000-08-14 18:45 ` Lars Magne Ingebrigtsen
2000-08-14 19:48   ` simon

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).