(mail-source-fetch): Reverse the return value of
[gnus] / lisp / mail-source.el
index 0bab31f..e2033ef 100644 (file)
@@ -1,5 +1,5 @@
 ;;; mail-source.el --- functions for fetching mail
-;; Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news, mail
@@ -60,6 +60,7 @@
 This variable is a list of mail source specifiers.
 See Info node `(gnus)Mail Source Specifiers'."
   :group 'mail-source
+  :link '(custom-manual "(gnus)Mail Source Specifiers")
   :type `(repeat
          (choice :format "%[Value Menu%] %v"
                  :value (file)
@@ -83,10 +84,16 @@ See Info node `(gnus)Mail Source Specifiers'."
                                          (function :tag "Predicate"))
                                   (group :inline t
                                          (const :format "" :value :prescript)
-                                         (string :tag "Prescript"))
+                                         (choice :tag "Prescript"
+                                                 :value nil
+                                                 (string :format "%v")
+                                                 (function :format "%v")))
                                   (group :inline t
                                          (const :format "" :value :postscript)
-                                         (string :tag "Postscript"))
+                                         (choice :tag "Postscript"
+                                                 :value nil
+                                                 (string :format "%v")
+                                                 (function :format "%v")))
                                   (group :inline t
                                          (const :format "" :value :plugged)
                                          (boolean :tag "Plugged"))))
@@ -113,10 +120,16 @@ See Info node `(gnus)Mail Source Specifiers'."
                                          (string :tag "Program"))
                                   (group :inline t
                                          (const :format "" :value :prescript)
-                                         (string :tag "Prescript"))
+                                         (choice :tag "Prescript"
+                                                 :value nil
+                                                 (string :format "%v")
+                                                 (function :format "%v")))
                                   (group :inline t
                                          (const :format "" :value :postscript)
-                                         (string :tag "Postscript"))
+                                         (choice :tag "Postscript"
+                                                 :value nil
+                                                 (string :format "%v")
+                                                 (function :format "%v")))
                                   (group :inline t
                                          (const :format "" :value :function)
                                          (function :tag "Function"))
@@ -218,6 +231,11 @@ See Info node `(gnus)Mail Source Specifiers'."
                                          (const :format "" :value :plugged)
                                          (boolean :tag "Plugged")))))))
 
+(defcustom mail-source-ignore-errors nil
+  "*Ignore errors when querying mail sources.
+If nil, the user will be prompted when an error occurs.  If non-nil,
+the error will be ignored.")
+
 (defcustom mail-source-primary-source nil
   "*Primary source for incoming mail.
 If non-nil, this maildrop will be checked periodically for new mail."
@@ -463,10 +481,17 @@ Return the number of files that were found."
                 (condition-case err
                     (funcall function source callback)
                   (error
-                   (unless (yes-or-no-p
-                            (format "Mail source %s error (%s).  Continue? "
-                                    source
-                                    (cadr err)))
+                   (if (and (not mail-source-ignore-errors)
+                            (not
+                             (yes-or-no-p
+                              (format "Mail source %s error (%s).  Continue? "
+                                      (if (memq ':password source)
+                                          (let ((s (copy-sequence source)))
+                                            (setcar (cdr (memq ':password s)) 
+                                                    "********")
+                                            s)
+                                        source)
+                                      (cadr err)))))
                      (error "Cannot get new mail"))
                    0)))))))))
 
@@ -602,7 +627,7 @@ If ARGS, PROMPT is used as an argument to `format'."
 
 (defun mail-source-run-script (script spec &optional delay)
   (when script
-    (if (and (symbolp script) (fboundp script))
+    (if (functionp script)
        (funcall script)
       (mail-source-call-script
        (format-spec script spec))))