From 88391b3cdca85f30e32fcbb790c457d1ba8a63f6 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Sat, 18 Sep 2010 03:52:14 +0200 Subject: [PATCH] nnimap-related changes to avoid bugging out if we can't contact a server. * 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 | 12 ++++++++++++ lisp/gnus-int.el | 4 ++++ lisp/gnus-start.el | 1 + lisp/gnus-sum.el | 10 +++++----- lisp/nnimap.el | 32 +++++++++++++++++++------------- 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ff8fb4648..76e9b4b35 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,17 @@ 2010-09-18 Lars Magne Ingebrigtsen + * 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 diff --git a/lisp/gnus-int.el b/lisp/gnus-int.el index 24764c082..389b1a22a 100644 --- a/lisp/gnus-int.el +++ b/lisp/gnus-int.el @@ -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) diff --git a/lisp/gnus-start.el b/lisp/gnus-start.el index 1d8093b7d..e25d31ec8 100644 --- a/lisp/gnus-start.el +++ b/lisp/gnus-start.el @@ -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)) diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 3e737c39e..3c3a05905 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -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) diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 7d2c9a705..e7bf0f376 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -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." -- 2.25.1