diff options
author | Teodor Zlatanov <tzz@lifelogs.com> | 2011-03-09 13:39:35 +0000 |
---|---|---|
committer | Katsumi Yamaoka <yamaoka@jpl.org> | 2011-03-09 13:39:35 +0000 |
commit | 733afdf4d9df952a2d06c40b067de3a62bceb26b (patch) | |
tree | b097d2a39b6e6a8a9ce80a5f8262a09b36518cc1 /lisp/gnus/nnimap.el | |
parent | ee545c35d2e83306d50ec78a8d9173ab9011bce5 (diff) | |
download | emacs-733afdf4d9df952a2d06c40b067de3a62bceb26b.tar.gz |
Merge changes made in Gnus trunk.
auth-source.el (auth-source-read-char-choice): New function to read a character choice using `dropdown-list', `read-char-choice', or `read-char'. It appends "[a/b/c] " to the prompt if the choices were '(?a ?b ?c). The `dropdown-list' support is disabled for now. Use `eval-when-compile' to load `dropdown-list'.
(auth-source-netrc-saver): Use it.
nnimap.el (nnimap-credentials): Keep the :save-function as the third parameter in the credentials.
(nnimap-open-connection-1): Use it after a successful login.
(nnimap-credentials): Add IMAP-specific user and password prompt.
auth-source.el (auth-source-search): Add :require parameter, taking a list. Document it and the :save-function return token. Pass :require down. Change the CREATED message from a warning to a debug statement.
(auth-source-search-backends): Pass :require down.
(auth-source-netrc-search): Pass :require down.
(auth-source-netrc-parse): Use :require, if it's given, as a filter. Change save prompt to indicate all modifications saved here are deletions.
(auth-source-netrc-create): Take user login name as default in user prompt. Move all the save functionality to a lexically bound function under the :save-function token in the returned list. Set up clearer default prompts for user, host, port, and secret.
(auth-source-netrc-saver): New function, intended to be wrapped for :save-function.
Diffstat (limited to 'lisp/gnus/nnimap.el')
-rw-r--r-- | lisp/gnus/nnimap.el | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 638097abd7d..e76ead515c5 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -279,16 +279,21 @@ textual parts.") (current-buffer))) (defun nnimap-credentials (address ports) - (let ((found (nth 0 (auth-source-search :max 1 - :host address - :port ports - :create t)))) + (let* ((auth-source-creation-prompts + '((user . "IMAP user at %h: ") + (secret . "IMAP password for %u@%h: "))) + (found (nth 0 (auth-source-search :max 1 + :host address + :port ports + :require '(:user :secret) + :create t)))) (if found (list (plist-get found :user) (let ((secret (plist-get found :secret))) (if (functionp secret) (funcall secret) - secret))) + secret)) + (plist-get found :save-function)) nil))) (defun nnimap-keepalive () @@ -396,7 +401,12 @@ textual parts.") (let ((nnimap-inhibit-logging t)) (setq login-result (nnimap-login (car credentials) (cadr credentials)))) - (unless (car login-result) + (if (car login-result) + ;; save the credentials if a save function exists + ;; (such a function will only be passed if a new + ;; token was created) + (when (functionp (nth 2 credentials)) + (funcall (nth 2 credentials))) ;; If the login failed, then forget the credentials ;; that are now possibly cached. (dolist (host (list (nnoo-current-server 'nnimap) |