Add hooks for gcc handling
[gnus] / lisp / auth-source.el
index c7daed8..3ddbb56 100644 (file)
@@ -1,6 +1,6 @@
 ;;; auth-source.el --- authentication sources for Gnus and Emacs
 
-;; Copyright (C) 2008-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <tzz@lifelogs.com>
 ;; Keywords: news
@@ -94,6 +94,7 @@
   "How many seconds passwords are cached, or nil to disable
 expiring.  Overrides `password-cache-expiry' through a
 let-binding."
+  :version "24.1"
   :group 'auth-source
   :type '(choice (const :tag "Never" nil)
                  (const :tag "All Day" 86400)
@@ -1256,7 +1257,7 @@ See `auth-source-search' for details on SPEC."
                                            (setq ret (cdr item))
                                            (setq check nil)))))
                                     (t 'never)))
-                                  (plain (or (eval default) read-passwd prompt)))
+                                  (plain (or (eval default) (read-passwd prompt))))
                              ;; ask if we don't know what to do (in which case
                              ;; auth-source-netrc-use-gpg-tokens must be a list)
                              (unless gpg-encrypt
@@ -1681,12 +1682,12 @@ authentication tokens:
         (setq data (or data
                        (if (eq r 'secret)
                            (or (eval default) (read-passwd prompt))
-                         (if stringp default
-                           (read-string (if (string-match ": *\\'" prompt)
-                                            (concat (substring prompt 0 (match-beginning 0))
-                                                    " (default " default "): ")
-                                          (concat prompt "(default " default ") "))
-                                        nil nil default)
+                         (if (stringp default)
+                             (read-string (if (string-match ": *\\'" prompt)
+                                              (concat (substring prompt 0 (match-beginning 0))
+                                                      " (default " default "): ")
+                                            (concat prompt "(default " default ") "))
+                                          nil nil default)
                            (eval default)))))
 
         (when data
@@ -1791,6 +1792,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