(nnir-read-server-parm): Do not unconditionally fall back to global
[gnus] / contrib / nnir.el
index 0b88a8f..640d958 100644 (file)
@@ -704,16 +704,17 @@ that it is for Namazu, not Glimpse."
 (add-hook 'gnus-group-mode-hook 'nnir-group-mode-hook)
 
 (defmacro nnir-group-server (group)
-  "Return the server for a foreign newsgroup GROUP.
+  "Return the server for a newsgroup GROUP.
 The returned format is as `gnus-server-to-method' needs it.  See
 `gnus-group-real-prefix' and `gnus-group-real-name'."
   `(let ((gname ,group))
      (if (string-match "^\\([^:]+\\):" gname)
-        (setq gname (match-string 1 gname))
-       nil)
-     (if (string-match "^\\([^+]+\\)\\+\\(.+\\)$" gname)
-        (format "%s:%s" (match-string 1 gname) (match-string 2 gname))
-       (concat gname ":"))))
+        (progn
+          (setq gname (match-string 1 gname))
+          (if (string-match "^\\([^+]+\\)\\+\\(.+\\)$" gname)
+              (format "%s:%s" (match-string 1 gname) (match-string 2 gname))
+            (concat gname ":")))
+       "native")))
 
 ;; Summary mode commands.
 
@@ -790,7 +791,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)
@@ -817,27 +817,30 @@ 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)))
-       ;; replace article number in original group with article number
+        (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 (error "Unknown header type %s while requesting article %s of group %s"
+                     foo artno artfullgroup))))
+       ;; 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
@@ -847,8 +850,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)
@@ -856,22 +858,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)
@@ -1147,7 +1154,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.
@@ -1495,9 +1506,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))
-          (symbol-value key))
-         ((null nnir-mail-backend)
+               (gnus-server-equal method nnir-mail-backend))
           (symbol-value key))
          (t nil))))
 ;;     (if method
@@ -1549,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?