auth-source: add auth-source-format-cache-entry
authorJulien Danjou <julien@danjou.info>
Tue, 20 Sep 2011 11:57:43 +0000 (13:57 +0200)
committerJulien Danjou <julien@danjou.info>
Tue, 20 Sep 2011 12:31:07 +0000 (14:31 +0200)
Signed-off-by: Julien Danjou <julien@danjou.info>
lisp/ChangeLog
lisp/auth-source.el

index 9e68a04..f6cf698 100644 (file)
@@ -1,3 +1,7 @@
+2011-09-20  Julien Danjou  <julien@danjou.info>
+
+       * auth-source.el (auth-source-format-cache-entry): New function.
+
 2011-09-20  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * gnus-fun.el (gnus-convert-image-to-x-face-command): Doc fix.
index 39bf32f..2d6f472 100644 (file)
@@ -759,28 +759,31 @@ Returns the deleted entries."
         do (password-cache-remove (symbol-name sym)))
   (setq auth-source-netrc-cache nil))
 
+(defun auth-source-format-cache-entry (spec)
+  "Format SPEC entry to put it in the password cache."
+  (concat auth-source-magic (format "%S" spec)))
+
 (defun auth-source-remember (spec found)
   "Remember FOUND search results for SPEC."
   (let ((password-cache-expiry auth-source-cache-expiry))
     (password-cache-add
-     (concat auth-source-magic (format "%S" spec)) found)))
+     (auth-source-format-cache-entry spec) found)))
 
 (defun auth-source-recall (spec)
   "Recall FOUND search results for SPEC."
-  (password-read-from-cache
-   (concat auth-source-magic (format "%S" spec))))
+  (password-read-from-cache (auth-source-format-cache-entry spec)))
 
 (defun auth-source-remembered-p (spec)
   "Check if SPEC is remembered."
   (password-in-cache-p
-   (concat auth-source-magic (format "%S" spec))))
+   (auth-source-format-cache-entry spec)))
 
 (defun auth-source-forget (spec)
   "Forget any cached data matching SPEC exactly.
 
 This is the same SPEC you passed to `auth-source-search'.
 Returns t or nil for forgotten or not found."
-  (password-cache-remove (concat auth-source-magic (format "%S" spec))))
+  (password-cache-remove (auth-source-format-cache-entry spec)))
 
 ;;; (loop for sym being the symbols of password-data when (string-match (concat "^" auth-source-magic) (symbol-name sym)) collect (symbol-name sym))