diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2021-11-26 19:49:48 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2021-11-26 19:49:48 +0100 |
| commit | 06be5c03a978af7eeba458fa0d0d2f1288bae59b (patch) | |
| tree | d9420a817da438110a3de0b96e94ae1c24f2f861 /itches/emacs/tracker.org | |
| parent | dd3e9c7f928b08a2dc7968c468e6812d0f4da32f (diff) | |
| download | memory-leaks-06be5c03a978af7eeba458fa0d0d2f1288bae59b.tar.xz | |
Add tentative enhancement request
Diffstat (limited to 'itches/emacs/tracker.org')
| -rw-r--r-- | itches/emacs/tracker.org | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/itches/emacs/tracker.org b/itches/emacs/tracker.org index 0f23f3a..a97e788 100644 --- a/itches/emacs/tracker.org +++ b/itches/emacs/tracker.org @@ -130,6 +130,94 @@ Cf. [[https://bugs.archlinux.org/task/58886][Arch Linux]], [[https://bugs.debian :Role: author :PatchApplied: t :END: +*** TODO Add command to toggle password visibility +**** cover letter +Hello Emacs, + +On occasion, e.g. when saving .authinfo.gpg, I'd like to briefly peek at +the password I'm typing. Entering the password twice is an appreciated +safeguard, but I know I'm perfectly able to make the same typo twice in +a row; I'd love for read-passwd to offer a command to toggle the +password visibility. + +(I'm dismissing the "write it in the clear, then cut it and paste it" +solution, since I don't want to add the kill ring nor my desktop +environment's clipboard manager to the equation) + +I'm attaching a proof-of-concept. Additional considerations, in no +particular order: + +- For the binding, I wanted something easy to mash quickly, but + something more mnemonic might be in order? + +- Some applications out there show the password while the keyboard + shortcut (or the mouse button) remains pressed, and hide it back as + soon as it is released; I like the idea, but I have no idea whether + that's feasible with Emacs. + +- The (member …) check could be replaced with e.g. (get-char-property + (minibuffer-prompt-end) 'display); that's how I implemented it at + first. It would fail to turn hiding off when the user has not entered + anything though. + +- I don't know how much documentation this new command would warrant: + + - Should it be mentioned in read-passwd's docstring? C-u isn't now, + but it was way back when, before 2012-04-11 "* lisp/subr.el + (read-passwd): Use read-string." (088be6fbd2). + + - Should it be mentioned in the manual? delete-minibuffer-contents + is documented of course, but not under "(elisp) Reading a + Password". + + - a NEWS entry, maybe? AFAICT C-u was never announced there. + +(On a side-note, which might warrant another bug report, I wonder if +anything could be done to advertise read-passwd-map bindings more. +Sure, C-h b shows these bindings, but users have no reason to assume +that read-passwd has extra bindings in addition to regular minibuffer +ones, so why would they reach for C-h b?) + +Let me know if this sounds like something useful. If so, and if the +implementation is acceptable as-is, I'll work on documentation as soon +as I have a clearer idea of where I should add some (and whether some +documentation should be added for C-u as well). + +Thank you for your time. + +TODO:attach +**** "serving suggestion" patch +#+begin_src diff +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. + +#+end_src + *** imenu **** TODO Add grouping/sorting predicates to ~imenu~ completion So that ~imenu~ + ~icomplete-vertical-mode~ becomes a built-in, |
