From b3f7e73fb76a366dc644ee2e6b9f4897c17d201d Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Sun, 29 Jul 2018 21:21:40 +0900 Subject: [PATCH] Prefer ?* to hide passwords It might be argued that a hidden string is more legible when using ?* as the hidden character instead of ?. For example, the following strings have the same length: "......" "******" It's slighly easier to visually count the number of characters in the second string (Bug#32220). * lisp/subr.el (read-passwd): Prefer ?* as default char instead of ?. * doc/lispref/minibuf.texi (Reading a Password): Update manual. ; * etc/NEWS (Changes in Emacs 27.1): Announce the change. --- doc/lispref/minibuf.texi | 2 +- etc/NEWS | 3 +++ lisp/subr.el | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 889b64af8ae..d091787a680 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -2199,7 +2199,7 @@ function @code{read-passwd}. @defun read-passwd prompt &optional confirm default This function reads a password, prompting with @var{prompt}. It does not echo the password as the user types it; instead, it echoes -@samp{.} for each character in the password. If you want to apply +@samp{*} for each character in the password. If you want to apply another character to hide the password, let-bind the variable @code{read-hide-char} with that character. diff --git a/etc/NEWS b/etc/NEWS index 089fc4053b1..31ccb447362 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -92,6 +92,9 @@ the new version of the file again.) * Changes in Emacs 27.1 ++++ +** The function 'read-passwd' uses '*' as default character to hide passwords. + --- ** New variable 'xft-ignore-color-fonts'. Default t means don't try to load color fonts when using Xft, as they diff --git a/lisp/subr.el b/lisp/subr.el index 6b30371a868..f8c19efc379 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2299,7 +2299,7 @@ some sort of escape sequence, the ambiguity is resolved via `read-key-delay'." 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. +This function echoes `*' for each character that the user types. You could let-bind `read-hide-char' to another hiding character, though. Once the caller uses the password, it can erase the password @@ -2325,7 +2325,7 @@ by doing (clear-string STRING)." beg))) (dotimes (i (- end beg)) (put-text-property (+ i beg) (+ 1 i beg) - 'display (string (or read-hide-char ?.)))))) + 'display (string (or read-hide-char ?*)))))) minibuf) (minibuffer-with-setup-hook (lambda () @@ -2340,7 +2340,7 @@ by doing (clear-string STRING)." (add-hook 'after-change-functions hide-chars-fun nil 'local)) (unwind-protect (let ((enable-recursive-minibuffers t) - (read-hide-char (or read-hide-char ?.))) + (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 -- 2.39.2