Merge changes in Emacs21.
[gnus] / lisp / nnkiboze.el
index 1f85c79..1ad6f8c 100644 (file)
@@ -1,5 +1,7 @@
 ;;; nnkiboze.el --- select virtual news access for Gnus
-;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc.
+
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
+;;     Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
       ;; article fetching by message-id at all.
       (nntp-request-article article newsgroup gnus-nntp-server buffer)
     (let* ((header (gnus-summary-article-header article))
-          (xref (mail-header-xref header)))
+          (xref (mail-header-xref header))
+          num group)
       (unless xref
        (error "nnkiboze: No xref"))
       (unless (string-match " \\([^ ]+\\):\\([0-9]+\\)" xref)
        (error "nnkiboze: Malformed xref"))
-      (gnus-request-article (string-to-int (match-string 2 xref))
-                           (match-string 1 xref)
-                           buffer))))
+      (setq num (string-to-int (match-string 2 xref))
+           group (match-string 1 xref))
+      (or (with-current-buffer buffer
+           (gnus-cache-request-article num group))
+         (gnus-request-article num group buffer)))))
 
 (deffoo nnkiboze-request-scan (&optional group server)
   (nnkiboze-generate-group (concat "nnkiboze:" group)))
@@ -207,7 +212,10 @@ Finds out what articles are to be part of the nnkiboze groups."
       (when (string-match "nnkiboze" (gnus-info-group info))
        ;; For each kiboze group, we call this function to generate
        ;; it.
-       (nnkiboze-generate-group (gnus-info-group info))))))
+       (nnkiboze-generate-group (gnus-info-group info) t))))
+  (save-excursion
+    (set-buffer gnus-group-buffer)
+    (gnus-group-list-groups)))
 
 (defun nnkiboze-score-file (group)
   (list (expand-file-name
@@ -216,7 +224,7 @@ Finds out what articles are to be part of the nnkiboze groups."
                  (concat (nnkiboze-prefixed-name nnkiboze-current-group)
                          "." gnus-score-file-suffix))))))
 
-(defun nnkiboze-generate-group (group)
+(defun nnkiboze-generate-group (group &optional inhibit-list-groups)
   (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
         (newsrc-file (concat nnkiboze-directory
                               (nnheader-translate-file-chars
@@ -230,6 +238,9 @@ Finds out what articles are to be part of the nnkiboze groups."
         (gnus-expert-user t)
         (gnus-large-newsgroup nil)
         (gnus-score-find-score-files-function 'nnkiboze-score-file)
+        ;; Use only nnkiboze-score-file!
+        (gnus-score-use-all-scores nil)
+        (gnus-use-scoring t)
         (gnus-verbose (min gnus-verbose 3))
         gnus-select-group-hook gnus-summary-prepare-hook
         gnus-thread-sort-functions gnus-show-threads
@@ -332,9 +343,10 @@ Finds out what articles are to be part of the nnkiboze groups."
       (insert "(setq nnkiboze-newsrc '")
       (gnus-prin1 nnkiboze-newsrc)
       (insert ")\n")))
-  (save-excursion
-    (set-buffer gnus-group-buffer)
-    (gnus-group-list-groups))
+  (unless inhibit-list-groups
+    (save-excursion
+      (set-buffer gnus-group-buffer)
+      (gnus-group-list-groups)))
   t)
 
 (defun nnkiboze-enter-nov (buffer header group)
@@ -351,11 +363,11 @@ Finds out what articles are to be part of the nnkiboze groups."
        (setq article 1))
       (mail-header-set-number oheader article)
       (with-temp-buffer
-       (insert (mail-header-xref oheader))
+       (insert (or (mail-header-xref oheader) ""))
        (goto-char (point-min))
        (if (re-search-forward " [^ ]+:[0-9]+" nil t)
            (goto-char (match-beginning 0))
-       (forward-char 1))
+         (or (eobp) (forward-char 1)))
        ;; The first Xref has to be the group this article
        ;; really came for - this is the article nnkiboze
        ;; will request when it is asked for the article.