From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/49827 Path: main.gmane.org!not-for-mail From: Simon Josefsson Newsgroups: gmane.emacs.gnus.general Subject: Re: regular and adaptive scoring with nnimap Date: Wed, 05 Feb 2003 06:52:07 +0100 Sender: owner-ding@hpc.uh.edu Message-ID: References: <84u1fwlxj5.fsf@lucy.is.informatik.uni-duisburg.de> <84u1fw7zaw.fsf@lucy.is.informatik.uni-duisburg.de> <4nk7gq8mms.fsf@lockgroove.bwh.harvard.edu> <84wukqtk3c.fsf@lucy.is.informatik.uni-duisburg.de> <4nof5txezm.fsf@lockgroove.bwh.harvard.edu> <4nk7gfd7q6.fsf@lockgroove.bwh.harvard.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1044424362 18154 80.91.224.249 (5 Feb 2003 05:52:42 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 5 Feb 2003 05:52:42 +0000 (UTC) Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18gIUB-0004iV-00 for ; Wed, 05 Feb 2003 06:52:39 +0100 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 18gIUN-0000Sa-00; Tue, 04 Feb 2003 23:52:51 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Tue, 04 Feb 2003 23:53:48 -0600 (CST) Original-Received: from sclp3.sclp.com (sclp3.sclp.com [66.230.238.2]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id XAA15624 for ; Tue, 4 Feb 2003 23:53:33 -0600 (CST) Original-Received: (qmail 38181 invoked by alias); 5 Feb 2003 05:52:31 -0000 Original-Received: (qmail 38176 invoked from network); 5 Feb 2003 05:52:31 -0000 Original-Received: from 178.230.13.217.in-addr.dgcsystems.net (HELO yxa.extundo.com) (217.13.230.178) by 66.230.238.6 with SMTP; 5 Feb 2003 05:52:31 -0000 Original-Received: from latte.josefsson.org (yxa.extundo.com [217.13.230.178]) (authenticated bits=0) by yxa.extundo.com (8.12.6/8.12.6) with ESMTP id h155q8eE009626 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 5 Feb 2003 06:52:09 +0100 Original-To: ding@gnus.org Mail-Copies-To: nobody X-Payment: hashcash 1.1 0:030205:ding@gnus.org:5c4c8425ca7749f3 X-Hashcash: 0:030205:ding@gnus.org:5c4c8425ca7749f3 In-Reply-To: <4nk7gfd7q6.fsf@lockgroove.bwh.harvard.edu> (Ted Zlatanov's message of "Tue, 04 Feb 2003 17:03:13 -0500") User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 (i386-debian-linux-gnu) X-Face: %bo>yc#X1.-jVa- writes: > How does this look, for retrieving an article and searching a group by > any parameter? > > (defun nnimap-db-get-article-contents (article group &optional server) > (let ((data)) > (when (numberp article) > (with-current-buffer (nnimap-get-server-buffer server) > (let ((saved (imap-current-mailbox))) > (with-temp-buffer > (nnimap-request-article article group server (buffer-name)) > (setq data (buffer-string))) > (nnimap-possibly-change-group saved server)))) > data)) Looks good. You might want to remove the store-and-restore current mailbox, I don't think it is necessary and on some servers it will be really slow. > (defun nnimap-db-get-uids-for-parameter (group parameter subject &optional server) > (let ((articles)) > (when (and (stringp subject) (stringp parameter) (stringp group)) > (with-current-buffer (nnimap-get-server-buffer server) > (let ((saved (imap-current-mailbox))) > (nnimap-possibly-change-group group server) > (setq articles (imap-search (format "HEADER %s \"%s\"" parameter subject))) > (nnimap-possibly-change-group saved server)))) > articles)) Looks good, with the same comment as above. > ;; (nnimap-db-get-uids-for-parameter "ding" "Subject" "spam") > ;; (nnimap-db-get-uids-for-parameter "ding" "Message-Id" "") > > I'm assuming two things: > > 1) (nnimap-possibly-change-group nil) is harmless > 2) (nnimap-possibly-change-group nil) returns the current group > > Are both true? n-p-c-g is actually somewhat broken (uidvalidity), so I suggest not using it. Instead, either use (if (imap-current-mailbox-p group) imap-current-mailbox (if (imap-mailbox-select group) imap-current-mailbox (error "Could not select group: %s" (imap-error-text))) or something. > I would use imap exclusively, but nnimap-possibly-change-group and the > other functions it offers are too useful :) Maybe the above code should be added as imap-possibly-change-group. Hm. > Also, do I need to do > > (setq gnus-newsgroup-active (gnus-activate-group group)) > > before each operation in case the nnimap server is not activated? You should try to make sure the server is open, yes. Setting that variable is probably not the right thing though, I think it is buffer local to summary buffers. g-a-g calls various hooks and stuff too, so perhaps it is not perfect to use.