From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/77490 Path: news.gmane.org!not-for-mail From: Richard Riley Newsgroups: gmane.emacs.gnus.general Subject: Re: auth-source-search Date: Fri, 04 Mar 2011 11:10:49 +0100 Organization: aich tea tea pea dicky riley dot net Message-ID: <6eoc5r6vrq.fsf@news.eternal-september.org> References: <87zkpbzwar.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1299233457 30606 80.91.229.12 (4 Mar 2011 10:10:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 4 Mar 2011 10:10:57 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M25813@lists.math.uh.edu Fri Mar 04 11:10:52 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PvRyG-0006Jv-Bp for ding-account@gmane.org; Fri, 04 Mar 2011 11:10:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1PvRy5-0000fU-DY; Fri, 04 Mar 2011 04:10:41 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1PvRy3-0000f7-Ay for ding@lists.math.uh.edu; Fri, 04 Mar 2011 04:10:39 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1PvRy2-0005CU-8G for ding@lists.math.uh.edu; Fri, 04 Mar 2011 04:10:39 -0600 Original-Received: from [85.183.18.158] (helo=asus1015pem) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1PvRy1-00078j-43 for ding@gnus.org; Fri, 04 Mar 2011 11:10:37 +0100 Original-Received: from shamrock by asus1015pem with local (Exim 4.72) (envelope-from ) id 1PvRyM-000193-Kc for ding@gnus.org; Fri, 04 Mar 2011 11:10:58 +0100 In-Reply-To: <87zkpbzwar.fsf@lifelogs.com> (Ted Zlatanov's message of "Thu, 03 Mar 2011 16:14:20 -0600") User-Agent: Gnus/5.110014 (No Gnus v0.14) Emacs/24.0.50 (gnu/linux) X-Spam-Score: -0.2 (/) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:77490 Archived-At: Ted Zlatanov writes: > On Thu, 03 Mar 2011 21:00:57 +0100 Richard Riley wrote: > > RR> (add-hook 'org-mobile-pre-push-hook > RR> '(lambda() > RR> (setq org-mobile-encryption-password (funcall (plist-get (car (auth-source-search :host '("orgmobile"))) ':secret))))) > > I would do it like this: > > (let* ((auth (auth-source-search :host "z.lifelogs.com")) > (secret (plist-get (nth 0 auth) :secret)) > (secret (if (functionp secret) (funcall secret) secret))) > secret) > > The differences with your code: > > 1) it works if the secret is not returned, or if the secret is not a function > > 2) it picks the first result safely and works if there's no results > > 3) quoting :secret is not necessary > > 4) you can use a string for searching, it doesn't have to be a list > > I will fix up auth.texi, I promise. I was waiting for the API to quiet > down, which I think it has. I'll add examples of usage including this. Thanks. A more robust solution indeed. Since this is probably such a required thing for anything needing passwords (erc, identica, gnus, git etc etc), would not a "auth-password" function make sense? I struggled for ages to get this to work ;) Its not my code per se above but the results of collaboration on #emacs where more than one person other than me was baffled by the complexity of docstring. Your code above is even more complex from my point of view - and I see why since you detect the secret type. But the code above would almost certainly benefit by being part of the API. cheers r.