- (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
+ (nth 0 (auth-source-user-or-password
+ '("login" "password")
+ ;; this is "host" in auth-sources
+ (if (boundp 'server) (symbol-value 'server) "")
+ type))))
+ user-auth)
+ ((and
+ (eq keyword :password)
+ (setq pass-auth
+ (nth 1
+ (auth-source-user-or-password
+ '("login" "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)))))))))