[gnus git] branch master updated: n0-13-99-g57a4bf1 =1= Fix default prompt and repeated saver query bugs.
Ted Zlatanov <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 57a4bf164075fe2c36b4a311a3199229ac29a460 (commit)
from f48235eacef5c56ad94704a17e438f9f6039ab71 (commit)
- Log -----------------------------------------------------------------
commit 57a4bf164075fe2c36b4a311a3199229ac29a460
Author: Ted Zlatanov <[email protected]>
Date: Sat Mar 12 12:07:47 2011 -0600
Fix default prompt and repeated saver query bugs.
* auth-source.el (auth-source-format-prompt): Always convert the value
to a string to avoid evaluating non-string arguments.
(auth-source-netrc-create): Offer default properly, not as initial
content in `read-string'.
(auth-source-netrc-saver): Use a cache keyed by file name and MD5 hash
of line to determine if we've been run before. If so, don't run again,
but print a trivial message to indicate the cache was hit instead.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a89bd49..74fbc6b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
+2011-03-12 Teodor Zlatanov <[email protected]>
+
+ * auth-source.el (auth-source-format-prompt): Always convert the value
+ to a string to avoid evaluating non-string arguments.
+ (auth-source-netrc-create): Offer default properly, not as initial
+ content in `read-string'.
+ (auth-source-netrc-saver): Use a cache keyed by file name and MD5 hash
+ of line to determine if we've been run before. If so, don't run again,
+ but print a trivial message to indicate the cache was hit instead.
+
2011-03-11 Teodor Zlatanov <[email protected]>
* gnus-sync.el (gnus-sync-install-hooks, gnus-sync-unload-hook): Don't
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index fff0356..d82e082 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -64,6 +64,8 @@
(autoload 'secrets-list-collections "secrets")
(autoload 'secrets-search-items "secrets")
+(autoload 'rfc2104-hash "rfc2104")
+
(defvar secrets-enabled)
(defgroup auth-source nil
@@ -780,7 +782,9 @@ while \(:host t) would find all host entries."
(let ((c (nth 0 cell))
(v (nth 1 cell)))
(when (and c v)
- (setq prompt (replace-regexp-in-string (format "%%%c" c) v prompt)))))
+ (setq prompt (replace-regexp-in-string (format "%%%c" c)
+ (format "%s" v)
+ prompt)))))
prompt)
(defun auth-source-ensure-strings (values)
@@ -1106,7 +1110,7 @@ See `auth-source-search' for details on SPEC."
;; special case prompt for passwords
(read-passwd prompt))
((null data)
- (read-string prompt default))
+ (read-string prompt nil nil default))
(t (or data default))))
(when data
@@ -1148,10 +1152,18 @@ See `auth-source-search' for details on SPEC."
(list artificial)))
-;;(funcall (plist-get (nth 0 (auth-source-search :host '("nonesuch") :user "tzz" :port "imap" :create t :max 1)) :save-function))
+;;(funcall (plist-get (nth 0 (auth-source-search :host '("nonesuch2") :user "tzz" :port "imap" :create t :max 1)) :save-function))
(defun auth-source-netrc-saver (file add)
"Save a line ADD in FILE, prompting along the way.
-Respects `auth-source-save-behavior'."
+Respects `auth-source-save-behavior'. Uses
+`auth-source-netrc-cache' to avoid prompting more than once."
+ (let* ((key (format "%s %s" file (rfc2104-hash 'md5 64 16 file add)))
+ (cached (assoc key auth-source-netrc-cache)))
+
+ (if cached
+ (auth-source-do-trivia
+ "auth-source-netrc-saver: found previous run for key %s, returning"
+ key)
(with-temp-buffer
(when (file-exists-p file)
(insert-file-contents file))
@@ -1211,7 +1223,8 @@ Respects `auth-source-save-behavior'."
"auth-source-netrc-create: wrote 1 new line to %s"
file)
(message "Saved new authentication information to %s" file)
- nil)))))
+ nil))))
+ (aput 'auth-source-netrc-cache key "ran"))))
;;; Backend specific parsing: Secrets API backend
-----------------------------------------------------------------------
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 | 10 ++++
lisp/auth-source.el | 141 ++++++++++++++++++++++++++++-----------------------
2 files changed, 87 insertions(+), 64 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