;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
(eval-when-compile
(require 'cl)
(require 'imap))
-(eval-and-compile
- (autoload 'auth-source-user-or-password "auth-source")
- (autoload 'pop3-movemail "pop3")
- (autoload 'pop3-get-message-count "pop3")
- (autoload 'nnheader-cancel-timer "nnheader"))
+(autoload 'auth-source-user-or-password "auth-source")
+(autoload 'pop3-movemail "pop3")
+(autoload 'pop3-get-message-count "pop3")
+(autoload 'nnheader-cancel-timer "nnheader")
(require 'mm-util)
(require 'message) ;; for `message-directory'
the `mail-source-keyword-map' variable."
`(let* ,(mail-source-bind-1 (car type-source))
(mail-source-set-1 ,(cadr type-source))
- (let ((user
- (or
- (auth-source-user-or-password
- "login"
- server ; this is "host" in auth-sources
- ',(car type-source))
- (when (boundp 'user) (symbol-value 'user))))
- (password
- (or
- (auth-source-user-or-password
- "password"
- server ; this is "host" in auth-sources
- ',(car type-source))
- (when (boundp 'user) (symbol-value 'user)))))
- (unless user
- (unintern 'user))
- (unless password
- (unintern 'password))
- ,@body)))
+ ,@body))
(put 'mail-source-bind 'lisp-indent-function 1)
(put 'mail-source-bind 'edebug-form-spec '(sexp body))
(defun mail-source-set-1 (source)
(let* ((type (pop source))
(defaults (cdr (assq type mail-source-keyword-map)))
- default value keyword)
+ default value keyword user-auth pass-auth)
(while (setq default (pop defaults))
;; for each default :SYMBOL, set SYMBOL to the plist value for :SYMBOL
;; using `mail-source-value' to evaluate the plist value
(set (mail-source-strip-keyword (setq keyword (car default)))
- (if (setq value (plist-get source keyword))
- (mail-source-value value)
- (mail-source-value (cadr default)))))))
+ ;; note the following reasons for this structure:
+ ;; 1) the auth-sources user and password override everything
+ ;; 2) it avoids macros, so it's cleaner
+ ;; 3) it falls through to the mail-sources and then default values
+ (cond
+ ((and
+ (eq keyword :user)
+ (setq user-auth
+ (auth-source-user-or-password
+ "login"
+ ;; this is "host" in auth-sources
+ (if (boundp 'server) (symbol-value 'server) "")
+ type)))
+ user-auth)
+ ((and
+ (eq keyword :password)
+ (setq pass-auth
+ (auth-source-user-or-password
+ "password"
+ ;; this is "host" in auth-sources
+ (if (boundp 'server) (symbol-value 'server) "")
+ type)))
+ pass-auth)
+ (t (if (setq value (plist-get source keyword))
+ (mail-source-value value)
+ (mail-source-value (cadr default)))))))))
(eval-and-compile
(defun mail-source-bind-common-1 ()
(mail-source-delete-crash-box)))))
found)))
-(eval-and-compile
- (autoload 'imap-open "imap")
- (autoload 'imap-authenticate "imap")
- (autoload 'imap-mailbox-select "imap")
- (autoload 'imap-mailbox-unselect "imap")
- (autoload 'imap-mailbox-close "imap")
- (autoload 'imap-search "imap")
- (autoload 'imap-fetch "imap")
- (autoload 'imap-close "imap")
- (autoload 'imap-error-text "imap")
- (autoload 'imap-message-flags-add "imap")
- (autoload 'imap-list-to-message-set "imap")
- (autoload 'imap-range-to-message-set "imap")
- (autoload 'nnheader-ms-strip-cr "nnheader"))
+(autoload 'imap-open "imap")
+(autoload 'imap-authenticate "imap")
+(autoload 'imap-mailbox-select "imap")
+(autoload 'imap-mailbox-unselect "imap")
+(autoload 'imap-mailbox-close "imap")
+(autoload 'imap-search "imap")
+(autoload 'imap-fetch "imap")
+(autoload 'imap-close "imap")
+(autoload 'imap-error-text "imap")
+(autoload 'imap-message-flags-add "imap")
+(autoload 'imap-list-to-message-set "imap")
+(autoload 'imap-range-to-message-set "imap")
+(autoload 'nnheader-ms-strip-cr "nnheader")
(autoload 'gnus-compress-sequence "gnus-range")
?s server ?P port ?u user))
found)))
-(eval-and-compile
- (autoload 'webmail-fetch "webmail"))
+(autoload 'webmail-fetch "webmail")
(defun mail-source-fetch-webmail (source callback)
"Fetch for webmail source."