unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: nnimap-user setting?
Date: Fri, 15 Apr 2011 15:31:45 -0500	[thread overview]
Message-ID: <87y63bdzny.fsf@lifelogs.com> (raw)
In-Reply-To: jwvzknrmgx0.fsf-monnier+emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1340 bytes --]

On Fri, 15 Apr 2011 16:52:45 -0300 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

>> Maybe it's better to use this new `nnimap-user' backend variable
>> directly.  IOW, if it's set, it should override anything from
>> auth-source, and the auth-source search should not use `nnimap-user',
>> just the host and the ports.  WDYT?

SM> Doesn't sound right: what if you have several accounts on the same
SM> IMAP server?  auto-info needs to know the username in order to find the
SM> right password.

In Gnus, you'd set up multiple secondary servers with the same machine
address and each one has its own nnimap-user.  Then `auth-source-search'
is passed the server name and the machine name, and will use the server
name first.  IOW:

Gnus: server1 = (machine.domain.com, nnimap-user "user1")
      server2 = (machine.domain.com, nnimap-user "user2")

.netrc/.authinfo{,.gpg}: 
machine server1 password password1
machine server2 password password2

But what bugged you is the auth-source prompting for the user name,
right?  See the attached patch, it will also set
`auth-source-creation-defaults' if `nnimap-user' is set, so you won't be
asked for the user name every time a virtual auth-source entry is
created.  You should only be asked for the password and whether you want
to save the entry (as per `auth-source-save-behavior').

Ted


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap-user.patch --]
[-- Type: text/x-diff, Size: 1223 bytes --]

diff --git a/lisp/nnimap.el b/lisp/nnimap.el
index afdea18..5709f92 100644
--- a/lisp/nnimap.el
+++ b/lisp/nnimap.el
@@ -55,6 +55,9 @@
 
 (nnoo-declare nnimap)
 
+(defvoo nnimap-user nil
+  "Username to use for authentication to the IMAP server.  Overrides the username obtained from auth-source-search.")
+
 (defvoo nnimap-address nil
   "The address of the IMAP server.")
 
@@ -287,6 +290,8 @@ textual parts.")
   (let* ((auth-source-creation-prompts
           '((user  . "IMAP user at %h: ")
             (secret . "IMAP password for %u@%h: ")))
+         (auth-source-creation-defaults
+          (when nnimap-user `((user . ,nnimap-user))))
          (found (nth 0 (auth-source-search :max 1
                                            :host address
                                            :port ports
@@ -412,7 +417,8 @@ textual parts.")
 		  (setq nnimap-object nil)
 		(let ((nnimap-inhibit-logging t))
 		  (setq login-result
-			(nnimap-login (car credentials) (cadr credentials))))
+			(nnimap-login (or nnimap-user (car credentials))
+                                      (cadr credentials))))
 		(if (car login-result)
 		    (progn
                     ;; Save the credentials if a save function exists

  reply	other threads:[~2011-04-15 20:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-13 17:22 nnimap-user setting? Stefan Monnier
2011-04-14 15:05 ` Ted Zlatanov
2011-04-15 19:52   ` Stefan Monnier
2011-04-15 20:31     ` Ted Zlatanov [this message]
2011-04-16 15:14       ` Stefan Monnier
2011-04-16 15:27         ` Ted Zlatanov
2011-04-18 19:12           ` Stefan Monnier
2011-04-19 13:05             ` Ted Zlatanov
2011-04-19 13:46               ` Stefan Monnier
2011-04-22  0:38                 ` Ted Zlatanov
2011-04-22 13:14                   ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y63bdzny.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).