Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!rpi!tale From: tale@pawl.rpi.edu (David C Lawrence) Newsgroups: gnu.emacs Subject: Re: Getting Emacs to not echo characters Message-ID: <257078E5.7EF@rpi.edu> Date: 26 Nov 89 23:59:32 GMT References: <741@milton.acs.washington.edu> Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 29 In deven@rpi.edu (Deven T. Corzine): Deven> Since this may be of general usefulness, I am posting this as well as Deven> Email to the original poster. [credit due to tale@rpi.edu for Deven> function, I modified to select minibuffer window when prompting for a Deven> password.] I wish you had asked me about this first; when you informed me of your idea a couple of months ago, I did it "the right way", because your modifications did not work for putting the cursor in the minibuffer when I incorporated it verbatim into another package. Pete already had the correct function last night, but now, for the sake of everyone else: (defun read-passwd (&optional prompt) "Allow user to type a string without it showing. Returns string. If optional PROMPT non-nil, use it as the prompt string in the minibuffer." ;; this is based on a similar function in telnet.el ;; the major drawback is that while being prompted for a password ;; it stays in this routine until C-g, RET or LFD is typed. (let ((passwd "") (echo-keystrokes 0) (cursor-in-echo-area t) char) (if prompt (message prompt)) (while (not (or (= (setq char (read-char)) 13) (= char 10))) ;; naughty bit. take C-h to mean DEL. (if (or (= char 8) (= char 127)) (if (> (length passwd) 0) (setq passwd (substring passwd 0 (1- (length passwd))))) (setq passwd (concat passwd (char-to-string char)))) (if prompt (message (concat prompt (make-string (length passwd) ?*))))) (if prompt (message "")) passwd))