[gnus git] branch master updated: n0-17-469-g59a2d4c =1= * auth-source.el (auth-source-user-and-password): Add convenience wrapper to search by just host and optionally user.

Ted Zlatanov <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  59a2d4c2ef7a5878857e2aa786c9ac03bbdfc6ff (commit)
      from  4858a15ea17467fe8ea8ccc05d89439747badc64 (commit)


- Log -----------------------------------------------------------------
commit 59a2d4c2ef7a5878857e2aa786c9ac03bbdfc6ff
Author: Ted Zlatanov <[email protected]>
Date:   Tue Jan 10 09:45:05 2012 -0500

    * auth-source.el (auth-source-user-and-password): Add convenience wrapper to search by just host and optionally user.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5799dcb..3148fb2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-10  Teodor Zlatanov  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* shr.el (shr-visit-file): Move point to the beginning of the buffer
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 978682f..de2fecf 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1791,6 +1791,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

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog      |    5 +++++
 lisp/auth-source.el |   20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.