Merge branch 'tzz-auth-source-rewrite' of https://git.gnus.org/gnus into tzz-auth...
authorTed Zlatanov <tzz@lifelogs.com>
Sun, 6 Feb 2011 14:46:03 +0000 (08:46 -0600)
committerTed Zlatanov <tzz@lifelogs.com>
Sun, 6 Feb 2011 14:46:03 +0000 (08:46 -0600)
Conflicts:
lisp/ChangeLog
lisp/auth-source.el

1  2 
lisp/auth-source.el

@@@ -1026,17 -1070,55 +1026,16 @@@ MODE can be \"login\" or \"password\".
               found)
             host protocol username)
            found)                        ; return the found data
 -      ;; else, if not found
 -      (let ((choices (apply 'auth-source-search search)))
 -        (dolist (choice choices)
 -          (if delete-existing
 -              (apply 'auth-source-delete choice search)
 -            (setq found (apply 'auth-source-retrieve mode choice search)))
 -          (and found (return found)))
 -
 -        ;; We haven't found something, so we will create it interactively.
 -        (when (and (not found) create-missing)
 -          (setq found (apply 'auth-source-create
 -                             mode (if choices
 -                                      (car choices)
 -                                    (car auth-sources))
 -                             search)))
 -
 -        ;; Cache the result.
 -        (when found
 -          (auth-source-do-debug
 -           "auth-source-user-or-password: found %s=%s for %s (%s) + %s"
 -           mode
 -           ;; don't show the password
 -           (if (and (member "password" mode) auth-source-hide-passwords)
 -               "SECRET" found)
 -           host protocol username)
 -          (setq found (if listy found (car-safe found)))
 -          (when auth-source-do-cache
 -            (puthash cname found auth-source-cache)))
 -
 -        found))))
 -
 -(defun auth-source-protocol-defaults (protocol)
 -  "Return a list of default ports and names for PROTOCOL."
 -  (cdr-safe (assoc protocol auth-source-protocols)))
 -
 -(defun auth-source-user-or-password-imap (mode host)
 -  (auth-source-user-or-password mode host 'imap))
 -
 -(defun auth-source-user-or-password-pop3 (mode host)
 -  (auth-source-user-or-password mode host 'pop3))
 -
 -(defun auth-source-user-or-password-ssh (mode host)
 -  (auth-source-user-or-password mode host 'ssh))
 -
 -(defun auth-source-user-or-password-sftp (mode host)
 -  (auth-source-user-or-password mode host 'sftp))
 -
 -(defun auth-source-user-or-password-smtp (mode host)
 -  (auth-source-user-or-password mode host 'smtp))
 +      ;; else, if not found, search with a max of 1
 +      (let ((choice (nth 0 (apply 'auth-source-search
 +                                  (nconc '(:max 1) search)))))
 +        (when choice
 +          (when (member "password" mode)
 +            (push (funcall (plist-get :secret choice)) found))
 +          (when (member "login" mode)
 +            (push (funcall (plist-get :user choice)) found)))
 +          (setq found (if listy found (car-safe found)))))
 +        found))
  
  (provide 'auth-source)