1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-27 19:31:38 +00:00

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.
This commit is contained in:
Tino Calancha 2018-07-29 21:21:40 +09:00
parent ea1cf0960a
commit b3f7e73fb7
3 changed files with 7 additions and 4 deletions

View File

@ -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.

View File

@ -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

View File

@ -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