diff options
| author | Glenn Morris | 2007-12-04 04:11:13 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-12-04 04:11:13 +0000 |
| commit | 8b33467307d1cbc16ac7b60dfdf5d3090a029e29 (patch) | |
| tree | 03e4f9477b7f03023c6665ca3edbb35667dba811 /lisp | |
| parent | 49052ec018b055ad82f2682ee06a77e8e1da2e90 (diff) | |
| download | emacs-8b33467307d1cbc16ac7b60dfdf5d3090a029e29.tar.gz emacs-8b33467307d1cbc16ac7b60dfdf5d3090a029e29.zip | |
(top-level): Don't require cl when compiling.
(password-read-and-add): Doc fix. Make obsolete.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/password-cache.el | 25 |
2 files changed, 14 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 429c08f72c3..e96ca3b2b54 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2007-12-04 Glenn Morris <rgm@gnu.org> | 1 | 2007-12-04 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * password-cache.el: Move here from gnus/password.el. | ||
| 4 | (top-level): Don't require cl when compiling. | ||
| 5 | (password-read-and-add): Doc fix. Make obsolete. | ||
| 6 | |||
| 3 | * emulation/cua-base.el (top-level): Move (provide 'cua-base) to end. | 7 | * emulation/cua-base.el (top-level): Move (provide 'cua-base) to end. |
| 4 | No longer provide 'cua. Don't require cua-rect, cua-gmrk when | 8 | No longer provide 'cua. Don't require cua-rect, cua-gmrk when |
| 5 | compiling. | 9 | compiling. |
diff --git a/lisp/password-cache.el b/lisp/password-cache.el index f82de18d94e..eeaa31b9a31 100644 --- a/lisp/password-cache.el +++ b/lisp/password-cache.el | |||
| @@ -37,13 +37,6 @@ | |||
| 37 | ;; (password-cache-add "test" "foo") | 37 | ;; (password-cache-add "test" "foo") |
| 38 | ;; => nil | 38 | ;; => nil |
| 39 | 39 | ||
| 40 | ;; Note the previous two can be replaced with: | ||
| 41 | ;; (password-read-and-add "Password? " "test") | ||
| 42 | ;; ;; Minibuffer prompt for password. | ||
| 43 | ;; => "foo" | ||
| 44 | ;; ;; "foo" is now cached with key "test" | ||
| 45 | |||
| 46 | |||
| 47 | ;; (password-read "Password? " "test") | 40 | ;; (password-read "Password? " "test") |
| 48 | ;; ;; No minibuffer prompt | 41 | ;; ;; No minibuffer prompt |
| 49 | ;; => "foo" | 42 | ;; => "foo" |
| @@ -60,9 +53,6 @@ | |||
| 60 | 53 | ||
| 61 | ;;; Code: | 54 | ;;; Code: |
| 62 | 55 | ||
| 63 | (eval-when-compile | ||
| 64 | (require 'cl)) | ||
| 65 | |||
| 66 | (defcustom password-cache t | 56 | (defcustom password-cache t |
| 67 | "Whether to cache passwords." | 57 | "Whether to cache passwords." |
| 68 | :group 'password | 58 | :group 'password |
| @@ -97,14 +87,20 @@ The variable `password-cache' control whether the cache is used." | |||
| 97 | (defun password-read-and-add (prompt &optional key) | 87 | (defun password-read-and-add (prompt &optional key) |
| 98 | "Read password, for use with KEY, from user, or from cache if wanted. | 88 | "Read password, for use with KEY, from user, or from cache if wanted. |
| 99 | Then store the password in the cache. Uses `password-read' and | 89 | Then store the password in the cache. Uses `password-read' and |
| 100 | `password-cache-add'. | 90 | `password-cache-add'. Custom variables `password-cache' and |
| 101 | Custom variables `password-cache' and `password-cache-expiry' | 91 | `password-cache-expiry' regulate cache behavior. |
| 102 | regulate cache behavior." | 92 | |
| 93 | Warning: the password is cached without checking that it is | ||
| 94 | correct. It is better to check the password before caching. If | ||
| 95 | you must use this function, take care to check passwords and | ||
| 96 | remove incorrect ones from the cache." | ||
| 103 | (let ((password (password-read prompt key))) | 97 | (let ((password (password-read prompt key))) |
| 104 | (when (and password key) | 98 | (when (and password key) |
| 105 | (password-cache-add key password)) | 99 | (password-cache-add key password)) |
| 106 | password)) | 100 | password)) |
| 107 | 101 | ||
| 102 | (make-obsolete 'password-read-and-add 'password-read "23.1") | ||
| 103 | |||
| 108 | (defun password-cache-remove (key) | 104 | (defun password-cache-remove (key) |
| 109 | "Remove password indexed by KEY from password cache. | 105 | "Remove password indexed by KEY from password cache. |
| 110 | This is typically run be a timer setup from `password-cache-add', | 106 | This is typically run be a timer setup from `password-cache-add', |
| @@ -121,8 +117,7 @@ user again." | |||
| 121 | 117 | ||
| 122 | (defun password-cache-add (key password) | 118 | (defun password-cache-add (key password) |
| 123 | "Add password to cache. | 119 | "Add password to cache. |
| 124 | The password is removed by a timer after `password-cache-expiry' | 120 | The password is removed by a timer after `password-cache-expiry' seconds." |
| 125 | seconds." | ||
| 126 | (when (and password-cache-expiry (null (intern-soft key password-data))) | 121 | (when (and password-cache-expiry (null (intern-soft key password-data))) |
| 127 | (run-at-time password-cache-expiry nil | 122 | (run-at-time password-cache-expiry nil |
| 128 | #'password-cache-remove | 123 | #'password-cache-remove |