--- nnir.el.orig	Fri Dec 15 18:57:43 2000
+++ nnir.el	Fri Dec 15 21:21:15 2000
@@ -268,6 +268,8 @@
 	     ())
     (imap    nnir-run-imap
              ())
+    (pick    nnir-run-pick-search
+	     ())
     (swish++ nnir-run-swish++
              ())
     (swish-e nnir-run-swish-e
@@ -408,6 +410,14 @@
   :type '(directory)
   :group 'nnir)
 
+;; (n)mh pick
+;; (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+
+(defcustom nnir-pick-program "pick"
+  "*Name of (n)mh pick executable."
+  :type '(string)
+  :group 'nnir)
+
 ;; Swish++.  Next three variables Copyright (C) 2000 Christoph Conrad
 ;; <christoph.conrad@gmx.de>.
 
@@ -842,6 +852,33 @@
       (message "Gathering query output...done")
       artlist)))
 
+(defun re-gsub (find replace str)
+  (if (string-match find str)
+      (re-gsub find replace (replace-match replace nil nil str))
+    str))
+      
+(defun nnir-run-pick-search (query &optional group)
+  (let* ((query-string (cdr (assq 'query query)))
+	 (query-options (split-string query-string))
+	 (group (gnus-group-real-name
+		  (if group group (gnus-group-group-name))))
+	 (score 1)
+	 (nnir-pick-folder (concat "+" (re-gsub "[.]" "/" group)))
+	 (numbers
+	  (with-temp-buffer
+	    (message "pick %s %s" nnir-pick-folder query-string)
+	    (let ((status
+		   (apply 'call-process (append `(,nnir-pick-program
+						  nil t nil
+						  ,nnir-pick-folder)
+						query-options))))
+	      (if (> status 0)
+		  (message "error (%d) running pick %s %s"
+			   status nnir-pick-folder query-string))
+	    (split-string (buffer-string))))))
+    (mapcar (lambda (x) (vector group (string-to-int x) score))
+	    numbers)))
+	
 ;; IMAP interface.  The following function is Copyright (C) 1998 Simon
 ;; Josefsson <jas@pdc.kth.se>.
 ;; todo:

