Subject: Re: bug#8050: Gnus does not connect to my IMAP server any more

From: Stefan Monnier <[email-masked]>
Date: Tue, 08 Mar 2011 16:34:53 -0500

>                          (case r
>                            ('secret "%p password for user %u, host %h: ")
>                            ('user "%p user name: ")
>                            ('host "%p host name for user %u: ")
>                            ('port "%p port for user %u and host %h: "))
>                          (format "Enter %s (%%u@%%h:%%p): " r)))

> Can you please propose specific replacements?

         (case r
           (secret "%p password for %u@%h: ")
           (user "%p user name for %h: ")
           (host "%p host name for user %u: ")
           (port "%p port for %u@%h: "))
         (format "Enter %s (%%u@%%h:%%p): " r)))

Notes:
- I added the host name to the user prompt (usually the user name
  may be different in different hosts for the same user, so most such
  prompts do include a hostname/realm).
- I left the user name in the host prompt, even though that sounds
  backward to me (kind of like choosing the street number before the
  street name).
- I removed the quotes which just made each of the branches be
  acceptable when `r' has value `quote'.
         
> I'll put something in.  This makes sense but is extra work for the
> auth-source API users, unfortunately.

I know, but the difference in user experience is enormous.

>>> I'm not sure about that one, I'm just using `read-passwd'.

SM> No, you misread: I'm talking about the prompt to save the password
SM> (i.e. the one with y/n/N/e/?), not the prompt to read the password.

> It uses:
>         (while (not done)
>           (message "%s" prompt)
>           (setq k (read-char))
>           ...)

And that leads to an absence of cursor in the minibuffer, even though
it's fundamentally a prompt.  Why not copy y-or-n-p from subr.el as
a starting point?
If you can factor out the commonality, I'd be happy to provide
a "prompt-maker" function and then define y-or-n-p in terms of that
prompt-maker.

SM> Two things:
SM> 1- then make it look nice, like "Saved password for foo@bar into <file>".
SM> The current text really looks like debug output.
> All the output from auth-source starts with the function name.

I call that debug output and is not OK for normal messages.

> The line you mention can be put in the background in favor of the
> output you specified.  But, again, auth-source does NOT just save
> passwords, and there's no guarantee that a host or a port were
> specified.  So the message will look different.

The case where a user and host were specified is likely to be the main
one for most users, so it's worth handling it specially.

SM> 2- I just replied "n" before, so I did *not* want it saved (tho I do
SM> want it saved for the session), so it is not a rare event at all.
> OK, I'll show it only when the data is saved.

Good, thank you.

        Stefan