Gnus development mailing list
 help / color / mirror / Atom feed
From: Andrew Cohen <cohen@andy.bu.edu>
To: ding@gnus.org
Subject: Re: A T does not work in nnimap
Date: Thu, 14 Oct 2010 14:45:20 -0400	[thread overview]
Message-ID: <87sk08sjen.fsf@andy.bu.edu> (raw)
In-Reply-To: <m3mxqgk630.fsf@quimbies.gnus.org>

[-- Attachment #1: Type: text/plain, Size: 745 bytes --]

>>>>> "Lars" == Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

    Lars> Andrew Cohen <cohen@andy.bu.edu> 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?



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: request-thread --]
[-- Type: text/x-diff, Size: 4121 bytes --]

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)

  reply	other threads:[~2010-10-14 18:45 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-07 11:00 Julien Danjou
2010-10-07 18:13 ` Lars Magne Ingebrigtsen
2010-10-12 13:28   ` Julien Danjou
2010-10-12 13:50     ` Lars Magne Ingebrigtsen
2010-10-12 14:18       ` Julien Danjou
2010-10-12 14:43         ` Andrew Cohen
2010-10-12 23:43           ` Andrew Cohen
2010-10-13 13:55             ` Julien Danjou
2010-10-13 15:30               ` Andrew Cohen
2010-10-13 15:42                 ` Julien Danjou
2010-10-13 17:21             ` Lars Magne Ingebrigtsen
2010-10-13 17:56               ` Andrew Cohen
2010-10-13 18:29                 ` Lars Magne Ingebrigtsen
2010-10-13 20:59                   ` Andrew Cohen
2010-10-13 21:11                     ` Lars Magne Ingebrigtsen
2010-10-13 21:30                       ` Andrew Cohen
2010-10-13 21:37                         ` Lars Magne Ingebrigtsen
2010-10-13 21:59                           ` Andrew Cohen
2010-10-13 22:06                             ` Lars Magne Ingebrigtsen
2010-10-14  0:38                           ` Andrew Cohen
2010-10-14 12:57                             ` Andrew Cohen
2010-10-14 18:00                               ` Lars Magne Ingebrigtsen
2010-10-14 18:45                                 ` Andrew Cohen [this message]
2010-10-14 19:02                                   ` Lars Magne Ingebrigtsen
2010-10-15 11:02                                   ` Julien Danjou
2010-10-15 11:24                                     ` Andrew Cohen
2010-10-15 11:29                                       ` Julien Danjou
2010-10-15 11:53                                         ` Steinar Bang
2010-10-15 12:01                                           ` Julien Danjou
2010-10-15 12:00                                         ` Andrew Cohen
2010-10-15 12:06                                           ` Julien Danjou
2010-10-15 12:17                                             ` Andrew Cohen
2010-10-15 12:26                                               ` Andrew Cohen
2010-10-15 18:26                                                 ` Julien Danjou
2010-10-16 12:58                                                   ` Andrew Cohen
2010-10-16 18:16                                                     ` Lars Magne Ingebrigtsen
2010-10-15 14:03                                               ` Lars Magne Ingebrigtsen
2010-10-15 12:11                                           ` Andrew Cohen
2010-10-15 12:28                                             ` Julien Danjou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sk08sjen.fsf@andy.bu.edu \
    --to=cohen@andy.bu.edu \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).