Override password-cache-expiry with auth-source-cache-expiry.
authorTed Zlatanov <tzz@lifelogs.com>
Wed, 16 Feb 2011 22:05:19 +0000 (16:05 -0600)
committerTed Zlatanov <tzz@lifelogs.com>
Wed, 16 Feb 2011 22:05:19 +0000 (16:05 -0600)
* auth-source.el (auth-source-cache-expiry): New variable to override
`password-cache-expiry'.
(auth-source-remember): Use it.

lisp/ChangeLog
lisp/auth-source.el

index 2577934..f7adaa1 100644 (file)
@@ -4,6 +4,9 @@
        result when the user doesn't want to write to the file.
        (auth-source-netrc-search): Expect a synthetic result and proceed
        accordingly.
+       (auth-source-cache-expiry): New variable to override
+       `password-cache-expiry'.
+       (auth-source-remember): Use it.
 
        * nnimap.el (nnimap-credentials): Remove the `inhibit-create'
        parameter.  Create entry if necessary by using :create t.
index 29829eb..2b284e3 100644 (file)
   :version "23.1" ;; No Gnus
   :group 'gnus)
 
+;;;###autoload
+(defcustom auth-source-cache-expiry 7200
+  "How many seconds passwords are cached, or nil to disable
+expiring.  Overrides `password-cache-expiry' through a
+let-binding."
+  :group 'auth-source
+  :type '(choice (const :tag "Never" nil)
+                 (const :tag "All Day" 86400)
+                 (const :tag "2 Hours" 7200)
+                 (const :tag "30 Minutes" 1800)
+                 (integer :tag "Seconds")))
+
 (defclass auth-source-backend ()
   ((type :initarg :type
          :initform 'netrc
@@ -588,8 +600,9 @@ Returns the deleted entries."
 
 (defun auth-source-remember (spec found)
   "Remember FOUND search results for SPEC."
-  (password-cache-add
-   (concat auth-source-magic (format "%S" spec)) found))
+  (let ((password-cache-expiry auth-source-cache-expiry))
+    (password-cache-add
+     (concat auth-source-magic (format "%S" spec)) found)))
 
 (defun auth-source-recall (spec)
   "Recall FOUND search results for SPEC."