From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/73129 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: Thu, 14 Oct 2010 14:45:20 -0400 Message-ID: <87sk08sjen.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> <87k4llfw24.fsf@andy.bu.edu> <8762x5szj4.fsf@andy.bu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1287081960 17484 80.91.229.12 (14 Oct 2010 18:46:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Oct 2010 18:46:00 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M21501@lists.math.uh.edu Thu Oct 14 20:45:59 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 1P6SoL-0005UD-CJ for ding-account@gmane.org; Thu, 14 Oct 2010 20:45:53 +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 1P6SoE-0001G3-Os; Thu, 14 Oct 2010 13:45:46 -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 1P6SoD-0001Fk-1i for ding@lists.math.uh.edu; Thu, 14 Oct 2010 13:45:45 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1P6So8-0001Qc-Eh for ding@lists.math.uh.edu; Thu, 14 Oct 2010 13:45:44 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1P6So7-0006Cz-00 for ; Thu, 14 Oct 2010 20:45:39 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P6So3-0005L9-Tk for ding@gnus.org; Thu, 14 Oct 2010 20:45:35 +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 20:45:35 +0200 Original-Received: from cohen by andy.bu.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Oct 2010 20:45:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 143 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:2sFmXA2ifeBu+yS/Ln9BXI5xdrY= X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:73129 Archived-At: --=-=-= Content-Type: text/plain >>>>> "Lars" == Lars Magne Ingebrigtsen writes: Lars> Andrew Cohen writes: >> Sorry for so many followups, but here is a slightly improved >> version (more sensible signature for 'request-thread, and fixed a >> bug in buffer handling). Lars> Looks good. The only thing that leaps out is the Lars> + (gnus-get-function gnus-command-method 'request-thread) Lars> thing, which is usually done in gnus-int.el, so that you can Lars> just call gnus-request-thread' directly. That also takes care Lars> of binding gnus-commmand-method correctly, which is nice for Lars> gnus-agent integration, but it probably makes no matter Lars> here... Cool. Does this work? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=refer.diff Content-Description: request-thread diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 3fbcef6..9b338ff 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -1311,6 +1311,25 @@ textual parts.") (setq nnimap-status-string "Read-only server") nil) +(deffoo nnimap-request-thread (id) + (let* ((refs (split-string + (or (mail-header-references (gnus-summary-article-header)) + ""))) + (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 + (with-current-buffer (nnimap-buffer) + (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-int.el b/lisp/gnus-int.el index b210df4..19bcffe 100644 --- a/lisp/gnus-int.el +++ b/lisp/gnus-int.el @@ -504,6 +504,12 @@ If BUFFER, insert the article in that group." article (gnus-group-real-name group) (nth 1 gnus-command-method) buffer))) +(defun gnus-request-thread (id) + "Request the thread containing the article specified by Message-ID id." + (let ((gnus-command-method (gnus-find-method-for-group gnus-newsgroup-name))) + (funcall (gnus-get-function gnus-command-method 'request-thread) + id))) + (defun gnus-request-head (article group) "Request the head of ARTICLE in GROUP." (let* ((gnus-command-method (gnus-find-method-for-group group)) diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 1086e28..568e297 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -8824,31 +8824,35 @@ 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))) (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)) + (if (gnus-check-backend-function 'request-thread gnus-newsgroup-name) + (gnus-request-thread id) + (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) --=-=-=--