all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: better than read-hide-char
Date: Tue, 31 Jul 2018 09:47:56 -0400	[thread overview]
Message-ID: <jwv7elbo7d8.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: E1fkKLW-0002D2-Ep@fencepost.gnu.org

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




  parent reply	other threads:[~2018-07-31 13:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31  2:25 better than read-hide-char Richard Stallman
2018-07-31  7:18 ` Andreas Schwab
2018-07-31 15:08   ` Drew Adams
2018-07-31 15:15     ` Andreas Schwab
2018-07-31 15:41       ` Drew Adams
2018-08-01  4:31   ` Richard Stallman
2018-07-31  9:25 ` Simon Leinen
2018-07-31 13:47 ` Stefan Monnier [this message]
2018-08-01  4:29   ` Richard Stallman
2018-08-01 15:48   ` Davis Herring
2018-08-01 16:15     ` Stefan Monnier
2019-03-02 21:58   ` Juri Linkov
2018-07-31 16:10 ` Clément Pit-Claudel
2018-07-31 20:17   ` Stefan Monnier
2018-08-01 14:59     ` Clément Pit-Claudel
2018-08-01 15:21       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv7elbo7d8.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.