From: ueno Date: Tue, 2 Nov 1999 20:20:08 +0000 (+0000) Subject: (pgg-passphrase-cache-expiry): New variable. X-Git-Tag: emiko-1_13_7~107 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=28852c83339f83609de8186808efb4d9ca83aa29;p=elisp%2Fsemi.git (pgg-passphrase-cache-expiry): New variable. (pgg-passphrase-cache): New variable. (pgg-read-passphrase): Add optional argument `key'. (pgg-add-passphrase-cache): New function. (pgg-remove-passphrase-cache): New function. --- diff --git a/pgg.el b/pgg.el index 2db896b..1cc96c6 100644 --- a/pgg.el +++ b/pgg.el @@ -215,8 +215,11 @@ and END to the keyring.") ;;; @ utility functions ;;; +(defvar pgg-passphrase-cache-expiry 16) +(defvar pgg-passphrase-cache (make-vector 7 0)) + (defvar pgg-read-passphrase nil) -(defun pgg-read-passphrase (prompt) +(defun pgg-read-passphrase (prompt &optional key) (if (not pgg-read-passphrase) (if (functionp 'read-passwd) (setq pgg-read-passphrase 'read-passwd) @@ -224,7 +227,18 @@ and END to the keyring.") (setq pgg-read-passphrase 'read-passwd) (autoload 'ange-ftp-read-passwd "ange-ftp") (setq pgg-read-passphrase 'ange-ftp-read-passwd)))) - (funcall pgg-read-passphrase prompt)) + (or (and key (symbol-value (intern-soft key pgg-passphrase-cache))) + (funcall pgg-read-passphrase prompt))) + +(defun pgg-add-passphrase-cache (key passphrase) + (set (intern key pgg-passphrase-cache) + passphrase) + (run-at-time pgg-passphrase-cache-expiry nil + #'pgg-remove-passphrase-cache + key)) + +(defun pgg-remove-passphrase-cache (key) + (unintern key pgg-passphrase-cache)) (provide 'pgg)