From aa2ebce9fc5b7c393d57be41db70d2b3cc087fb8 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Mon, 14 Mar 2011 22:44:17 -0400
Subject: [PATCH] * lisp/gnus/auth-source.el (auth-source-netrc-create): Use
 usual format for the default in prompts.

---
 lisp/gnus/ChangeLog      | 53 ++++++++++++++++++++++------------------
 lisp/gnus/auth-source.el | 20 +++++++++------
 2 files changed, 41 insertions(+), 32 deletions(-)

diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index af0bd1519c7..515a54cd491 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-15  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* auth-source.el (auth-source-netrc-create): Use usual format for the
+	default in prompts.
+
 2011-03-13  Teodor Zlatanov  <tzz@lifelogs.com>
 
 	* auth-source.el (auth-source-netrc-create): Show the default in the
@@ -15,9 +20,9 @@
 
 2011-03-11  Teodor Zlatanov  <tzz@lifelogs.com>
 
-	* gnus-sync.el (gnus-sync-install-hooks, gnus-sync-unload-hook): Don't
-	install `gnus-sync-read' to any hooks by default.  It's buggy.  The
-	user will have to run `gnus-sync-read' manually and wait for Cloudy
+	* gnus-sync.el (gnus-sync-install-hooks, gnus-sync-unload-hook):
+	Don't install `gnus-sync-read' to any hooks by default.  It's buggy.
+	The user will have to run `gnus-sync-read' manually and wait for Cloudy
 	Gnus.
 
 2011-03-11  Julien Danjou  <julien@danjou.info>
@@ -101,8 +106,8 @@
 
 2011-03-05  Antoine Levitt  <antoine.levitt@gmail.com>
 
-	* message.el (message-cite-reply-position, message-cite-style): New
-	variables.
+	* message.el (message-cite-reply-position, message-cite-style):
+	New variables.
 	(message-yank-original): Use the new citation styles.
 
 2011-03-04  Daiki Ueno  <ueno@unixuser.org>
@@ -216,14 +221,14 @@
 
 2011-02-23  Lars Ingebrigtsen  <larsi@gnus.org>
 
-	* gnus-start.el (gnus-dribble-read-file): Set
-	buffer-save-without-query, since we always want to save the dribble
+	* gnus-start.el (gnus-dribble-read-file):
+	Set buffer-save-without-query, since we always want to save the dribble
 	file, probably.
 
 	* nnmail.el (nnmail-article-group): Allow a final "" split to work on
 	nnimap.
 
-	* gnus-sum.el (gnus-user-date-format-alist): Renamed back again from
+	* gnus-sum.el (gnus-user-date-format-alist): Rename back again from
 	-summary- since it's a user-visible variable.
 
 	* nnimap.el (nnimap-retrieve-group-data-early): Don't do QRESYNC the
@@ -469,8 +474,8 @@
 2011-02-14  Teodor Zlatanov  <tzz@lifelogs.com>
 
 	* auth-source.el (auth-source-backend-parse-parameters): Don't rely on
-	`plist-get' to accept non-list parameters (XEmacs issue).  Fix
-	docstring.
+	`plist-get' to accept non-list parameters (XEmacs issue).
+	Fix docstring.
 	(auth-source-secrets-search): Use `delete-dups', `append mapcar', and
 	`butlast' instead of `remove-duplicates', `mapcan', and `subseq'.
 	(auth-sources, auth-source-backend-parse, auth-source-secrets-search):
@@ -510,8 +515,8 @@
 
 2011-02-13  Tassilo Horn  <tassilo@member.fsf.org>  (tiny change)
 
-	* nnimap.el (nnimap-request-accept-article, nnimap-process-quirk): Fix
-	Gcc processing on imap.
+	* nnimap.el (nnimap-request-accept-article, nnimap-process-quirk):
+	Fix Gcc processing on imap.
 
 2011-02-10  Stefan Monnier  <monnier@iro.umontreal.ca>
 
@@ -599,8 +604,8 @@
 
 2011-02-06  Michael Albinus  <michael.albinus@gmx.de>
 
-	* auth-source.el (top): Require 'eieio unconditionally.  Autoload
-	`secrets-get-attributes' instead of `secrets-get-attribute'.
+	* auth-source.el (top): Require 'eieio unconditionally.
+	Autoload `secrets-get-attributes' instead of `secrets-get-attribute'.
 	(auth-source-secrets-search): Limit search when `max' is greater than
 	number of results.
 
@@ -636,7 +641,7 @@
 	(auth-source-protocol-defaults, auth-source-user-or-password-imap)
 	(auth-source-user-or-password-pop3, auth-source-user-or-password-ssh)
 	(auth-source-user-or-password-sftp)
-	(auth-source-user-or-password-smtp): Removed.
+	(auth-source-user-or-password-smtp): Remove.
 	(auth-source-user-or-password): Deprecated and modified to be a wrapper
 	around `auth-source-search'.  Not tested thoroughly.
 
@@ -802,16 +807,16 @@
 	* gnus-group.el (gnus-group-jump-to-group): Allow jumping to groups
 	that Gnus doesn't know exists again.
 
-	* gnus-art.el (gnus-article-date-lapsed-new-header): Removed.
+	* gnus-art.el (gnus-article-date-lapsed-new-header): Remove.
 	(gnus-treat-date-ut): Ditto.
-	(gnus-article-update-date-header): Renamed.
-	(gnus-treat-date-local): Removed.
-	(gnus-treat-date-english): Removed.
-	(gnus-treat-date-lapsed): Removed.
-	(gnus-treat-date-combined-lapsed): Removed.
-	(gnus-treat-date-original): Removed.
-	(gnus-treat-date-iso8601): Removed.
-	(gnus-treat-date-user-defined): Removed.
+	(gnus-article-update-date-header): Rename.
+	(gnus-treat-date-local): Remove.
+	(gnus-treat-date-english): Remove.
+	(gnus-treat-date-lapsed): Remove.
+	(gnus-treat-date-combined-lapsed): Remove.
+	(gnus-treat-date-original): Remove.
+	(gnus-treat-date-iso8601): Remove.
+	(gnus-treat-date-user-defined): Remove.
 	(gnus-article-date-headers): New variable to control all the date
 	header options.
 	(article-date-ut): Rewrite to allow using the new way to format date
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index 52f2b92e933..f703fbbd200 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -1093,17 +1093,19 @@ See `auth-source-search' for details on SPEC."
                         (?h ,(aget printable-defaults 'host))
                         (?p ,(aget printable-defaults 'port))))))
 
-        ;; store the data, prompting for the password if needed
+        ;; Store the data, prompting for the password if needed.
         (setq data
               (cond
                ((and (null data) (eq r 'secret))
-                ;; special case prompt for passwords
+                ;; Special case prompt for passwords.
                 (read-passwd prompt))
                ((null data)
                 (when default
-                  (setq
-                   prompt
-                   (concat prompt (format "(default %s) " default))))
+                  (setq prompt
+                        (if (string-match ": *\\'" prompt)
+                            (concat (substring prompt 0 (match-beginning 0))
+                                    " (default " default "): ")
+                          (concat prompt "(default " default ") "))))
                 (read-string prompt nil nil default))
                (t (or data default))))
 
@@ -1115,7 +1117,7 @@ See `auth-source-search' for details on SPEC."
                                             (lambda () data))
                                         data))))
 
-        ;; when r is not an empty string...
+        ;; When r is not an empty string...
         (when (and (stringp data)
                    (< 0 (length data)))
           ;; this function is not strictly necessary but I think it
@@ -1173,7 +1175,7 @@ Respects `auth-source-save-behavior'.  Uses
         ;; we want the new data to be found first, so insert at beginning
         (goto-char (point-min))
 
-        ;; ask AFTER we've successfully opened the file
+        ;; Ask AFTER we've successfully opened the file.
         (let ((prompt (format "Save auth info to file %s? " file))
               (done (not (eq auth-source-save-behavior 'ask)))
               (bufname "*auth-source Help*")
@@ -1190,6 +1192,8 @@ Respects `auth-source-save-behavior'.  Uses
                                "(N)o and don't ask to save again\n"
                                "(e)dit the line\n"
                                "(?) for help as you can see.\n"))
+                      ;; Why?  Doesn't with-output-to-temp-buffer already do
+                      ;; the exact same thing anyway?  --Stef
                       (set-buffer standard-output)
                       (help-mode))))
               (?n (setq add ""
@@ -1203,7 +1207,7 @@ Respects `auth-source-save-behavior'.  Uses
           (when (get-buffer-window bufname)
             (delete-window (get-buffer-window bufname)))
 
-          ;; make sure the info is not saved
+          ;; Make sure the info is not saved.
           (when (null auth-source-save-behavior)
             (setq add ""))
 
-- 
2.39.5