Import Oort Gnus v0.13.
[elisp/gnus.git-] / lisp / gnus-int.el
index da22bb5..3536822 100644 (file)
 (eval-when-compile (require 'cl))
 
 (require 'gnus)
+(require 'message)
+(require 'gnus-range)
+
+(eval-when-compile
+  (defun gnus-agent-expire (a b c)))
 
 (defcustom gnus-open-server-hook nil
   "Hook called just before opening connection to the news server."
@@ -219,12 +224,21 @@ If it is down, start it up (again)."
                               (format "Unable to open %s:%s, go offline? "
                                       (car gnus-command-method)
                                       (cadr gnus-command-method)))
-                             'offline
+                              'offline
                            'denied))
                    'denied)))
        ;; Return the result from the "open" call.
-       (or (eq (cadr elem) 'offline)
-           result)))))
+        (cond ((eq (cadr elem) 'offline)
+               ;; I'm avoiding infinite recursion by binding unopen
+               ;; status to denied (The logic of this routine
+               ;; guarantees that I can't get to this point with
+               ;; unopen status already bound to denied).
+               (unless (eq gnus-server-unopen-status 'denied)
+                 (let ((gnus-server-unopen-status 'denied))
+                   (gnus-open-server gnus-command-method)))
+               t)
+              (t
+               result))))))
 
 (defun gnus-close-server (gnus-command-method)
   "Close the connection to GNUS-COMMAND-METHOD."
@@ -507,10 +521,10 @@ If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
           (gnus-get-function gnus-command-method 'request-expire-articles)
           articles (gnus-group-real-name group) (nth 1 gnus-command-method)
           force)))
-    (when (and gnus-agent gnus-agent-cache
-              (gnus-sorted-difference articles not-deleted))
-      (gnus-agent-expire (gnus-sorted-difference articles not-deleted)
-                        group 'force))
+    (when (and gnus-agent gnus-agent-cache (gnus-agent-method-p gnus-command-method))
+      (let ((expired-articles (gnus-sorted-difference articles not-deleted)))
+        (when expired-articles
+          (gnus-agent-expire expired-articles group 'force))))
     not-deleted))
 
 (defun gnus-request-move-article (article group server accept-function &optional last)
@@ -518,7 +532,7 @@ If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
         (result (funcall (gnus-get-function gnus-command-method 'request-move-article)
                          article (gnus-group-real-name group)
                          (nth 1 gnus-command-method) accept-function last)))
-    (when (and result gnus-agent gnus-agent-cache)
+    (when (and result gnus-agent gnus-agent-cache (gnus-agent-method-p gnus-command-method))
       (gnus-agent-expire (list article) group 'force))
     result))