(nnir-retrieve-headers): Bind gnus-override-method before calling
[gnus] / contrib / nnir.el
index e3a8fe4..77503f4 100644 (file)
@@ -18,8 +18,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -532,18 +532,31 @@ that it is for swish++, not Glimpse."
   :type '(regexp)
   :group 'nnir)
 
-;; Swish-E.  Next three variables Copyright (C) 2000 Christoph Conrad
-;; <christoph.conrad@gmx.de>.
+;; Swish-E.
 ;; URL: http://sunsite.berkeley.edu/SWISH-E/
 ;; New version: http://www.boe.es/swish-e
+;; Variables `nnir-swish-e-index-file', `nnir-swish-e-program' and
+;; `nnir-swish-e-additional-switches'
+;; Copyright (C) 2000 Christoph Conrad <christoph.conrad@gmx.de>.
 
+(make-obsolete-variable 'nnir-swish-e-index-file
+                       'nnir-swish-e-index-files)
 (defcustom nnir-swish-e-index-file
   (expand-file-name "~/Mail/index.swish-e")
   "*Index file for swish-e.
-This could be a server parameter."
+This could be a server parameter.
+It is never consulted once `nnir-swish-e-index-files', which should be
+used instead, has been customized."
   :type '(file)
   :group 'nnir)
 
+(defcustom nnir-swish-e-index-files
+  (list nnir-swish-e-index-file)
+  "*List of index files for swish-e.
+This could be a server parameter."
+  :type '(repeat (file))
+  :group 'nnir)
+
 (defcustom nnir-swish-e-program "swish-e"
   "*Name of swish-e search executable.
 This cannot be a server parameter."
@@ -777,7 +790,6 @@ and show thread that contains this article."
 (deffoo nnir-retrieve-headers (articles &optional group server fetch-old)
   (save-excursion
     (let ((artlist (copy-sequence articles))
-          (idx 1)
           (art nil)
           (artitem nil)
           (artgroup nil) (artno nil)
@@ -804,27 +816,29 @@ and show thread that contains this article."
         ;; NOV data and prepend to `novdata'
         (set-buffer nntp-server-buffer)
        (nnir-possibly-change-server server)
-        (case (setq foo (gnus-retrieve-headers (list artno) artfullgroup nil))
-          (nov
-           (goto-char (point-min))
-           (setq novitem (nnheader-parse-nov))
-           (unless novitem
-             (pop-to-buffer nntp-server-buffer)
-             (error
-              "nnheader-parse-nov returned nil for article %s in group %s"
-              artno artfullgroup)))
-          (headers
-           (goto-char (point-min))
-           (setq novitem (nnheader-parse-head))
-           (unless novitem
-             (pop-to-buffer nntp-server-buffer)
-             (error
-              "nnheader-parse-head returned nil for article %s in group %s"
-              artno artfullgroup)))
-          (t (nnheader-report 'nnir "Don't support header type %s." foo)))
+        (let ((gnus-override-method
+              (gnus-server-to-method server)))
+         (case (setq foo (gnus-retrieve-headers (list artno) artfullgroup nil))
+           (nov
+            (goto-char (point-min))
+            (setq novitem (nnheader-parse-nov))
+            (unless novitem
+              (pop-to-buffer nntp-server-buffer)
+              (error
+               "nnheader-parse-nov returned nil for article %s in group %s"
+               artno artfullgroup)))
+           (headers
+            (goto-char (point-min))
+            (setq novitem (nnheader-parse-head))
+            (unless novitem
+              (pop-to-buffer nntp-server-buffer)
+              (error
+               "nnheader-parse-head returned nil for article %s in group %s"
+               artno artfullgroup)))
+           (t (nnheader-report 'nnir "Don't support header type %s." foo))))
        ;; replace article number in original group with article number
         ;; in nnir group
-        (mail-header-set-number novitem idx)
+        (mail-header-set-number novitem art)
         (mail-header-set-from novitem
                               (mail-header-from novitem))
         (mail-header-set-subject
@@ -834,8 +848,7 @@ and show thread that contains this article."
                  (mail-header-subject novitem)))
         ;;-(mail-header-set-extra novitem nil)
         (push novitem novdata)
-        (setq artlist (cdr artlist))
-        (setq idx (1+ idx)))
+        (setq artlist (cdr artlist)))
       (setq novdata (nreverse novdata))
       (set-buffer nntp-server-buffer) (erase-buffer)
       (mapcar 'nnheader-insert-nov novdata)
@@ -843,22 +856,27 @@ and show thread that contains this article."
 
 (deffoo nnir-request-article (article
                               &optional group server to-buffer)
-  (save-excursion
-    (let* ((artitem (nnir-artlist-article nnir-artlist
-                                          article))
-           (artfullgroup (nnir-artitem-group artitem))
-           (artno (nnir-artitem-number artitem))
-           ;; Bug?
-           ;; Why must we bind nntp-server-buffer here?  It won't
-           ;; work if `buf' is used, say.  (Of course, the set-buffer
-           ;; line below must then be updated, too.)
-           (nntp-server-buffer (or to-buffer nntp-server-buffer)))
-      (set-buffer nntp-server-buffer)
-      (erase-buffer)
-      (message "Requesting article %d from group %s"
-               artno artfullgroup)
-      (gnus-request-article artno artfullgroup nntp-server-buffer)
-      (cons artfullgroup artno))))
+  (if (stringp article)
+      (nnheader-report
+       'nnir
+       "nnir-retrieve-headers doesn't grok message ids: %s"
+       article)
+    (save-excursion
+      (let* ((artitem (nnir-artlist-article nnir-artlist
+                                           article))
+            (artfullgroup (nnir-artitem-group artitem))
+            (artno (nnir-artitem-number artitem))
+            ;; Bug?
+            ;; Why must we bind nntp-server-buffer here?  It won't
+            ;; work if `buf' is used, say.  (Of course, the set-buffer
+            ;; line below must then be updated, too.)
+            (nntp-server-buffer (or to-buffer nntp-server-buffer)))
+       (set-buffer nntp-server-buffer)
+       (erase-buffer)
+       (message "Requesting article %d from group %s"
+                artno artfullgroup)
+       (gnus-request-article artno artfullgroup nntp-server-buffer)
+       (cons artfullgroup artno)))))
 
 
 (nnoo-define-skeleton nnir)
@@ -1134,7 +1152,11 @@ Windows NT 4.0."
               dirnam (file-name-directory (match-string 2)))
 
         ;; don't match directories
-        (when (string-match "^[0-9]+$" artno)
+        (when (string-match "^[0-9]+\\(\\.[a-z0-9]+\\)?$" artno)
+         ;; nnml-use-compressed-files might be any string, but probably this
+         ;; is sufficient.  Note that we can't only use the value of
+         ;; nnml-use-compressed-files because old articles might have been
+         ;; saved with a different value.
           (when (not (null dirnam))
 
            ;; maybe limit results to matching groups.
@@ -1196,10 +1218,10 @@ Tested with swish-e-2.0.1 on Windows NT 4.0."
       (erase-buffer)
 
       (message "Doing swish-e query %s..." query)
-      (let* ((index-file
+      (let* ((index-files
              (or (nnir-read-server-parm
-                  'nnir-swish-e-index-file server)
-                 (error "Missing parameter `nnir-swish-e-index-file'")))
+                  'nnir-swish-e-index-files server)
+                 (error "Missing parameter `nnir-swish-e-index-files'")))
             (additional-switches
              (nnir-read-server-parm
               'nnir-swish-e-additional-switches server))
@@ -1207,7 +1229,7 @@ Tested with swish-e-2.0.1 on Windows NT 4.0."
                        nil             ; input from /dev/null
                        t               ; output
                        nil             ; don't redisplay
-                       "-f" ,index-file
+                       "-f" ,@index-files
                        ,@additional-switches
                        "-w"
                        ,qstring        ; the query, in swish-e format
@@ -1482,7 +1504,7 @@ form 'backend:name'."
     (cond ((and method (assq key (cddr method)))
           (nth 1 (assq key (cddr method))))
          ((and nnir-mail-backend
-               (gnus-method-equal method nnir-mail-backend))
+               (gnus-server-equal method nnir-mail-backend))
           (symbol-value key))
          ((null nnir-mail-backend)
           (symbol-value key))
@@ -1536,7 +1558,7 @@ The Gnus backend/server information is added."
 
 (defun nnir-artlist-artitem-rsv (artlist n)
   "Returns from ARTLIST the Retrieval Status Value of the Nth artitem
-(counting from 1)."
+\(counting from 1)."
   (nnir-artitem-rsv (nnir-artlist-article artlist n)))
 
 ;; unused?