aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/gnus/mail-source.el
diff options
context:
space:
mode:
authorMiles Bader2008-04-26 04:29:42 +0000
committerMiles Bader2008-04-26 04:29:42 +0000
commit58a67d68bfc2eafe0cd029aa33693228f21f4e51 (patch)
tree009923ba472fb824796a3cd59f91925c17ee8c5b /lisp/gnus/mail-source.el
parent1ea193a2b6414ac6186de0840e5b734c7d82a810 (diff)
downloademacs-58a67d68bfc2eafe0cd029aa33693228f21f4e51.tar.gz
emacs-58a67d68bfc2eafe0cd029aa33693228f21f4e51.zip
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1128
Diffstat (limited to 'lisp/gnus/mail-source.el')
-rw-r--r--lisp/gnus/mail-source.el28
1 files changed, 24 insertions, 4 deletions
diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el
index a26f885894d..d8633b7a6a4 100644
--- a/lisp/gnus/mail-source.el
+++ b/lisp/gnus/mail-source.el
@@ -36,6 +36,7 @@
36 (require 'cl) 36 (require 'cl)
37 (require 'imap)) 37 (require 'imap))
38(eval-and-compile 38(eval-and-compile
39 (autoload 'auth-source-user-or-password "auth-source")
39 (autoload 'pop3-movemail "pop3") 40 (autoload 'pop3-movemail "pop3")
40 (autoload 'pop3-get-message-count "pop3") 41 (autoload 'pop3-get-message-count "pop3")
41 (autoload 'nnheader-cancel-timer "nnheader")) 42 (autoload 'nnheader-cancel-timer "nnheader"))
@@ -44,7 +45,6 @@
44 45
45(defvar display-time-mail-function) 46(defvar display-time-mail-function)
46 47
47
48(defgroup mail-source nil 48(defgroup mail-source nil
49 "The mail-fetching library." 49 "The mail-fetching library."
50 :version "21.1" 50 :version "21.1"
@@ -420,6 +420,8 @@ All keywords that can be used must be listed here."))
420 "Strip the leading colon off the KEYWORD." 420 "Strip the leading colon off the KEYWORD."
421 (intern (substring (symbol-name keyword) 1)))) 421 (intern (substring (symbol-name keyword) 1))))
422 422
423;; generate a list of variable names paired with nil values
424;; suitable for usage in a `let' form
423(eval-and-compile 425(eval-and-compile
424 (defun mail-source-bind-1 (type) 426 (defun mail-source-bind-1 (type)
425 (let* ((defaults (cdr (assq type mail-source-keyword-map))) 427 (let* ((defaults (cdr (assq type mail-source-keyword-map)))
@@ -438,14 +440,30 @@ At run time, the mail source specifier SOURCE will be inspected,
438and the variables will be set according to it. Variables not 440and the variables will be set according to it. Variables not
439specified will be given default values. 441specified will be given default values.
440 442
443The user and password will be loaded from the auth-source values
444if those are available. They override the original user and
445password in a second `let' form.
446
441After this is done, BODY will be executed in the scope 447After this is done, BODY will be executed in the scope
442of the `let' form. 448of the second `let' form.
443 449
444The variables bound and their default values are described by 450The variables bound and their default values are described by
445the `mail-source-keyword-map' variable." 451the `mail-source-keyword-map' variable."
446 `(let ,(mail-source-bind-1 (car type-source)) 452 `(let* ,(mail-source-bind-1 (car type-source))
447 (mail-source-set-1 ,(cadr type-source)) 453 (mail-source-set-1 ,(cadr type-source))
448 ,@body)) 454 (let ((user (or
455 (auth-source-user-or-password
456 "login"
457 server ; this is "host" in auth-sources
458 ',(car type-source))
459 user))
460 (password (or
461 (auth-source-user-or-password
462 "password"
463 server ; this is "host" in auth-sources
464 ',(car type-source))
465 password)))
466 ,@body)))
449 467
450(put 'mail-source-bind 'lisp-indent-function 1) 468(put 'mail-source-bind 'lisp-indent-function 1)
451(put 'mail-source-bind 'edebug-form-spec '(sexp body)) 469(put 'mail-source-bind 'edebug-form-spec '(sexp body))
@@ -455,6 +473,8 @@ the `mail-source-keyword-map' variable."
455 (defaults (cdr (assq type mail-source-keyword-map))) 473 (defaults (cdr (assq type mail-source-keyword-map)))
456 default value keyword) 474 default value keyword)
457 (while (setq default (pop defaults)) 475 (while (setq default (pop defaults))
476 ;; for each default :SYMBOL, set SYMBOL to the plist value for :SYMBOL
477 ;; using `mail-source-value' to evaluate the plist value
458 (set (mail-source-strip-keyword (setq keyword (car default))) 478 (set (mail-source-strip-keyword (setq keyword (car default)))
459 (if (setq value (plist-get source keyword)) 479 (if (setq value (plist-get source keyword))
460 (mail-source-value value) 480 (mail-source-value value)