summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2014-07-11 11:09:54 +0200
committerMichael Albinus <michael.albinus@gmx.de>2014-07-11 11:09:54 +0200
commitc0ada759210b090944e0a23ed4879ca1a3ad38a7 (patch)
tree5bc957f5d30cc16af9add35e301e02c5c22bf89a /lisp
parent644656aa562a78edf384abd6f4ce80bc930d5547 (diff)
downloademacs-c0ada759210b090944e0a23ed4879ca1a3ad38a7.tar.gz
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
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/subr.el13
2 files changed, 10 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4e19be4d3ea..3965da7287b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-07-11 Michael Albinus <michael.albinus@gmx.de>
+
+ * subr.el (read-passwd): Use `read-hide-char' if non-nil. Bind it
+ when calling `read-string'. (Bug#17839)
+
2014-07-10 Eli Zaretskii <eliz@gnu.org>
* files.el (warn-maybe-out-of-memory): Fix the wording of the
diff --git a/lisp/subr.el b/lisp/subr.el
index a0c56bf9752..9accb9d36c5 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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