diff options
| author | Richard M. Stallman | 1997-12-21 00:50:07 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-12-21 00:50:07 +0000 |
| commit | e0e4cb7afab544d0715a50efd4dcd697321afd26 (patch) | |
| tree | 1b2b65f2ec79833ce931196a878276ab32c1ccc7 | |
| parent | bafa64ca7840dd4044fa1ac6615d2a274a45430b (diff) | |
| download | emacs-e0e4cb7afab544d0715a50efd4dcd697321afd26.tar.gz emacs-e0e4cb7afab544d0715a50efd4dcd697321afd26.zip | |
(read-password): New function.
| -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.")) | |||
| 752 | (setq first nil)) | 752 | (setq first nil)) |
| 753 | code)) | 753 | code)) |
| 754 | 754 | ||
| 755 | (defun read-password (prompt &optional default) | ||
| 756 | "Read a password, echoing `.' for each character typed. | ||
| 757 | End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. | ||
| 758 | Optional DEFAULT is password to start with." | ||
| 759 | (let ((pass nil) | ||
| 760 | (c 0) | ||
| 761 | (echo-keystrokes 0) | ||
| 762 | (cursor-in-echo-area t)) | ||
| 763 | (while (progn (message "%s%s" | ||
| 764 | prompt | ||
| 765 | (make-string (length pass) ?.)) | ||
| 766 | (setq c (read-char)) | ||
| 767 | (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) | ||
| 768 | (if (= c ?\C-u) | ||
| 769 | (setq pass "") | ||
| 770 | (if (and (/= c ?\b) (/= c ?\177)) | ||
| 771 | (setq pass (concat pass (char-to-string c))) | ||
| 772 | (if (> (length pass) 0) | ||
| 773 | (setq pass (substring pass 0 -1)))))) | ||
| 774 | (message nil) | ||
| 775 | (or pass default ""))) | ||
| 776 | |||
| 755 | (defun force-mode-line-update (&optional all) | 777 | (defun force-mode-line-update (&optional all) |
| 756 | "Force the mode-line of the current buffer to be redisplayed. | 778 | "Force the mode-line of the current buffer to be redisplayed. |
| 757 | With optional non-nil ALL, force redisplay of all mode-lines." | 779 | With optional non-nil ALL, force redisplay of all mode-lines." |