summaryrefslogtreecommitdiff
path: root/lisp/gnus/auth-source.el
diff options
context:
space:
mode:
authorTeodor Zlatanov <tzz@lifelogs.com>2012-01-10 22:04:51 +0000
committerKatsumi Yamaoka <yamaoka@jpl.org>2012-01-10 22:04:51 +0000
commitfb7e9e0539eabe1b5135fd793cbba20d87ebc1d2 (patch)
tree73c7e2bbe140212f7b0a01e50d84da6269a31dfb /lisp/gnus/auth-source.el
parent1e2c5d95f66eac88b52135f27a532fab8600a4ba (diff)
downloademacs-fb7e9e0539eabe1b5135fd793cbba20d87ebc1d2.tar.gz
emacs-fb7e9e0539eabe1b5135fd793cbba20d87ebc1d2.tar.bz2
emacs-fb7e9e0539eabe1b5135fd793cbba20d87ebc1d2.zip
nntp.el (nntp-send-authinfo): Query `auth-source-search' with the logical server name in addition to the actual machine address.
auth-source.el (auth-source-user-and-password): Add convenience wrapper to search by just host and optionally user.
Diffstat (limited to 'lisp/gnus/auth-source.el')
-rw-r--r--lisp/gnus/auth-source.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index acbc541512f..5e946372d04 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -1781,6 +1781,26 @@ MODE can be \"login\" or \"password\"."
found))
+(defun auth-source-user-and-password (host &optional user)
+ (let* ((auth-info (car
+ (if user
+ (auth-source-search
+ :host host
+ :user "yourusername"
+ :max 1
+ :require '(:user :secret)
+ :create nil)
+ (auth-source-search
+ :host host
+ :max 1
+ :require '(:user :secret)
+ :create nil))))
+ (user (plist-get auth-info :user))
+ (password (plist-get auth-info :secret)))
+ (when (functionp password)
+ (setq password (funcall password)))
+ (list user password auth-info)))
+
(provide 'auth-source)
;;; auth-source.el ends here