aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-03-08 00:16:38 +0000
committerRichard M. Stallman1998-03-08 00:16:38 +0000
commit44071d6b2ca7de02160903e46d47e9037acd7627 (patch)
tree5e0fddab9fa97f7722c7f384c9c69e016bb2615d
parent94a13fbf0176fff9b44b664a576db426008d8d9b (diff)
downloademacs-44071d6b2ca7de02160903e46d47e9037acd7627.tar.gz
emacs-44071d6b2ca7de02160903e46d47e9037acd7627.zip
(read-passwd): Renamed from read-password. New second arg CONFIRM.
-rw-r--r--lisp/subr.el51
1 files changed, 31 insertions, 20 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index c14a048fb52..ba3d1317768 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -763,27 +763,38 @@ any other non-digit terminates the character code and is then used as input."))
763 (setq first nil)) 763 (setq first nil))
764 code)) 764 code))
765 765
766(defun read-password (prompt &optional default) 766(defun read-passwd (prompt &optional confirm default)
767 "Read a password, echoing `.' for each character typed. 767 "Read a password, prompting with PROMPT. Echo `.' for each character typed.
768End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. 768End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line.
769Optional DEFAULT is password to start with." 769Optional argument CONFIRM, if non-nil, then read it twice to make sure.
770 (let ((pass nil) 770Optional DEFAULT is a default password to use instead of empty input."
771 (c 0) 771 (if confirm
772 (echo-keystrokes 0) 772 (let (success)
773 (cursor-in-echo-area t)) 773 (while (not success)
774 (while (progn (message "%s%s" 774 (let ((first (read-passwd prompt nil default))
775 prompt 775 (second (read-passwd "Confirm password: " nil default)))
776 (make-string (length pass) ?.)) 776 (if (equal first second)
777 (setq c (read-char)) 777 (setq success first)
778 (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) 778 (message "Password not repeated accurately; please start over")
779 (if (= c ?\C-u) 779 (sit-for 1))))
780 (setq pass "") 780 success)
781 (if (and (/= c ?\b) (/= c ?\177)) 781 (let ((pass nil)
782 (setq pass (concat pass (char-to-string c))) 782 (c 0)
783 (if (> (length pass) 0) 783 (echo-keystrokes 0)
784 (setq pass (substring pass 0 -1)))))) 784 (cursor-in-echo-area t))
785 (message nil) 785 (while (progn (message "%s%s"
786 (or pass default ""))) 786 prompt
787 (make-string (length pass) ?.))
788 (setq c (read-char))
789 (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
790 (if (= c ?\C-u)
791 (setq pass "")
792 (if (and (/= c ?\b) (/= c ?\177))
793 (setq pass (concat pass (char-to-string c)))
794 (if (> (length pass) 0)
795 (setq pass (substring pass 0 -1))))))
796 (message nil)
797 (or pass default ""))))
787 798
788(defun force-mode-line-update (&optional all) 799(defun force-mode-line-update (&optional all)
789 "Force the mode-line of the current buffer to be redisplayed. 800 "Force the mode-line of the current buffer to be redisplayed.