Path: utzoo!utgpu!watmath!uunet!wuarchive!uwm.edu!rpi!netserv2!deven From: deven@rpi.edu (Deven T. Corzine) Newsgroups: gnu.emacs Subject: Re: Getting Emacs to not echo characters Message-ID: Date: 26 Nov 89 21:09:16 GMT References: <741@milton.acs.washington.edu> Organization: Rensselaer Polytechnic Institute, Troy, NY Lines: 41 In-Reply-To: pete@milton.acs.washington.edu's message of 26 Nov 89 04:07:20 GMT On 26 Nov 89 04:07:20 GMT, pete@milton.acs.washington.edu (Pete Pulliam) said: Pete> I am writing a short emacs lisp program which, at one point, Pete> requires a password to be typed. I don't want this password to Pete> be displayed on the screen, but am having difficulty turning Pete> echoing off in emacs. Any info on how to do this would be Pete> appreciated. Since this may be of general usefulness, I am posting this as well as Email to the original poster. [credit due to tale@rpi.edu for function, I modified to select minibuffer window when prompting for a password.] (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 mini-buffer. Not meant to be called by the user explicitly." (let ((passwd "") (echo-keystrokes 0) char (win (selected-window))) (if prompt (progn (select-window (minibuffer-window)) (message prompt))) (while (not (or (= (setq char (read-char)) 13) (= char 10))) (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 (progn (select-window win) (message ""))) passwd)) Deven -- Deven T. Corzine Internet: deven@rpi.edu, shadow@pawl.rpi.edu Snail: 2151 12th St. Apt. 4, Troy, NY 12180 Phone: (518) 274-0327 Bitnet: deven@rpitsmts, userfxb6@rpitsmts UUCP: uunet!rpi!deven Simple things should be simple and complex things should be possible.