summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2008-11-16 21:02:05 +0000
committerChong Yidong <cyd@stupidchicken.com>2008-11-16 21:02:05 +0000
commitd4a263ba04623f28736e004c295d8dc483a0b23e (patch)
tree582602250364ec39f1267862095d05bcf2642830 /lisp/subr.el
parent71a00ac2df7df0bb82d4d7198bdb322f2ca4dc3c (diff)
downloademacs-d4a263ba04623f28736e004c295d8dc483a0b23e.tar.gz
(read-passwd): Use read-event instead of read-char-exclusive.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el25
1 files changed, 16 insertions, 9 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index fac523d4a7f..eb4cf15e141 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1811,16 +1811,27 @@ by doing (clear-string STRING)."
(c 0)
(echo-keystrokes 0)
(cursor-in-echo-area t)
- (message-log-max nil))
+ (message-log-max nil)
+ (stop-keys (list 'return ?\r ?\n ?\e))
+ (rubout-keys (list 'backspace ?\b ?\177)))
(add-text-properties 0 (length prompt)
minibuffer-prompt-properties prompt)
(while (progn (message "%s%s"
prompt
(make-string (length pass) ?.))
- (setq c (read-char-exclusive nil t))
- (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
+ ;; We used to use read-char-exclusive, that that
+ ;; gives funny behavior when the user presses,
+ ;; e.g., the arrow keys.
+ (setq c (read-event nil t))
+ (not (memq c stop-keys)))
(clear-this-command-keys)
- (cond ((= c ?\C-u) ; kill line
+ (cond ((memq c rubout-keys) ; rubout
+ (when (> (length pass) 0)
+ (let ((new-pass (substring pass 0 -1)))
+ (and (arrayp pass) (clear-string pass))
+ (setq pass new-pass))))
+ ((not (numberp c)))
+ ((= c ?\C-u) ; kill line
(and (arrayp pass) (clear-string pass))
(setq pass ""))
((= c ?\C-y) ; yank
@@ -1835,16 +1846,12 @@ by doing (clear-string STRING)."
(and (arrayp pass) (clear-string pass))
(setq c ?\0)
(setq pass new-pass))))
- ((and (/= c ?\b) (/= c ?\177)) ; insert char
+ ((characterp c) ; insert char
(let* ((new-char (char-to-string c))
(new-pass (concat pass new-char)))
(and (arrayp pass) (clear-string pass))
(clear-string new-char)
(setq c ?\0)
- (setq pass new-pass)))
- ((> (length pass) 0) ; rubout
- (let ((new-pass (substring pass 0 -1)))
- (and (arrayp pass) (clear-string pass))
(setq pass new-pass)))))
(message nil)
(or pass default "")))))