summaryrefslogtreecommitdiff
path: root/itches/emacs/read-passwd-reveal.patch
blob: 09eba80edbb3fd5c44827bf0bd3fa01dcd28a5cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/lisp/subr.el b/lisp/subr.el
index 06ea503da6..da9253cedd 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2820,6 +2820,7 @@ read-passwd-map
   ;; minibuffer-local-map along the way!
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
+    (define-key map "\C-c\C-c" #'read-passwd-toggle-visibility)
     (define-key map "\C-u" #'delete-minibuffer-contents) ;bug#12570
     map)
   "Keymap used while reading passwords.")
@@ -2830,6 +2831,14 @@ read-password--hide-password
       (put-text-property (+ i beg) (+ 1 i beg)
                          'display (string (or read-hide-char ?*))))))
 
+(defun read-passwd-toggle-visibility ()
+  (interactive)
+  (if (member #'read-password--hide-password post-command-hook)
+      (progn
+        (remove-hook 'post-command-hook #'read-password--hide-password t)
+        (remove-text-properties (minibuffer-prompt-end) (point-max) '(display)))
+    (add-hook 'post-command-hook #'read-password--hide-password nil t)))
+
 (defun read-passwd (prompt &optional confirm default)
   "Read a password, prompting with PROMPT, and return it.
 If optional CONFIRM is non-nil, read the password twice to make sure.