[gnus git] branch master updated: n0-17-201-gb2274a6 =1= Allow thread-referral to use nnir to search across groups.

Andrew Cohen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  b2274a6f90b2ef1112ab22c5b158bf6e427bd4dd (commit)
      from  22a06f8aa44da45edff3c6330abed1b63564a88c (commit)


- Log -----------------------------------------------------------------
commit b2274a6f90b2ef1112ab22c5b158bf6e427bd4dd
Author: Andrew Cohen <[email protected]>
Date:   Sat Jul 23 12:29:46 2011 -0400

    Allow thread-referral to use nnir to search across groups.
    
    * nnir.el (nnir-search-thread): New function to make an nnir group
      based on a thread query.
    
    * gnus-sum.el (gnus-refer-thread-use-nnir): New variable to control use
      of nnir in thread referral.
      (gnus-summary-refer-thread): Use it.
    
    * nnimap.el (nnimap-request-thread): Use it.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d36a04a..4be8325 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
+2011-07-23  Andrew Cohen  <[email protected]>
+
+	* nnir.el (nnir-search-thread): New function to make an nnir group
+	based on a thread query.
+
+	* gnus-sum.el (gnus-refer-thread-use-nnir): New variable to control use
+	of nnir in thread referral.
+	(gnus-summary-refer-thread): Use it.
+
+	* nnimap.el (nnimap-request-thread): Use it.
+
 2011-07-20  Lars Magne Ingebrigtsen  <[email protected]>
 
 	* shr.el (shr-tag-comment): Ignore HTML comments.
diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el
index 6e8fc63..5917c9d 100644
--- a/lisp/gnus-sum.el
+++ b/lisp/gnus-sum.el
@@ -118,6 +118,13 @@ If t, fetch all the available old headers."
   :type '(choice number
 		 (sexp :menu-tag "other" t)))
 
+(defcustom gnus-refer-thread-use-nnir nil
+  "*Use nnir to search an entire server when referring threads. A
+nil value will only search for thread-related articles in the
+current group."
+  :group 'gnus-thread
+  :type 'boolean)
+
 (defcustom gnus-summary-make-false-root 'adopt
   "*nil means that Gnus won't gather loose threads.
 If the root of a thread has expired or been read in a previous
@@ -8972,11 +8979,16 @@ Return the number of articles fetched."
     result))
 
 (defun gnus-summary-refer-thread (&optional limit)
-  "Fetch all articles in the current thread.
-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."
+  "Fetch all articles in the current thread. For backends that
+know how to search for threads (currently only 'nnimap) a
+non-numeric prefix arg will use nnir to search the entire
+server; without a prefix arg only the current group is
+searched. If the variable `gnus-refer-thread-use-nnir' is
+non-nil the prefix arg has the reverse meaning. If no
+backend-specific 'request-thread function is available fetch
+LIMIT (the numerical prefix) old headers. If LIMIT is
+non-numeric or nil fetch the number specified by the
+`gnus-refer-thread-limit' variable."
   (interactive "P")
   (gnus-warp-to-article)
   (let* ((header (gnus-summary-article-header))
@@ -8984,13 +8996,16 @@ variable."
 	 (gnus-inhibit-demon t)
 	 (gnus-summary-ignore-duplicates t)
 	 (gnus-read-all-available-headers t)
-	 (limit (if limit (prefix-numeric-value limit)
-		  gnus-refer-thread-limit))
+	 (gnus-refer-thread-use-nnir
+	  (if (and (not (null limit)) (listp limit))
+	      (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
 	 (new-headers
 	  (if (gnus-check-backend-function
 	       'request-thread gnus-newsgroup-name)
 	      (gnus-request-thread header gnus-newsgroup-name)
-	    (let* ((last (if (numberp limit)
+	    (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
+			    gnus-refer-thread-limit))
+		   (last (if (numberp limit)
 			     (min (+ (mail-header-number header)
 				     limit)
 				  gnus-newsgroup-highest)
@@ -9005,17 +9020,19 @@ variable."
 		       (regexp-opt (append refs (list id subject)))))))
 	      (gnus-fetch-headers (list last) (if (numberp limit)
 						  (* 2 limit) limit) t)))))
+    (when (listp new-headers)
     (dolist (header new-headers)
       (when (member (mail-header-number header) gnus-newsgroup-unselected)
 	(push (mail-header-number header) gnus-newsgroup-unreads)
 	(setq gnus-newsgroup-unselected
-	      (delete (mail-header-number header) gnus-newsgroup-unselected))))
+                (delete (mail-header-number header)
+			gnus-newsgroup-unselected))))
     (setq gnus-newsgroup-headers
 	  (gnus-delete-duplicate-headers
 	   (gnus-merge
 	    'list gnus-newsgroup-headers new-headers
 	    'gnus-article-sort-by-number)))
-    (gnus-summary-limit-include-thread id)))
+      (gnus-summary-limit-include-thread id))))
 
 (defun gnus-summary-refer-article (message-id)
   "Fetch an article specified by MESSAGE-ID."
diff --git a/lisp/nnimap.el b/lisp/nnimap.el
index 3855227..8a0d635 100644
--- a/lisp/nnimap.el
+++ b/lisp/nnimap.el
@@ -1566,6 +1566,8 @@ textual parts.")
 		  (articles &optional limit force-new dependencies))
 
 (deffoo nnimap-request-thread (header &optional group server)
+  (if gnus-refer-thread-use-nnir 
+      (nnir-search-thread header)
   (when (nnimap-possibly-change-group group server)
     (let* ((cmd (nnimap-make-thread-query header))
 	   (result (with-current-buffer (nnimap-buffer)
@@ -1574,7 +1576,7 @@ textual parts.")
 	(gnus-fetch-headers
 	 (and (car result) (delete 0 (mapcar #'string-to-number
 					     (cdr (assoc "SEARCH" (cdr result))))))
-	 nil t)))))
+           nil t))))))
 
 (defun nnimap-possibly-change-group (group server)
   (let ((open-result t))
diff --git a/lisp/nnir.el b/lisp/nnir.el
index 9840ddd..e6420a4 100644
--- a/lisp/nnir.el
+++ b/lisp/nnir.el
@@ -289,6 +289,7 @@ is `(valuefunc member)'."
   (autoload 'nnimap-buffer "nnimap")
   (autoload 'nnimap-command "nnimap")
   (autoload 'nnimap-possibly-change-group "nnimap")
+  (autoload 'nnimap-make-thread-query "nnimap")
   (autoload 'gnus-registry-action "gnus-registry")
   (defvar gnus-registry-install))
 
@@ -1649,6 +1650,16 @@ server is of form 'backend:name'."
     (nnir-open-server server)))
 
 
+(defun nnir-search-thread (header)
+  "Make an nnir group based on the thread containing the article header"
+  (let ((parm (list
+	       (cons 'query
+		     (nnimap-make-thread-query header))
+	       (cons 'criteria "")
+	       (cons 'server (gnus-method-to-server
+			      (gnus-find-method-for-group
+			       gnus-newsgroup-name))))))
+    (gnus-group-make-nnir-group nil parm)))
 
 ;; unused?
 (defun nnir-artlist-groups (artlist)

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog   |   11 ++++++++++
 lisp/gnus-sum.el |   55 +++++++++++++++++++++++++++++++++++------------------
 lisp/nnimap.el   |   20 ++++++++++--------
 lisp/nnir.el     |   11 ++++++++++
 4 files changed, 69 insertions(+), 28 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.