From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: better than read-hide-char Date: Tue, 31 Jul 2018 09:47:56 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1533044878 16947 195.159.176.226 (31 Jul 2018 13:47:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 31 Jul 2018 13:47:58 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 31 15:47:54 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fkV09-0004CG-4m for ged-emacs-devel@m.gmane.org; Tue, 31 Jul 2018 15:47:49 +0200 Original-Received: from localhost ([::1]:58901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkV2F-0007Ap-UO for ged-emacs-devel@m.gmane.org; Tue, 31 Jul 2018 09:49:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkV0U-0005vT-W7 for emacs-devel@gnu.org; Tue, 31 Jul 2018 09:48:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkV0Q-0008Qf-4d for emacs-devel@gnu.org; Tue, 31 Jul 2018 09:48:11 -0400 Original-Received: from [195.159.176.226] (port=35828 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkV0P-0008Pu-RB for emacs-devel@gnu.org; Tue, 31 Jul 2018 09:48:06 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fkUyG-0001wy-6B for emacs-devel@gnu.org; Tue, 31 Jul 2018 15:45:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 50 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:PTCLQehXvao9Z40SDdtaCFsy/qE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228039 Archived-At: > the password echoes as 012345678901234567890123456789... > That way, you could tell how many characters you have successfully typed > even when they are 20, 30, 40, 50, 60 or 70 characters. > That would help people notice some mistakes in long passwords. Sure. Another option would be the patch below. BTW, for those who like to have their password sanity-checked locally before they press RET, it even displays some kind of short hash ;-) Stefan PS: Adding a command to temporarily reveal the password is also a small matter of programming. diff --git a/lisp/subr.el b/lisp/subr.el index 5b38c4d42e..d93b97a7c4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2452,11 +2452,19 @@ (message "Password not repeated accurately; please start over") (sit-for 1)))) success) - (let ((hide-chars-fun + (let* (ol + (hide-chars-fun (lambda (beg end _len) (clear-this-command-keys) (setq beg (min end (max (minibuffer-prompt-end) beg))) + (move-overlay ol (point-max) (point-max)) + (let ((len (- (point-max) (minibuffer-prompt-end))) + (hash (md5 (minibuffer-contents-no-properties)))) + (overlay-put ol 'after-string + (if (> len 1) + (format " [%d chars, #%s]" + len (substring hash 0 4))))) (dotimes (i (- end beg)) (put-text-property (+ i beg) (+ 1 i beg) 'display (string (or read-hide-char ?.)))))) @@ -2471,6 +2479,7 @@ read-passwd (use-local-map read-passwd-map) (setq-local inhibit-modification-hooks nil) ;bug#15501. (setq-local show-paren-mode nil) ;bug#16091. + (setq ol (make-overlay (point-max) (point-max) nil t t)) (add-hook 'after-change-functions hide-chars-fun nil 'local)) (unwind-protect (let ((enable-recursive-minibuffers t)