Do a `gnus-request-scan' for the methods that support -retrieve-groups, too.
[gnus] / lisp / gnus-start.el
index 3c78ac9..a349475 100644 (file)
@@ -1526,7 +1526,8 @@ newsgroup."
          (when (> (cdr cache-active) (cdr active))
            (setcdr active (cdr cache-active))))))))
 
-(defun gnus-activate-group (group &optional scan dont-check method)
+(defun gnus-activate-group (group &optional scan dont-check method
+                                 dont-sub-check)
   "Check whether a group has been activated or not.
 If SCAN, request a scan of that group as well."
   (let ((method (or method (inline (gnus-find-method-for-group group))))
@@ -1541,9 +1542,11 @@ If SCAN, request a scan of that group as well."
                (gnus-request-scan group method))
           t)
         (if (or debug-on-error debug-on-quit)
-            (inline (gnus-request-group group dont-check method))
+            (inline (gnus-request-group group (or dont-sub-check dont-check)
+                                        method))
           (condition-case nil
-              (inline (gnus-request-group group dont-check method))
+              (inline (gnus-request-group group (or dont-sub-check dont-check)
+                                          method))
             ;;(error nil)
             (quit
              (message "Quit activating %s" group)
@@ -1684,7 +1687,9 @@ If SCAN, request a scan of that group as well."
           alevel))
         (methods-cache nil)
         (type-cache nil)
-        scanned-methods info group active method retrieve-groups cmethod
+        (gnus-agent-article-local-times 0)
+        (archive-method (gnus-server-to-method "archive"))
+        infos info group active method cmethod
         method-type method-group-list)
     (gnus-message 6 "Checking new news...")
 
@@ -1719,7 +1724,9 @@ If SCAN, request a scan of that group as well."
       (unless method-group-list
        (setq method-type
              (cond
-              ((gnus-secondary-method-p method)
+              ((or (gnus-secondary-method-p method)
+                   (and (gnus-archive-server-wanted-p)
+                        (gnus-methods-equal-p archive-method method)))
                'secondary)
               ((inline (gnus-server-equal gnus-select-method method))
                'primary)
@@ -1727,8 +1734,13 @@ If SCAN, request a scan of that group as well."
                'foreign)))
        (push (setq method-group-list (list method method-type nil))
              type-cache))
-      (setcar (nthcdr 2 method-group-list)
-             (cons info (nth 2 method-group-list))))
+      ;; Only add groups that need updating.
+      (when (<= (gnus-info-level info)
+               (if (eq (cadr method-group-list) 'foreign)
+                   foreign-level
+                 alevel))
+       (setcar (nthcdr 2 method-group-list)
+               (cons info (nth 2 method-group-list)))))
 
     ;; Sort the methods based so that the primary and secondary
     ;; methods come first.  This is done for legacy reasons to try to
@@ -1746,22 +1758,20 @@ If SCAN, request a scan of that group as well."
            infos (nth 2 (car type-cache)))
       (pop type-cache)
 
-      ;; See if any of the groups from this method require updating.
-      (when (block nil
-             (dolist (info infos)
-               (when (< (gnus-info-level info)
-                        (if (eq method-type 'foreign)
-                            foreign-level
-                          alevel))
-                 (return t))))
+      (when (and method
+                infos)
+       ;; See if any of the groups from this method require updating.
        (gnus-read-active-for-groups method infos)
        (dolist (info infos)
          (inline (gnus-get-unread-articles-in-group
-                  info (gnus-active (gnus-info-group info)) t)))))
+                  info (gnus-active (gnus-info-group info)))))))
     (gnus-message 6 "Checking new news...done")))
 
 (defun gnus-method-rank (type method)
   (cond
+   ;; Get info for virtual groups last.
+   ((eq (car method) 'nnvirtual)
+    200)
    ((eq type 'primary)
     1)
    ;; Compute the rank of the secondary methods based on where they
@@ -1770,7 +1780,7 @@ If SCAN, request a scan of that group as well."
     (let ((i 2))
       (block nil
        (dolist (smethod gnus-secondary-select-methods)
-         (when (equalp method smethod)
+         (when (equal method smethod)
            (return i))
          (incf i))
        i)))
@@ -1782,15 +1792,18 @@ If SCAN, request a scan of that group as well."
   (with-current-buffer nntp-server-buffer
     (cond
      ((gnus-check-backend-function 'retrieve-groups (car method))
+      (when (gnus-check-backend-function 'request-scan (car method))
+       (gnus-request-scan nil method))
       (gnus-read-active-file-2
        (mapcar (lambda (info)
-                (gnus-info-group info))
+                (gnus-group-real-name (gnus-info-group info)))
               infos)
        method))
      ((gnus-check-backend-function 'request-list (car method))
       (gnus-read-active-file-1 method nil))
      (t
-      (error "No method for %S" method)))))
+      (dolist (info infos)
+       (gnus-activate-group (gnus-info-group info) nil nil method t))))))
 
 ;; Create a hash table out of the newsrc alist.  The `car's of the
 ;; alist elements are used as keys.
@@ -1812,14 +1825,18 @@ If SCAN, request a scan of that group as well."
        (if (setq rest (member method methods))
            (gnus-info-set-method info (car rest))
          (push method methods)))
-      (gnus-sethash
-       (car info)
-       ;; Preserve number of unread articles in groups.
-       (cons (and ohashtb (car (gnus-gethash (car info) ohashtb)))
-            prev)
-       gnus-newsrc-hashtb)
-      (setq prev alist
-           alist (cdr alist)))
+      ;; Check for duplicates.
+      (if (gnus-gethash (car info) gnus-newsrc-hashtb)
+         ;; Remove this entry from the alist.
+         (setcdr prev (cddr prev))
+       (gnus-sethash
+        (car info)
+        ;; Preserve number of unread articles in groups.
+        (cons (and ohashtb (car (gnus-gethash (car info) ohashtb)))
+              prev)
+        gnus-newsrc-hashtb)
+       (setq prev alist))
+      (setq alist (cdr alist)))
     ;; Make the same select-methods in `gnus-server-alist' identical
     ;; as well.
     (while methods
@@ -3177,5 +3194,3 @@ If this variable is nil, don't do anything."
 (provide 'gnus-start)
 
 ;;; gnus-start.el ends here
-
-