From: Teodor Zlatanov Date: Tue, 10 Jan 2012 22:04:51 +0000 (+0000) Subject: nntp.el (nntp-send-authinfo): Query `auth-source-search' with the logical server... X-Git-Tag: emacs-pretest-24.0.93~97^2~38 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fb7e9e0539eabe1b5135fd793cbba20d87ebc1d2;p=emacs.git 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. --- diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 9a4d8abe3e8..c7358779818 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,11 @@ +2012-01-10 Teodor Zlatanov + + * 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. + 2012-01-07 Lars Magne Ingebrigtsen * shr.el (shr-visit-file): Move point to the beginning of the buffer 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 diff --git a/lisp/gnus/nntp.el b/lisp/gnus/nntp.el index db9d9e252be..c740f614356 100644 --- a/lisp/gnus/nntp.el +++ b/lisp/gnus/nntp.el @@ -1249,8 +1249,8 @@ If SEND-IF-FORCE, only send authinfo to the server if the (alist (netrc-machine list nntp-address "nntp")) (auth-info (nth 0 (auth-source-search :max 1 - ;; TODO: allow the virtual server name too - :host nntp-address + :host (list nntp-address + (nnoo-current-server 'nntp)) :port '("119" "nntp")))) (auth-user (plist-get auth-info :user)) (auth-force (plist-get auth-info :force))