[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9751: 23.3; Alternative Keyboard Feature/Bug
From: |
Stefan Monnier |
Subject: |
bug#9751: 23.3; Alternative Keyboard Feature/Bug |
Date: |
Wed, 11 Jan 2012 21:48:24 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
> This problem can be fixed with the following patch:
> === modified file 'lisp/subr.el'
> --- lisp/subr.el 2012-01-07 19:50:04 +0000
> +++ lisp/subr.el 2012-01-12 00:34:03 +0000
> @@ -2092,6 +2092,7 @@ (defun read-passwd (prompt &optional con
> (echo-keystrokes 0)
> (cursor-in-echo-area t)
> (message-log-max nil)
> + (local-function-key-map nil)
> (stop-keys (list 'return ?\r ?\n ?\e))
> (rubout-keys (list 'backspace ?\b ?\177)))
> (add-text-properties 0 (length prompt)
I'd rather not go down that path (it might fix this problem but would
introduce others).
I wrote it too late for 24.1, but I'm using now a version of read-passwd
that uses read-string, so function-key-map (as well as all your familiar
key bindings) works just like for normal text. I think it will fix this
problem in a more satisfactory way (but it's too late for 24.1).
Stefan
(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.
Optional DEFAULT is a default password to use instead of empty input.
This function echoes `.' for each character that the user types.
Once the caller uses the password, it can erase the password
by doing (clear-string STRING)."
(if confirm
(let (success)
(while (not success)
(let ((first (read-passwd prompt nil default))
(second (read-passwd "Confirm password: " nil default)))
(if (equal first second)
(progn
(and (arrayp second) (clear-string second))
(setq success first))
(and (arrayp first) (clear-string first))
(and (arrayp second) (clear-string second))
(message "Password not repeated accurately; please start over")
(sit-for 1))))
success)
(let (minibuf)
(minibuffer-with-setup-hook
(lambda ()
(setq minibuf (current-buffer))
;; Turn off electricity.
(set (make-local-variable 'post-self-insert-hook) nil)
(add-hook 'after-change-functions
(lambda (beg end len)
(clear-this-command-keys)
(setq beg (min end (max (minibuffer-prompt-end)
beg)))
(dotimes (i (- end beg))
(put-text-property (+ i beg) (+ 1 i beg)
'display (string ?.))))
nil t))
(unwind-protect
(read-string prompt nil
(let ((sym (make-symbol "forget-history")))
(set sym nil)
sym)
default)
(when (buffer-live-p minibuf)
(with-current-buffer minibuf (erase-buffer))))))))