[gnus git] branch master updated: =2= Mention the default now is to have two files in `auth-sources'. ; Complete among multiple auth-source-search choices when creating. Don't show the password when prompting for creation.

Ted Zlatanov <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  47e91edc48785d0db45fd552e17a0a7a19a4e962 (commit)
       via  1f65d1e9c2537e3859ee9cd775129852a4f72ff5 (commit)
      from  0fc67199d3aa4635aaa5fd230f9b14f2385a0559 (commit)


- Log -----------------------------------------------------------------
commit 47e91edc48785d0db45fd552e17a0a7a19a4e962
Author: Ted Zlatanov <[email protected]>
Date:   Thu Feb 17 08:42:25 2011 -0600

    Mention the default now is to have two files in `auth-sources'.
    
    * auth.texi (GnuPG and EasyPG Assistant Configuration): Mention the
    default now is to have two files in `auth-sources'.

diff --git a/texi/ChangeLog b/texi/ChangeLog
index 20025a0..c0a58b3 100644
--- a/texi/ChangeLog
+++ b/texi/ChangeLog
@@ -2,6 +2,8 @@
 
 	* auth.texi (Help for users): Use :port instead of :protocol for all
 	auth-source docs.
+	(GnuPG and EasyPG Assistant Configuration): Mention the default now is
+	to have two files in `auth-sources'.
 
 2011-02-14  Teodor Zlatanov  <[email protected]>
 
diff --git a/texi/auth.texi b/texi/auth.texi
index 619320a..76c1984 100644
--- a/texi/auth.texi
+++ b/texi/auth.texi
@@ -262,7 +262,9 @@ TODO: how to include docstring?
 @appendix GnuPG and EasyPG Assistant Configuration
 
 If you don't customize @code{auth-sources}, the auth-source library
-reads @code{~/.authinfo.gpg}, which is a GnuPG encrypted file.
+reads @code{~/.authinfo.gpg}, which is a GnuPG encrypted file.  Then
+it will check @code{~/.authinfo} but it's not recommended to use such
+an unencrypted file.
 
 In Emacs 23 or later there is an option @code{auto-encryption-mode} to
 automatically decrypt @code{*.gpg} files.  It is enabled by default.

commit 1f65d1e9c2537e3859ee9cd775129852a4f72ff5
Author: Ted Zlatanov <[email protected]>
Date:   Thu Feb 17 08:40:43 2011 -0600

    Complete among multiple auth-source-search choices when creating.  Don't show the password when prompting for creation.
    
    * auth-source.el (auth-source-search): Updated docs to talk about
    multiple creation choices.
    (auth-source-netrc-create): Accept a list as a value (from the search
    parameters) and do completion on that list.  Keep a separate netrc line
    with the password obscured for showing the user.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9e05e74..16247e0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,21 @@
 2011-02-17  Teodor Zlatanov  <[email protected]>
 
+	* nnimap.el (nnimap-credentials): Instead of picking the first port as
+	a creation default, pass the whole port list down.  It will be completed.
+
+	* auth-source.el (auth-source-search): Updated docs to talk about
+	multiple creation choices.
+	(auth-source-netrc-create): Accept a list as a value (from the search
+	parameters) and do completion on that list.  Keep a separate netrc line
+	with the password obscured for showing the user.
+
+	* nnimap.el (nnimap-open-connection-1): Make the `nnimap-address' the
+	first choice to `auth-source-search' so it will be used for entry
+	creation instead of the server's Gnus-specific name.
+	(nnimap-credentials): Rely on the auth-source library to select which
+	port is actually wanted in the new netrc entry, so don't override
+	`auth-source-creation-defaults'.
+
 	* auth-source.el (auth-source-netrc-parse): Use :port instead of
 	:protocol and accept a missing user, host, or port as a wildcard match.
 	(auth-source-debug): Default to off.
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index a5be129..8c34591 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -463,8 +463,8 @@ which says:
  search to find only entries that have P set to 'pppp'.\"
 
 When multiple values are specified in the search parameter, the
-first one is used for creation.  So :host (X Y Z) would create a
-token for host X, for instance.
+user is prompted for which one.  So :host (X Y Z) would ask the
+user to choose between X, Y, and Z.
 
 This creation can fail if the search was not specific enough to
 create a new token (it's up to the backend to decide that).  You
@@ -861,6 +861,7 @@ See `auth-source-search' for details on SPEC."
          (required (append base-required create-extra))
          (file (oref backend source))
          (add "")
+         (show "")
          ;; `valist' is an alist
          valist
          ;; `artificial' will be returned if no creation is needed
@@ -868,12 +869,16 @@ See `auth-source-search' for details on SPEC."
 
     ;; only for base required elements (defined as function parameters):
     ;; fill in the valist with whatever data we may have from the search
-    ;; we take the first value if it's a list, the whole value otherwise
+    ;; we complete the first value if it's a list and use the value otherwise
     (dolist (br base-required)
       (when (symbol-value br)
-        (aput 'valist br (if (listp (symbol-value br))
-                             (nth 0 (symbol-value br))
-                           (symbol-value br)))))
+        (let ((br-choice (cond
+                          ;; all-accepting choice (predicate is t)
+                          ((eq t (symbol-value br)) nil)
+                          ;; just the value otherwise
+                          (t (symbol-value br)))))
+          (when br-choice
+            (aput 'valist br br-choice)))))
 
     ;; for extra required elements, see if the spec includes a value for them
     (dolist (er create-extra)
@@ -904,6 +909,8 @@ See `auth-source-search' for details on SPEC."
              (user-value (aget valist 'user))
              (host-value (aget valist 'host))
              (port-value (aget valist 'port))
+             ;; note this handles lists by just printing them
+             ;; later we allow the user to use completing-read to pick
              (info-so-far (concat (if user-value
                                       (format "%s@" user-value)
                                     "[USER?]")
@@ -931,6 +938,16 @@ See `auth-source-search' for details on SPEC."
                        (format "Enter %s for %s%s: "
                                r info-so-far default-string)
                        nil nil default))
+                     ((listp data)
+                      (completing-read
+                       (format "Enter %s for %s (TAB to see the choices): "
+                               r info-so-far)
+                       data
+                       nil              ; no predicate
+                       t                ; require a match
+                       ;; note the default is nil, but if the user
+                       ;; hits RET we'll get "", which is handled OK later
+                       nil))
                      (t data))))
 
         (when data
@@ -944,8 +961,9 @@ See `auth-source-search' for details on SPEC."
         ;; when r is not an empty string...
         (when (and (stringp data)
                    (< 0 (length data)))
-          ;; append the key (the symbol name of r) and the value in r
-          (setq add (concat add
+          (let ((printer (lambda (hide)
+                           ;; append the key (the symbol name of r)
+                           ;; and the value in r
                             (format "%s%s %S"
                                     ;; prepend a space
                                     (if (zerop (length add)) "" " ")
@@ -957,7 +975,11 @@ See `auth-source-search' for details on SPEC."
                                      ('port "port") ; redundant but clearer
                                      (t (symbol-name r)))
                                     ;; the value will be printed in %S format
-                                    data))))))
+                                   (if (and hide (eq r 'secret))
+                                       "HIDDEN_SECRET"
+                                     data)))))
+            (setq add (concat add (funcall printer nil)))
+            (setq show (concat show (funcall printer t)))))))
 
     (with-temp-buffer
       (when (file-exists-p file)
@@ -974,7 +996,7 @@ See `auth-source-search' for details on SPEC."
       (goto-char (point-max))
 
       ;; ask AFTER we've successfully opened the file
-      (if (y-or-n-p (format "Add to file %s: line [%s]" file add))
+      (if (y-or-n-p (format "Add to file %s: line [%s]" file show))
           (progn
             (unless (bolp)
               (insert "\n"))
diff --git a/lisp/nnimap.el b/lisp/nnimap.el
index fc8873f..2412546 100644
--- a/lisp/nnimap.el
+++ b/lisp/nnimap.el
@@ -277,8 +277,7 @@ textual parts.")
     (current-buffer)))
 
 (defun nnimap-credentials (address ports)
-  (let* ((auth-source-creation-defaults `((port . ,(nth 0 ports))))
-         (found (nth 0 (auth-source-search :max 1
+  (let* ((found (nth 0 (auth-source-search :max 1
                                            :host address
                                            :port ports
                                            :create t)))
@@ -386,8 +385,8 @@ textual parts.")
                                ;; the virtual server name and the address
                                (nnimap-credentials
                                 (list
-                                 (nnoo-current-server 'nnimap)
-                                 nnimap-address)
+                                 nnimap-address
+                                 (nnoo-current-server 'nnimap))
                                 ports))))
 		  (setq nnimap-object nil)
 		(let ((nnimap-inhibit-logging t))

-----------------------------------------------------------------------
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      |   16 +++++++++++++++
 lisp/auth-source.el |   54 +++++++++++++++++++++++++++++++++++---------------
 lisp/nnimap.el      |    7 ++---
 texi/ChangeLog      |    2 +
 texi/auth.texi      |    4 ++-
 5 files changed, 62 insertions(+), 21 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.