aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeodor Zlatanov2011-02-25 23:52:19 +0000
committerKatsumi Yamaoka2011-02-25 23:52:19 +0000
commit61e9662ef52e9b4a257fc9dd3c3812af2657f70a (patch)
treea84d4be6c56c9ed602cbe73ff675f73da45ef84f
parent4ad89555139cef8136f98c7bd1ab83bf003ef5e4 (diff)
downloademacs-61e9662ef52e9b4a257fc9dd3c3812af2657f70a.tar.gz
emacs-61e9662ef52e9b4a257fc9dd3c3812af2657f70a.zip
Merge changes made in Gnus trunk.
auth-source.el (auth-source-search): Cache empty result sets. password-cache.el (password-in-cache-p): Convenience function to check if a key is in the cache, even if the value is nil.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/gnus/ChangeLog2
-rw-r--r--lisp/gnus/auth-source.el16
-rw-r--r--lisp/password-cache.el6
4 files changed, 27 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b59b11590d0..f5df9a26c37 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12011-02-25 Teodor Zlatanov <tzz@lifelogs.com>
2
3 * password-cache.el (password-in-cache-p): Convenience function to
4 check if a key is in the cache, even if the value is nil.
5
12011-02-25 Jambunathan K <kjambunathan@gmail.com> 62011-02-25 Jambunathan K <kjambunathan@gmail.com>
2 7
3 * emacs-lisp/package-x.el (package--archive-contents-from-url) 8 * emacs-lisp/package-x.el (package--archive-contents-from-url)
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 7e39a369714..3eb7a477dd1 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,7 @@
12011-02-25 Teodor Zlatanov <tzz@lifelogs.com> 12011-02-25 Teodor Zlatanov <tzz@lifelogs.com>
2 2
3 * auth-source.el (auth-source-search): Cache empty result sets.
4
3 * auth-source.el (auth-source-save-behavior): New variable to replace 5 * auth-source.el (auth-source-save-behavior): New variable to replace
4 `auth-source-never-create'. 6 `auth-source-never-create'.
5 (auth-source-netrc-create): Use it. 7 (auth-source-netrc-create): Use it.
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index e4d4fd4c83b..500de10b71c 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -524,10 +524,13 @@ must call it to obtain the actual value."
524 (keys (loop for i below (length spec) by 2 524 (keys (loop for i below (length spec) by 2
525 unless (memq (nth i spec) ignored-keys) 525 unless (memq (nth i spec) ignored-keys)
526 collect (nth i spec))) 526 collect (nth i spec)))
527 (cached (auth-source-remembered-p spec))
528 ;; note that we may have cached results but found is still nil
529 ;; (there were no results from the search)
527 (found (auth-source-recall spec)) 530 (found (auth-source-recall spec))
528 filtered-backends accessor-key backend) 531 filtered-backends accessor-key backend)
529 532
530 (if (and found auth-source-do-cache) 533 (if (and cached auth-source-do-cache)
531 (auth-source-do-debug 534 (auth-source-do-debug
532 "auth-source-search: found %d CACHED results matching %S" 535 "auth-source-search: found %d CACHED results matching %S"
533 (length found) spec) 536 (length found) spec)
@@ -580,7 +583,8 @@ must call it to obtain the actual value."
580 "auth-source-search: CREATED %d results (max %d) matching %S" 583 "auth-source-search: CREATED %d results (max %d) matching %S"
581 (length found) max spec)) 584 (length found) max spec))
582 585
583 (when (and found auth-source-do-cache) 586 ;; note we remember the lack of result too, if it's applicable
587 (when auth-source-do-cache
584 (auth-source-remember spec found))) 588 (auth-source-remember spec found)))
585 589
586 found)) 590 found))
@@ -654,6 +658,11 @@ Returns the deleted entries."
654 (password-read-from-cache 658 (password-read-from-cache
655 (concat auth-source-magic (format "%S" spec)))) 659 (concat auth-source-magic (format "%S" spec))))
656 660
661(defun auth-source-remembered-p (spec)
662 "Check if SPEC is remembered."
663 (password-in-cache-p
664 (concat auth-source-magic (format "%S" spec))))
665
657(defun auth-source-forget (spec) 666(defun auth-source-forget (spec)
658 "Forget any cached data matching SPEC exactly. 667 "Forget any cached data matching SPEC exactly.
659 668
@@ -664,7 +673,10 @@ Returns t or nil for forgotten or not found."
664;;; (loop for sym being the symbols of password-data when (string-match (concat "^" auth-source-magic) (symbol-name sym)) collect (symbol-name sym)) 673;;; (loop for sym being the symbols of password-data when (string-match (concat "^" auth-source-magic) (symbol-name sym)) collect (symbol-name sym))
665 674
666;;; (auth-source-remember '(:host "wedd") '(4 5 6)) 675;;; (auth-source-remember '(:host "wedd") '(4 5 6))
676;;; (auth-source-remembered-p '(:host "wedd"))
667;;; (auth-source-remember '(:host "xedd") '(1 2 3)) 677;;; (auth-source-remember '(:host "xedd") '(1 2 3))
678;;; (auth-source-remembered-p '(:host "xedd"))
679;;; (auth-source-remembered-p '(:host "zedd"))
668;;; (auth-source-recall '(:host "xedd")) 680;;; (auth-source-recall '(:host "xedd"))
669;;; (auth-source-recall '(:host t)) 681;;; (auth-source-recall '(:host t))
670;;; (auth-source-forget+ :host t) 682;;; (auth-source-forget+ :host t)
diff --git a/lisp/password-cache.el b/lisp/password-cache.el
index 8738aa65a9f..a7f75a03add 100644
--- a/lisp/password-cache.el
+++ b/lisp/password-cache.el
@@ -76,6 +76,12 @@ regulate cache behavior."
76 key 76 key
77 (symbol-value (intern-soft key password-data)))) 77 (symbol-value (intern-soft key password-data))))
78 78
79(defun password-in-cache-p (key)
80 "Check if KEY is in the cache."
81 (and password-cache
82 key
83 (intern-soft key password-data)))
84
79(defun password-read (prompt &optional key) 85(defun password-read (prompt &optional key)
80 "Read password, for use with KEY, from user, or from cache if wanted. 86 "Read password, for use with KEY, from user, or from cache if wanted.
81KEY indicate the purpose of the password, so the cache can 87KEY indicate the purpose of the password, so the cache can