From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/55049 Path: main.gmane.org!not-for-mail From: Kevin Greiner Newsgroups: gmane.emacs.gnus.general Subject: Re: two agent nits Date: Tue, 02 Dec 2003 00:01:42 -0600 Sender: ding-owner@lists.math.uh.edu Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1070344962 27666 80.91.224.253 (2 Dec 2003 06:02:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 2 Dec 2003 06:02:42 +0000 (UTC) Original-X-From: ding-owner+M3589@lists.math.uh.edu Tue Dec 02 07:02:38 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AR3cM-0005u5-00 for ; Tue, 02 Dec 2003 07:02:38 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1AR3bn-0000um-00; Tue, 02 Dec 2003 00:02:03 -0600 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1AR3bd-0000ue-00 for ding@lists.math.uh.edu; Tue, 02 Dec 2003 00:01:53 -0600 Original-Received: from quimby.gnus.org (quimby.gnus.org [80.91.224.244]) by justine.libertine.org (Postfix) with ESMTP id 9E0CD3A0078 for ; Tue, 2 Dec 2003 00:01:52 -0600 (CST) Original-Received: from news by quimby.gnus.org with local (Exim 3.35 #1 (Debian)) id 1AR3bc-0007Ep-00 for ; Tue, 02 Dec 2003 07:01:52 +0100 Original-To: ding@gnus.org Original-Path: not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 185 Original-NNTP-Posting-Host: dialup-216-12-206-245.ev1.net Original-X-Trace: quimby.gnus.org 1070344911 27826 216.12.206.245 (2 Dec 2003 06:01:51 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Tue, 2 Dec 2003 06:01:51 +0000 (UTC) User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (windows-nt) Cancel-Lock: sha1:3P1Dw6dKb9ElN3JYala2muo1ujo= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:55049 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:55049 --=-=-= Kevin Greiner writes: > Simon Josefsson writes: > >> Kevin Greiner writes: >> >>> Simon Josefsson writes: >>> >>>> Kevin Greiner writes: >>>> >>>>> Simon Josefsson writes: >>>>> >>>>>> * I can't seem to get the agent to fetch read articles. >>>>>> gnus-agent-consider-all-articles's value is t >>>>>> The default agent category predicate is 'true'. >>>>>> `J s' and `J u' just download unread or ticked articles. >>>>> >>>>> Have to tried setting gnus-agent-consider-all-articles to nil? That >>>>> seems to work for me. >>>> >>>> I tried, but still the same. Pressing `J u' on groups just say it is >>>> finished, but only the unread/ticked articles are in my local cache. >>>> >>>> Hm. The manual and the docstring for the variable doesn't seem to be >>>> in sync. I thought the variable did what the docstring said, but the >>>> manual just discuss missing headers. Which one is correct? >>> >>> The variable gnus-agent-consider-all-articles appears in >>> gnus-agent-fetch-headers but NOT gnus-agent-fetch-articles. However, >>> gnus-agent-fetch-group-1 calls gnus-agent-fetch-headers to get the >>> list of new articles so gnus-agent-consider-all-articles may, by >>> modifying the return value of gnus-agent-fetch-headers, effect the >>> list of articles being fetched by gnus-agent-fetch-articles. >> >> Thanks for the pointers, I think I isolated the problem, from g-a-f-a: >> >> (let* ((fetch-all (and gnus-agent-consider-all-articles >> ;; Do not fetch all headers if the predicate >> ;; implies that we only consider unread articles. >> (not (gnus-predicate-implies-unread >> (gnus-agent-find-parameter group >> 'agent-predicate))))) >> >> Fetch-all evaluate to nil for me, causing the function to only return >> a list of unread articles. Since g-a-c-a-a is t, the reason fetch-al >> is nil is because of the second statement. >> >> (gnus-predicate-implies-unread 'true) >> => ignore >> >> (not (gnus-predicate-implies-unread 'true)) >> => nil >> >> Reading the docstring: >> >> (gnus-predicate-implies-unread PREDICATE) >> Say whether PREDICATE implies unread articles only. >> It is okay to miss some cases, but there must be no false positives. >> That is, if this function returns true, then indeed the predicate must >> return only unread articles. >> >> The 'ignore return value is not documented, and because it is non-nil >> it is treated as true by the caller in this case. >> >> If I apply this change, everything works, but I can't tell if it is >> the right thing. > > Thanks for isolating the problem. I'm also not certain that this is > the right thing to do. It is certainly the correct answer if the > function is gnus-agent-true but what if the function is a compiled > function returned by gnus-category-make-function? > >> --- gnus-agent.el.~6.180.~ 2003-12-01 12:35:54.000000000 +0100 >> +++ gnus-agent.el 2003-12-01 17:39:06.000000000 +0100 >> @@ -2455,7 +2455,7 @@ >> ((not function) >> nil) >> ((functionp function) >> - 'ignore) >> + nil) >> ((memq (car function) '(or and not)) >> (apply (car function) >> (mapcar 'gnus-function-implies-unread-1 (cdr function)))) > > Simon, I finally realized what bothered me with this patch. If you look closely, the resulting code has a cond statement with four cases. In three cases, the result is simply nil. In the fourth case, the function recurses. Taken together that means that the function simply degenerates into nil. So here's my version of the patch. It is unfortunately a good deal more complex. I'd appreciate some feedback before I check it in. --=-=-= Content-Disposition: attachment; filename=agent_patch.txt Content-Description: Patch to fetch read articles. --- lisp.cvs_ref/gnus-agent.el Mon Dec 1 23:05:10 2003 +++ lisp/gnus-agent.el Tue Dec 2 00:00:26 2003 @@ -2445,22 +2445,58 @@ (defun gnus-predicate-implies-unread (predicate) "Say whether PREDICATE implies unread articles only. It is okay to miss some cases, but there must be no false positives. -That is, if this function returns true, then indeed the predicate must +That is, if this predicate returns true, then indeed the predicate must return only unread articles." - (gnus-function-implies-unread-1 (gnus-category-make-function predicate))) + (eq t (gnus-function-implies-unread-1 + (gnus-category-make-function-1 predicate)))) (defun gnus-function-implies-unread-1 (function) - (cond ((eq function (symbol-function 'gnus-agent-read-p)) - nil) - ((not function) - nil) - ((functionp function) - 'ignore) - ((memq (car function) '(or and not)) - (apply (car function) - (mapcar 'gnus-function-implies-unread-1 (cdr function)))) - (t - (error "Unknown function: %s" function)))) + "Recursively evaluate a predicate function to determine whether it can select +any read articles. Returns t if the function is known to never +return read articles, nil when it is known to always return read +articles, and t_nil when the function may return both read and unread +articles." + (let ((func (car function)) + (args (mapcar 'gnus-function-implies-unread-1 (cdr function)))) + (cond ((eq func 'and) + (cond ((memq t args) ; if any argument returns only unread articles + ;; then that argument constrains the result to only unread articles. + t) + ((memq 't_nil args) ; if any argument is indeterminate + ;; then the result is indeterminate + 't_nil))) + ((eq func 'or) + (cond ((memq nil args) ; if any argument returns read articles + ;; then that argument ensures that the results includes read articles. + nil) + ((memq 't_nil args) ; if any argument is indeterminate + ;; then that argument ensures that the results are indeterminate + 't_nil) + (t ; if all arguments return only unread articles + ;; then the result returns only unread articles + t))) + ((eq func 'not) + (cond ((eq (car args) 't_nil) ; if the argument is indeterminate + ; then the result is indeterminate + (car args)) + (t ; otherwise + ; toggle the result to be the opposite of the argument + (not (car args))))) + ((eq func 'gnus-agent-read-p) + nil) ; The read predicate NEVER returns unread articles + ((eq func 'gnus-agent-false) + t) ; The false predicate returns t as the empty set excludes all read articles + ((eq func 'gnus-agent-true) + nil) ; The true predicate ALWAYS returns read articles + ((catch 'found-match + (let ((alist gnus-category-predicate-alist)) + (while alist + (if (eq func (cdar alist)) + (throw 'found-match t) + (setq alist (cdr alist)))))) + 't_nil) ; All other predicates return read and unread articles + (t + (error "Unknown predicate function: %s" function))))) (defun gnus-group-category (group) "Return the category GROUP belongs to." --=-=-= Kevin --=-=-=--