diff options
| author | Tino Calancha | 2018-07-29 21:21:40 +0900 |
|---|---|---|
| committer | Tino Calancha | 2018-07-29 21:21:40 +0900 |
| commit | b3f7e73fb76a366dc644ee2e6b9f4897c17d201d (patch) | |
| tree | c77ba17c92d8bc2d4d615946b5b515fad5442896 | |
| parent | ea1cf0960a86bc373cfd4900f46d9fe5e847941e (diff) | |
| download | emacs-b3f7e73fb76a366dc644ee2e6b9f4897c17d201d.tar.gz emacs-b3f7e73fb76a366dc644ee2e6b9f4897c17d201d.zip | |
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.
| -rw-r--r-- | doc/lispref/minibuf.texi | 2 | ||||
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | 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}. | |||
| 2199 | @defun read-passwd prompt &optional confirm default | 2199 | @defun read-passwd prompt &optional confirm default |
| 2200 | This function reads a password, prompting with @var{prompt}. It does | 2200 | This function reads a password, prompting with @var{prompt}. It does |
| 2201 | not echo the password as the user types it; instead, it echoes | 2201 | not echo the password as the user types it; instead, it echoes |
| 2202 | @samp{.} for each character in the password. If you want to apply | 2202 | @samp{*} for each character in the password. If you want to apply |
| 2203 | another character to hide the password, let-bind the variable | 2203 | another character to hide the password, let-bind the variable |
| 2204 | @code{read-hide-char} with that character. | 2204 | @code{read-hide-char} with that character. |
| 2205 | 2205 | ||
| @@ -92,6 +92,9 @@ the new version of the file again.) | |||
| 92 | 92 | ||
| 93 | * Changes in Emacs 27.1 | 93 | * Changes in Emacs 27.1 |
| 94 | 94 | ||
| 95 | +++ | ||
| 96 | ** The function 'read-passwd' uses '*' as default character to hide passwords. | ||
| 97 | |||
| 95 | --- | 98 | --- |
| 96 | ** New variable 'xft-ignore-color-fonts'. | 99 | ** New variable 'xft-ignore-color-fonts'. |
| 97 | Default t means don't try to load color fonts when using Xft, as they | 100 | 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'." | |||
| 2299 | If optional CONFIRM is non-nil, read the password twice to make sure. | 2299 | If optional CONFIRM is non-nil, read the password twice to make sure. |
| 2300 | Optional DEFAULT is a default password to use instead of empty input. | 2300 | Optional DEFAULT is a default password to use instead of empty input. |
| 2301 | 2301 | ||
| 2302 | This function echoes `.' for each character that the user types. | 2302 | This function echoes `*' for each character that the user types. |
| 2303 | You could let-bind `read-hide-char' to another hiding character, though. | 2303 | You could let-bind `read-hide-char' to another hiding character, though. |
| 2304 | 2304 | ||
| 2305 | Once the caller uses the password, it can erase the password | 2305 | Once the caller uses the password, it can erase the password |
| @@ -2325,7 +2325,7 @@ by doing (clear-string STRING)." | |||
| 2325 | beg))) | 2325 | beg))) |
| 2326 | (dotimes (i (- end beg)) | 2326 | (dotimes (i (- end beg)) |
| 2327 | (put-text-property (+ i beg) (+ 1 i beg) | 2327 | (put-text-property (+ i beg) (+ 1 i beg) |
| 2328 | 'display (string (or read-hide-char ?.)))))) | 2328 | 'display (string (or read-hide-char ?*)))))) |
| 2329 | minibuf) | 2329 | minibuf) |
| 2330 | (minibuffer-with-setup-hook | 2330 | (minibuffer-with-setup-hook |
| 2331 | (lambda () | 2331 | (lambda () |
| @@ -2340,7 +2340,7 @@ by doing (clear-string STRING)." | |||
| 2340 | (add-hook 'after-change-functions hide-chars-fun nil 'local)) | 2340 | (add-hook 'after-change-functions hide-chars-fun nil 'local)) |
| 2341 | (unwind-protect | 2341 | (unwind-protect |
| 2342 | (let ((enable-recursive-minibuffers t) | 2342 | (let ((enable-recursive-minibuffers t) |
| 2343 | (read-hide-char (or read-hide-char ?.))) | 2343 | (read-hide-char (or read-hide-char ?*))) |
| 2344 | (read-string prompt nil t default)) ; t = "no history" | 2344 | (read-string prompt nil t default)) ; t = "no history" |
| 2345 | (when (buffer-live-p minibuf) | 2345 | (when (buffer-live-p minibuf) |
| 2346 | (with-current-buffer minibuf | 2346 | (with-current-buffer minibuf |