Mercurial > emacs
changeset 20472:79ea90039b23
(read-password): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 21 Dec 1997 00:50:07 +0000 |
parents | d4e514328333 |
children | f8b70ad2fc2a |
files | lisp/subr.el |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/subr.el Sat Dec 20 23:12:09 1997 +0000 +++ b/lisp/subr.el Sun Dec 21 00:50:07 1997 +0000 @@ -752,6 +752,28 @@ (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."