Synch with Oort Gnus.
[elisp/gnus.git-] / lisp / mail-source.el
index 30fab7f..6cc9e78 100644 (file)
@@ -457,13 +457,15 @@ Return the number of files that were found."
              (setq found (mail-source-callback
                           callback mail-source-crash-box)))
            (+ found
-              (condition-case err
+              (if (or debug-on-quit debug-on-error)
                   (funcall function source callback)
-                (error
-                 (unless (yes-or-no-p
-                          (format "Mail source error (%s).  Continue? " err))
-                   (error "Cannot get new mail"))
-                 0))))))))
+                (condition-case err
+                    (funcall function source callback)
+                  (error
+                   (unless (yes-or-no-p
+                            (format "Mail source error (%s).  Continue? " err))
+                     (error "Cannot get new mail"))
+                   0)))))))))
 
 (defun mail-source-make-complex-temp-name (prefix)
   (let ((newname (make-temp-name prefix))
@@ -682,15 +684,17 @@ If ARGS, PROMPT is used as an argument to `format'."
                     (or leave
                         (and (boundp 'pop3-leave-mail-on-server)
                              pop3-leave-mail-on-server))))
-               (condition-case err
+               (if (or debug-on-quit debug-on-error)
                    (save-excursion (pop3-movemail mail-source-crash-box))
-                 (error
-                  ;; We nix out the password in case the error
-                  ;; was because of a wrong password being given.
-                  (setq mail-source-password-cache
-                        (delq (assoc from mail-source-password-cache)
-                              mail-source-password-cache))
-                  (signal (car err) (cdr err))))))))
+                 (condition-case err
+                     (save-excursion (pop3-movemail mail-source-crash-box))
+                   (error
+                    ;; We nix out the password in case the error
+                    ;; was because of a wrong password being given.
+                    (setq mail-source-password-cache
+                          (delq (assoc from mail-source-password-cache)
+                                mail-source-password-cache))
+                    (signal (car err) (cdr err)))))))))
       (if result
          (progn
            (when (eq authentication 'password)
@@ -741,15 +745,17 @@ If ARGS, PROMPT is used as an argument to `format'."
                    (pop3-port port)
                    (pop3-authentication-scheme
                     (if (eq authentication 'apop) 'apop 'pass)))
-               (condition-case err
+               (if (or debug-on-quit debug-on-error)
                    (save-excursion (pop3-get-message-count))
-                 (error
-                  ;; We nix out the password in case the error
-                  ;; was because of a wrong password being given.
-                  (setq mail-source-password-cache
-                        (delq (assoc from mail-source-password-cache)
-                              mail-source-password-cache))
-                  (signal (car err) (cdr err))))))))
+                 (condition-case err
+                     (save-excursion (pop3-get-message-count))
+                   (error
+                    ;; We nix out the password in case the error
+                    ;; was because of a wrong password being given.
+                    (setq mail-source-password-cache
+                          (delq (assoc from mail-source-password-cache)
+                                mail-source-password-cache))
+                    (signal (car err) (cdr err)))))))))
       (if result
          ;; Inform display-time that we have new mail.
          (setq mail-source-new-mail-available (> result 0))
@@ -919,10 +925,11 @@ This only works when `display-time' is enabled."
                  (push (cons from imap-password) mail-source-password-cache)))
              ;; if predicate is nil, use all uids
              (dolist (uid (imap-search (or predicate "1:*") buf))
-               (when (setq str (if (imap-capability 'IMAP4rev1 buf)
-                                   (imap-fetch uid "BODY.PEEK[]" 'BODYDETAIL
-                                               nil buf)
-                           (imap-fetch uid "RFC822.PEEK" 'RFC822 nil buf)))
+               (when (setq str
+                           (if (imap-capability 'IMAP4rev1 buf)
+                               (caddar (imap-fetch uid "BODY.PEEK[]"
+                                                   'BODYDETAIL nil buf))
+                             (imap-fetch uid "RFC822.PEEK" 'RFC822 nil buf)))
                  (push uid remove)
                  (insert "From imap " (current-time-string) "\n")
                  (save-excursion
@@ -938,7 +945,7 @@ This only works when `display-time' is enabled."
               fetchflag nil buf))
            (if dontexpunge
                (imap-mailbox-unselect buf)
-             (imap-mailbox-close buf))
+             (imap-mailbox-close nil buf))
            (imap-close buf))
        (imap-close buf)
        ;; We nix out the password in case the error