[gnus git] branch master updated: n0-17-307-g7346e27 =1= auth-source: allow to specify a dynamically computed default password

Julien Danjou <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  7346e270c13b94d28c6d63512d3f6fe2f3a5d169 (commit)
      from  6b6601f546f95399fee49605bd4cd186c0d99e31 (commit)


- Log -----------------------------------------------------------------
commit 7346e270c13b94d28c6d63512d3f6fe2f3a5d169
Author: Julien Danjou <[email protected]>
Date:   Tue Sep 20 16:34:48 2011 +0200

    auth-source: allow to specify a dynamically computed default password
    
    Signed-off-by: Julien Danjou <[email protected]>

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3fd5ca5..b332a31 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
 2011-09-20  Julien Danjou  <[email protected]>
 
+	* auth-source.el (auth-source-netrc-create): Use default value for
+	password if specified. Evaluate default.
+	(auth-source-plstore-create): Ditto.
+
 	* password-cache.el (password-cache-remove): Remove entries even if the
 	value is nil, so that password with a nil value (negative caching) is
 	possible to invalidate.
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 2d6f472..0b47bcf 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1188,6 +1188,8 @@ See `auth-source-search' for details on SPEC."
 
     ;; for each required element
     (dolist (r required)
+      (if (eq r 'secret)
+          (debug))
       (let* ((data (aget valist r))
              ;; take the first element if the data is a list
              (data (or (auth-source-netrc-element-or-first data)
@@ -1201,7 +1203,7 @@ See `auth-source-search' for details on SPEC."
              (default (cond
                        ((and (not given-default) (eq r 'user))
                         (user-login-name))
-                       (t given-default)))
+                       (t (eval given-default))))
              (printable-defaults (list
                                   (cons 'user
                                         (or
@@ -1238,6 +1240,8 @@ See `auth-source-search' for details on SPEC."
         (setq data
               (cond
                ((and (null data) (eq r 'secret))
+                (if default
+                    default
                 ;; Special case prompt for passwords.
                 ;; TODO: make the default (setq auth-source-netrc-use-gpg-tokens `((,(if (boundp 'epa-file-auto-mode-alist-entry) (car (symbol-value 'epa-file-auto-mode-alist-entry)) "\\.gpg\\'") nil) (t gpg)))
                 ;; TODO: or maybe leave as (setq auth-source-netrc-use-gpg-tokens 'never)
@@ -1268,15 +1272,14 @@ See `auth-source-search' for details on SPEC."
                                 auth-source-netrc-use-gpg-tokens)))
                   (if (eq gpg-encrypt 'gpg)
                       (auth-source-epa-make-gpg-token plain file)
-                    plain)))
+                      plain))))
                ((null data)
                 (when default
-                  (setq prompt
-                        (if (string-match ": *\\'" prompt)
+                  (read-string (if (string-match ": *\\'" prompt)
                             (concat (substring prompt 0 (match-beginning 0))
                                     " (default " default "): ")
-                          (concat prompt "(default " default ") "))))
-                (read-string prompt nil nil default))
+                                 (concat prompt "(default " default ") "))
+                               nil nil default)))
                (t (or data default))))
 
         (when data
@@ -1647,7 +1650,7 @@ authentication tokens:
              (default (cond
                        ((and (not given-default) (eq r 'user))
                         (user-login-name))
-                       (t given-default)))
+                       (t (eval given-default))))
              (printable-defaults (list
                                   (cons 'user
                                         (or
@@ -1685,15 +1688,16 @@ authentication tokens:
               (cond
                ((and (null data) (eq r 'secret))
                 ;; Special case prompt for passwords.
-                (read-passwd prompt))
+                (if default
+                    default
+                  (read-passwd prompt)))
                ((null data)
                 (when default
-                  (setq prompt
-                        (if (string-match ": *\\'" prompt)
+                  (read-string (if (string-match ": *\\'" prompt)
                             (concat (substring prompt 0 (match-beginning 0))
                                     " (default " default "): ")
-                          (concat prompt "(default " default ") "))))
-                (read-string prompt nil nil default))
+                                 (concat prompt "(default " default ") "))
+                               nil nil default)))
                (t (or data default))))
 
         (when data

-----------------------------------------------------------------------
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      |    4 ++
 lisp/auth-source.el |   82 ++++++++++++++++++++++++++------------------------
 2 files changed, 47 insertions(+), 39 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.