[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nnimap-user setting?
From: |
Ted Zlatanov |
Subject: |
Re: nnimap-user setting? |
Date: |
Fri, 15 Apr 2011 15:31:45 -0500 |
User-agent: |
Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux) |
On Fri, 15 Apr 2011 16:52:45 -0300 Stefan Monnier <address@hidden> 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
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 address@hidden: ")))
+ (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
- nnimap-user setting?, Stefan Monnier, 2011/04/13
- Re: nnimap-user setting?, Ted Zlatanov, 2011/04/14
- Re: nnimap-user setting?, Stefan Monnier, 2011/04/15
- Re: nnimap-user setting?,
Ted Zlatanov <=
- Re: nnimap-user setting?, Stefan Monnier, 2011/04/16
- Re: nnimap-user setting?, Ted Zlatanov, 2011/04/16
- Re: nnimap-user setting?, Stefan Monnier, 2011/04/18
- Re: nnimap-user setting?, Ted Zlatanov, 2011/04/19
- Re: nnimap-user setting?, Stefan Monnier, 2011/04/19
- Re: nnimap-user setting?, Ted Zlatanov, 2011/04/21
- Re: nnimap-user setting?, Ted Zlatanov, 2011/04/22