Hide password in batch mode

* doc/lispref/minibuf.texi (Intro to Minibuffers, Reading a Password):
Password hiding is available in batch mode, do not mention it in
the exclusion list.  Mention `read-hide-char'. 

* lisp/subr.el (read-passwd): Use `read-hide-char' if non-nil.  Bind it
when calling `read-string'.

* src/minibuf.c (top): Include systty.h.  Declare external
emacs_get_tty and emacs_set_tty.
(Vread_hide_char): New lisp variable.
(read_minibuf_noninteractive): Hide characters with
Vread_hide_char if it is a character.

* src/sysdep.c (emacs_get_tty, emacs_set_tty): Make them externally visible.

Fixes: debbugs:17839
This commit is contained in:
Michael Albinus 2014-07-11 11:09:54 +02:00
parent 644656aa56
commit c0ada75921
7 changed files with 71 additions and 17 deletions

View file

@ -2016,7 +2016,7 @@ If optional CONFIRM is non-nil, read the password twice to make sure.
Optional DEFAULT is a default password to use instead of empty input.
This function echoes `.' for each character that the user types.
Note that in batch mode, the input is not hidden!
You could let-bind `read-hide-char' to another hiding character, though.
Once the caller uses the password, it can erase the password
by doing (clear-string STRING)."
@ -2041,7 +2041,7 @@ by doing (clear-string STRING)."
beg)))
(dotimes (i (- end beg))
(put-text-property (+ i beg) (+ 1 i beg)
'display (string ?.)))))
'display (string (or read-hide-char ?.))))))
minibuf)
(minibuffer-with-setup-hook
(lambda ()
@ -2055,12 +2055,9 @@ by doing (clear-string STRING)."
(setq-local show-paren-mode nil) ;bug#16091.
(add-hook 'after-change-functions hide-chars-fun nil 'local))
(unwind-protect
(let ((enable-recursive-minibuffers t))
(read-string
(if noninteractive
(format "%s[INPUT WILL NOT BE HIDDEN!] " prompt) ; bug#17839
prompt)
nil t default)) ; t = "no history"
(let ((enable-recursive-minibuffers t)
(read-hide-char (or read-hide-char ?.)))
(read-string prompt nil t default)) ; t = "no history"
(when (buffer-live-p minibuf)
(with-current-buffer minibuf
;; Not sure why but it seems that there might be cases where the