From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/73094 Path: news.gmane.org!not-for-mail From: Andrew Cohen Newsgroups: gmane.emacs.gnus.general Subject: Re: A T does not work in nnimap Date: Wed, 13 Oct 2010 20:38:11 -0400 Message-ID: <87k4llfw24.fsf@andy.bu.edu> References: <874ocrwjxu.fsf@andy.bu.edu> <87mxqjvuy8.fsf@andy.bu.edu> <87r5fuc6xk.fsf@andy.bu.edu> <87hbgpdd25.fsf@andy.bu.edu> <87d3rddbmu.fsf@andy.bu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1287016774 6120 80.91.229.12 (14 Oct 2010 00:39:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Oct 2010 00:39:34 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M21466@lists.math.uh.edu Thu Oct 14 02:39:33 2010 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P6Br0-0004Wo-Kb for ding-account@gmane.org; Thu, 14 Oct 2010 02:39:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1P6Bq1-0004RW-TA; Wed, 13 Oct 2010 19:38:29 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1P6Bpz-0004RH-Uk for ding@lists.math.uh.edu; Wed, 13 Oct 2010 19:38:27 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1P6Bpu-0005Jr-Pp for ding@lists.math.uh.edu; Wed, 13 Oct 2010 19:38:27 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1P6Bpu-0007a5-00 for ; Thu, 14 Oct 2010 02:38:22 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P6Bps-00046S-UL for ding@gnus.org; Thu, 14 Oct 2010 02:38:20 +0200 Original-Received: from andy.bu.edu ([128.197.41.152]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Oct 2010 02:38:20 +0200 Original-Received: from cohen by andy.bu.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Oct 2010 02:38:20 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 125 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: andy.bu.edu User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:T2NmwVo/UsT5WxulZzdZLuMYiN0= X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:73094 Archived-At: --=-=-= Content-Type: text/plain >>>>> "Lars" == Lars Magne Ingebrigtsen writes: Lars> Andrew Cohen writes: >> OK, so some pseudo-code: (defun gnus-summary-refer-thread () (if >> backend-supports-request-thread (backend-request-thread) >> (gnus-retrieve-headers bunch)) (gnus-summary-limit-include-thread >> id)) Right? I think I might be able to handle this. Lars> Yup. Here is a version of gnus-summary-refer-thread as discussed, along with a new nnimap backend function nnimap-request-thread. Only lightly tested. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=refer.diff Content-Description: refer-threads diff --git a/lisp/nnimap.el b/lisp/nnimap.el index b530ce6..2cf4713 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -1310,6 +1310,25 @@ textual parts.") (setq nnimap-status-string "Read-only server") nil) +(deffoo nnimap-request-thread (id refs &optional server) + (nnimap-possibly-change-group nil server) + (with-current-buffer (nnimap-buffer) + (let* ((cmd (let ((value + (format + "(OR HEADER REFERENCES %s HEADER Message-Id %s)" + id id))) + (dolist (refid refs value) + (setq value (format + "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)" + refid refid value))))) + (result + (nnimap-command + "UID SEARCH %s" cmd))) + (gnus-fetch-headers (and (car result) + (delete 0 (mapcar #'string-to-number + (cdr (assoc "SEARCH" (cdr result)))))))))) + + (defun nnimap-possibly-change-group (group server) (let ((open-result t)) (when (and server diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 1086e28..dc6a35c 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -8824,31 +8824,41 @@ Return the number of articles fetched." (defun gnus-summary-refer-thread (&optional limit) "Fetch all articles in the current thread. -If LIMIT (the numerical prefix), fetch that many old headers instead -of what's specified by the `gnus-refer-thread-limit' variable." +If no backend-specific 'request-thread function is available +fetch LIMIT (the numerical prefix) old headers. If LIMIT is nil +fetch what's specified by the `gnus-refer-thread-limit' +variable." (interactive "P") (let ((id (mail-header-id (gnus-summary-article-header))) + (refs (split-string + (or (mail-header-references (gnus-summary-article-header)) + ""))) (limit (if limit (prefix-numeric-value limit) - gnus-refer-thread-limit))) - (unless (eq gnus-fetch-old-headers 'invisible) - (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) - ;; Retrieve the headers and read them in. - (if (eq (if (numberp limit) - (gnus-retrieve-headers - (list (min - (+ (mail-header-number - (gnus-summary-article-header)) - limit) - gnus-newsgroup-end)) - gnus-newsgroup-name (* limit 2)) - ;; gnus-refer-thread-limit is t, i.e. fetch _all_ - ;; headers. - (gnus-retrieve-headers (list gnus-newsgroup-end) - gnus-newsgroup-name limit)) - 'nov) - (gnus-build-all-threads) - (error "Can't fetch thread from back ends that don't support NOV")) - (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)) + gnus-refer-thread-limit)) + (gnus-command-method + (gnus-find-method-for-group gnus-newsgroup-name))) + (if (gnus-check-backend-function 'request-thread gnus-newsgroup-name) + (funcall (gnus-get-function gnus-command-method 'request-thread) + id refs) + (unless (eq gnus-fetch-old-headers 'invisible) + (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) + ;; Retrieve the headers and read them in. + (if (numberp limit) + (gnus-retrieve-headers + (list (min + (+ (mail-header-number + (gnus-summary-article-header)) + limit) + gnus-newsgroup-end)) + gnus-newsgroup-name (* limit 2)) + ;; gnus-refer-thread-limit is t, i.e. fetch _all_ + ;; headers. + (gnus-retrieve-headers (list gnus-newsgroup-end) + gnus-newsgroup-name limit) + (gnus-message 5 "Fetching headers for %s...done" + gnus-newsgroup-name)))) + (when (eq gnus-headers-retrieved-by 'nov) + (gnus-build-all-threads)) (gnus-summary-limit-include-thread id))) (defun gnus-summary-refer-article (message-id) --=-=-=--