From: Richard Riley <rileyrg@googlemail.com>
To: ding@gnus.org
Subject: Re: auth-source-search
Date: Fri, 04 Mar 2011 11:10:49 +0100 [thread overview]
Message-ID: <6eoc5r6vrq.fsf@news.eternal-september.org> (raw)
In-Reply-To: <87zkpbzwar.fsf@lifelogs.com> (Ted Zlatanov's message of "Thu, 03 Mar 2011 16:14:20 -0600")
Ted Zlatanov <tzz@lifelogs.com> writes:
> On Thu, 03 Mar 2011 21:00:57 +0100 Richard Riley <rileyrg@googlemail.com> 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.
next prev parent reply other threads:[~2011-03-04 10:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-03 16:11 auth-source-search Richard Riley
2011-03-03 20:00 ` auth-source-search Richard Riley
2011-03-03 22:14 ` auth-source-search Ted Zlatanov
2011-03-04 10:10 ` Richard Riley [this message]
2011-03-04 14:55 ` auth-source-search Ted Zlatanov
2011-03-05 10:21 ` auth-source-search Lars Magne Ingebrigtsen
2011-03-07 17:44 ` auth-source-search Ted Zlatanov
2011-03-09 15:39 ` auth-source-search Ted Zlatanov
[not found] ` <14vczs2spa.fsf@news.eternal-september.org>
2011-03-09 17:38 ` auth-source-search Ted Zlatanov
2011-03-15 16:41 ` auth-source-search Lars Magne Ingebrigtsen
2011-03-09 15:35 ` auth-source-search 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6eoc5r6vrq.fsf@news.eternal-september.org \
--to=rileyrg@googlemail.com \
--cc=ding@gnus.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.
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 NNTP newsgroup(s).