From: Reiner Steib Date: Thu, 1 Jan 2009 18:24:40 +0000 (+0000) Subject: * imap.el (imap-string-to-integer): Fix typo. X-Git-Url: http://cgit.sxemacs.org/?a=commitdiff_plain;h=3b5eb0cdcbff3c3b1a0c3c1127c004369f21edf8;p=gnus * imap.el (imap-string-to-integer): Fix typo. (imap-fetch-safe): New function. (imap-message-copyuid-1, imap-message-appenduid-1): Use it. * nnimap.el (nnimap-find-minmax-uid): Use imap-fetch-safe. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 28dd79b4d..f4ae9f69d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2009-01-01 Dave Love + + * imap.el (imap-string-to-integer): Fix typo. + (imap-fetch-safe): New function. + (imap-message-copyuid-1, imap-message-appenduid-1): Use it. + + * nnimap.el (nnimap-find-minmax-uid): Use imap-fetch-safe. + 2008-12-26 Reiner Steib * dns.el (dns-set-servers): Check "Address". Fix typo. diff --git a/lisp/imap.el b/lisp/imap.el index f0161b337..053a95a49 100644 --- a/lisp/imap.el +++ b/lisp/imap.el @@ -1,7 +1,7 @@ ;;; imap.el --- imap library ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. ;; Author: Simon Josefsson ;; Keywords: mail @@ -1772,9 +1772,38 @@ is non-nil return these properties." (let ((number (string-to-number string base))) (if (> number most-positive-fixnum) (error - (format "String %s cannot be converted to a lisp integer" number)) + (format "String %s cannot be converted to a Lisp integer" number)) number))) +(defun imap-fetch-safe (uids props &optional receive nouidfetch buffer) + "Like `imap-fetch', but DTRT with Exchange 2007 bug. +However, UIDS here is a cons, where the car is the canonical form +of the UIDS specification, and the cdr is the one which works with +Exchange 2007 or, potentially, other buggy servers. +See `imap-enable-exchange-bug-workaround'." + ;; We don't unconditionally use the alternative (valid) form, since + ;; this is said to be significantly inefficient. The first time we + ;; get here for a given, we'll try the canonical form. If we get + ;; the known error from the buggy server, set the flag + ;; buffer-locally (to account for connexions to multiple servers), + ;; then re-try with the alternative UIDS spec. + (condition-case data + (imap-fetch (if imap-enable-exchange-bug-workaround + (cdr uids) + (car uids)) + props receive nouidfetch buffer) + (error + (if (and (not imap-enable-exchange-bug-workaround) + (string-match + "The specified message set is invalid" + (cadr data))) + (with-current-buffer (or buffer (current-buffer)) + (set (make-local-variable + 'imap-enable-exchange-bug-workaround) + t) + (imap-fetch (cdr uids) props receive nouidfetch)) + (signal (car data) (cdr data)))))) + (defun imap-message-copyuid-1 (mailbox) (if (imap-capability 'UIDPLUS) (list (nth 0 (imap-mailbox-get-1 'copyuid mailbox)) @@ -1784,11 +1813,7 @@ is non-nil return these properties." (imap-message-data (make-vector 2 0))) (when (imap-mailbox-examine-1 mailbox) (prog1 - (and (imap-fetch - ;; why the switch here, since they seem to be - ;; equivalent, and ~ no-one is going to find this - ;; switch? -- fx - (if imap-enable-exchange-bug-workaround "*:*" "*") "UID") + (and (imap-fetch-safe '("*" . "*:*") "UID") (list (imap-mailbox-get-1 'uidvalidity mailbox) (apply 'max (imap-message-map (lambda (uid prop) uid) 'UID)))) @@ -1832,8 +1857,7 @@ first element. The rest of list contains the saved articles' UIDs." (imap-message-data (make-vector 2 0))) (when (imap-mailbox-examine-1 mailbox) (prog1 - (and (imap-fetch - (if imap-enable-exchange-bug-workaround "*:*" "*") "UID") + (and (imap-fetch-safe '("*" "*:*") "UID") (list (imap-mailbox-get-1 'uidvalidity mailbox) (apply 'max (imap-message-map (lambda (uid prop) uid) 'UID)))) diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 898bec854..2a22ee7bb 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -1,7 +1,7 @@ ;;; nnimap.el --- imap backend for Gnus ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -;; 2007, 2008 Free Software Foundation, Inc. +;; 2007, 2008, 2009 Free Software Foundation, Inc. ;; Author: Simon Josefsson ;; Jim Radford @@ -555,8 +555,7 @@ If EXAMINE is non-nil the group is selected read-only." (imap-mailbox-select group examine)) (let (minuid maxuid) (when (> (imap-mailbox-get 'exists) 0) - (imap-fetch (if imap-enable-exchange-bug-workaround "1,*:*" "1,*") - "UID" nil 'nouidfetch) + (imap-fetch-safe '("1,*" . "1,*:*") "UID" nil 'nouidfetch) (imap-message-map (lambda (uid Uid) (setq minuid (if minuid (min minuid uid) uid) maxuid (if maxuid (max maxuid uid) uid)))