From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: nnimap-user setting? Date: Fri, 15 Apr 2011 15:31:45 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87y63bdzny.fsf@lifelogs.com> References: <87zkns98l8.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1302899534 15264 80.91.229.12 (15 Apr 2011 20:32:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 15 Apr 2011 20:32:14 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 15 22:32:10 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QApgW-0001aM-O1 for ged-emacs-devel@m.gmane.org; Fri, 15 Apr 2011 22:32:08 +0200 Original-Received: from localhost ([::1]:42619 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QApgW-0001jQ-1M for ged-emacs-devel@m.gmane.org; Fri, 15 Apr 2011 16:32:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:54210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QApgT-0001jB-7A for emacs-devel@gnu.org; Fri, 15 Apr 2011 16:32:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QApgR-0006y9-8a for emacs-devel@gnu.org; Fri, 15 Apr 2011 16:32:05 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:37095) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QApgQ-0006y1-UM for emacs-devel@gnu.org; Fri, 15 Apr 2011 16:32:03 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QApgO-0001Tl-M6 for emacs-devel@gnu.org; Fri, 15 Apr 2011 22:32:00 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Apr 2011 22:32:00 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 15 Apr 2011 22:32:00 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 75 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:yybI4Qhum4NhaF+7xybZ/qLyEIM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138506 Archived-At: --=-=-= Content-Type: text/plain On Fri, 15 Apr 2011 16:52:45 -0300 Stefan Monnier 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=nnimap-user.patch 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 --=-=-=--