diff options
author | Richard M. Stallman <rms@gnu.org> | 1997-12-21 00:50:07 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1997-12-21 00:50:07 +0000 |
commit | 327d47228b64cacd576615ca824b2f0d11ec948c (patch) | |
tree | ce7faa1a219acdd9bcc92b9621520e0ecf9e020e /lisp/subr.el | |
parent | 1732a96f98d6b3b88c77369e2ae9b76d3a81905f (diff) | |
download | emacs-327d47228b64cacd576615ca824b2f0d11ec948c.tar.gz |
(read-password): New function.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 7e21ef9a46b..cadb2fd313f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -752,6 +752,28 @@ any other non-digit terminates the character code and is then used as input.")) (setq first nil)) code)) +(defun read-password (prompt &optional default) + "Read a password, echoing `.' for each character typed. +End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. +Optional DEFAULT is password to start with." + (let ((pass nil) + (c 0) + (echo-keystrokes 0) + (cursor-in-echo-area t)) + (while (progn (message "%s%s" + prompt + (make-string (length pass) ?.)) + (setq c (read-char)) + (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) + (if (= c ?\C-u) + (setq pass "") + (if (and (/= c ?\b) (/= c ?\177)) + (setq pass (concat pass (char-to-string c))) + (if (> (length pass) 0) + (setq pass (substring pass 0 -1)))))) + (message nil) + (or pass default ""))) + (defun force-mode-line-update (&optional all) "Force the mode-line of the current buffer to be redisplayed. With optional non-nil ALL, force redisplay of all mode-lines." |