nnimap-related changes to avoid bugging out if we can't contact a server.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 18 Sep 2010 01:52:14 +0000 (03:52 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 18 Sep 2010 01:52:14 +0000 (03:52 +0200)
* gnus-start.el (gnus-get-unread-articles): Don't try to scan groups
from methods that are denied.

* nnimap.el (nnimap-possibly-change-group): Return nil if we can't log
in.
(nnimap-finish-retrieve-group-infos): Make sure we're not waiting for
nothing.

* gnus-sum.el (gnus-select-newsgroup): Indent.

lisp/ChangeLog
lisp/gnus-int.el
lisp/gnus-start.el
lisp/gnus-sum.el
lisp/nnimap.el

index ff8fb46..76e9b4b 100644 (file)
@@ -1,5 +1,17 @@
 2010-09-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * gnus-sum.el (gnus-select-newsgroup): Indent.
+
+       * nnimap.el (nnimap-possibly-change-group): Return nil if we can't log
+       in.
+       (nnimap-finish-retrieve-group-infos): Make sure we're not waiting for
+       nothing.
+
+       * gnus-start.el (gnus-get-unread-articles): Don't try to scan groups
+       from methods that are denied.
+
+       * gnus-int.el (gnus-method-denied-p): New function.
+
        * nnimap.el (nnimap-open-connection): Use auth-sources to query and
        store the password instead of netrc.
        (nnimap-open-connection): Don't error out when we can't make a
index 24764c0..389b1a2 100644 (file)
@@ -222,6 +222,10 @@ If it is down, start it up (again)."
 ;;; Interface functions to the backends.
 ;;;
 
+(defun gnus-method-denied-p (method)
+  (eq (nth 1 (assoc method gnus-opened-servers))
+      'denied))
+
 (defun gnus-open-server (gnus-command-method)
   "Open a connection to GNUS-COMMAND-METHOD."
   (when (stringp gnus-command-method)
index 1d8093b..e25d31e 100644 (file)
@@ -1757,6 +1757,7 @@ If SCAN, request a scan of that group as well."
     (dolist (elem type-cache)
       (destructuring-bind (method method-type infos dummy) elem
        (when (and method infos
+                  (not (gnus-method-denied-p method))
                   (gnus-check-backend-function
                    'retrieve-group-data-early (car method)))
          (when (gnus-check-backend-function 'request-scan (car method))
index 3e737c3..3c3a059 100644 (file)
@@ -5504,11 +5504,11 @@ If SELECT-ARTICLES, only select those articles from GROUP."
           (mm-decode-coding-string (gnus-status-message group) charset))))
 
     (unless (gnus-request-group group t)
-       (when (equal major-mode 'gnus-summary-mode)
-         (gnus-kill-buffer (current-buffer)))
-       (error "Couldn't request group %s: %s"
-              (mm-decode-coding-string group charset)
-              (mm-decode-coding-string (gnus-status-message group) charset)))
+      (when (equal major-mode 'gnus-summary-mode)
+       (gnus-kill-buffer (current-buffer)))
+      (error "Couldn't request group %s: %s"
+            (mm-decode-coding-string group charset)
+            (mm-decode-coding-string (gnus-status-message group) charset)))
 
     (when gnus-agent
       (gnus-agent-possibly-alter-active group (gnus-active group) info)
index 7d2c9a7..e7bf0f3 100644 (file)
@@ -551,7 +551,8 @@ not done by default on servers that doesn't support that command.")
        sequences))))
 
 (defun nnimap-finish-retrieve-group-infos (server infos sequences)
-  (when (nnimap-possibly-change-group nil server)
+  (when (and sequences
+            (nnimap-possibly-change-group nil server))
     (with-current-buffer (nnimap-buffer)
       ;; Wait for the final data to trickle in.
       (nnimap-wait-for-response (cadar sequences))
@@ -681,18 +682,23 @@ not done by default on servers that doesn't support that command.")
   nil)
 
 (defun nnimap-possibly-change-group (group server)
-  (when (and server
-            (not (nnimap-server-opened server)))
-    (nnimap-open-server server))
-  (if (not group)
-      t
-    (with-current-buffer (nnimap-buffer)
-      (if (equal group (nnimap-group nnimap-object))
-         t
-       (let ((result (nnimap-command "SELECT %S" (utf7-encode group t))))
-         (when (car result)
-           (setf (nnimap-group nnimap-object) group)
-           result))))))
+  (let ((open-result t))
+    (when (and server
+              (not (nnimap-server-opened server)))
+      (setq open-result (nnimap-open-server server)))
+    (cond
+     ((not open-result)
+      nil)
+     ((not group)
+      t)
+     (t
+      (with-current-buffer (nnimap-buffer)
+       (if (equal group (nnimap-group nnimap-object))
+           t
+         (let ((result (nnimap-command "SELECT %S" (utf7-encode group t))))
+           (when (car result)
+             (setf (nnimap-group nnimap-object) group)
+             result))))))))
 
 (defun nnimap-find-connection (buffer)
   "Find the connection delivering to BUFFER."