[gnus git] branch master updated: n0-13-95-g5bb9d0c =1= Add `auth-source-pick-first-password'.
Ted Zlatanov <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 5bb9d0c1a792e150752e9e90d74aa87fa46f97a1 (commit)
from fb8adb421f68ac0de215fe99d3d306014d1c507c (commit)
- Log -----------------------------------------------------------------
commit 5bb9d0c1a792e150752e9e90d74aa87fa46f97a1
Author: Ted Zlatanov <[email protected]>
Date: Wed Mar 9 11:36:28 2011 -0600
Add `auth-source-pick-first-password'.
* auth-source.el (auth-source-pick-first-password): New convenience
function.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3cf50e5..96d521b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -6,6 +6,7 @@
'(?a ?b ?c). The `dropdown-list' support is disabled for now. Use
`eval-when-compile' to load `dropdown-list'.
(auth-source-netrc-saver): Use it.
+ (auth-source-pick-first-password): New convenience function.
2011-03-08 Teodor Zlatanov <[email protected]>
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 1088719..e2a3ce5 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -769,7 +769,26 @@ while \(:host t) would find all host entries."
(return 'no)))
'no))))
-;;; Backend specific parsing: netrc/authinfo backend
+;;; (auth-source-pick-first-password :host "z.lifelogs.com")
+;;; (auth-source-pick-first-password :port "imap")
+(defun auth-source-pick-first-password (&rest spec)
+ "Pick the first secret found from applying SPEC to `auth-source-search'."
+ (let* ((result (nth 0 (apply 'auth-source-search (plist-put spec :max 1))))
+ (secret (plist-get result :secret)))
+
+ (if (functionp secret)
+ (funcall secret)
+ secret)))
+
+;; (auth-source-format-prompt "test %u %h %p" '((?u "user") (?h "host")))
+(defun auth-source-format-prompt (prompt alist)
+ "Format PROMPT using %x (for any character x) specifiers in ALIST."
+ (dolist (cell alist)
+ (let ((c (nth 0 cell))
+ (v (nth 1 cell)))
+ (when (and c v)
+ (setq prompt (replace-regexp-in-string (format "%%%c" c) v prompt)))))
+ prompt)
(defun auth-source-ensure-strings (values)
(unless (listp values)
@@ -780,6 +799,8 @@ while \(:host t) would find all host entries."
value))
values))
+;;; Backend specific parsing: netrc/authinfo backend
+
(defvar auth-source-netrc-cache nil)
;;; (auth-source-netrc-parse "~/.authinfo.gpg")
@@ -998,17 +1019,6 @@ See `auth-source-search' for details on SPEC."
(nth 0 v)
v))
-;; (auth-source-format-prompt "test %u %h %p" '((?u "user") (?h "host")))
-
-(defun auth-source-format-prompt (prompt alist)
- "Format PROMPT using %x (for any character x) specifiers in ALIST."
- (dolist (cell alist)
- (let ((c (nth 0 cell))
- (v (nth 1 cell)))
- (when (and c v)
- (setq prompt (replace-regexp-in-string (format "%%%c" c) v prompt)))))
- prompt)
-
;;; (auth-source-search :host "nonesuch" :type 'netrc :max 1 :create t)
;;; (auth-source-search :host "nonesuch" :type 'netrc :max 1 :create t :create-extra-keys '((A "default A") (B)))
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 1 +
lisp/auth-source.el | 34 ++++++++++++++++++++++------------
2 files changed, 23 insertions(+), 12 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project