From d39109c3e111bf2403f6e636ff1273f2701683e7 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 6 Oct 2012 13:29:15 -0400 Subject: [PATCH] * lisp/subr.el (read-passwd-map): New var. (read-passwd): Use `read-string' again. * lisp/minibuffer.el (delete-minibuffer-contents): Make it interactive. --- lisp/ChangeLog | 6 ++++++ lisp/minibuffer.el | 1 + lisp/subr.el | 21 ++++++++++----------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6235f9f28ca..292a536f2c9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-10-06 Stefan Monnier + + * subr.el (read-passwd-map): New var. + (read-passwd): Use `read-string' again. + * minibuffer.el (delete-minibuffer-contents): Make it interactive. + 2012-10-06 Jambunathan K * register.el (append-to-register, prepend-to-register): diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index cf990019abc..a9be1749423 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -632,6 +632,7 @@ That is what completion commands operate on." (defun delete-minibuffer-contents () "Delete all user input in a minibuffer. If the current buffer is not a minibuffer, erase its entire contents." + (interactive) ;; We used to do `delete-field' here, but when file name shadowing ;; is on, the field doesn't cover the entire minibuffer contents. (delete-region (minibuffer-prompt-end) (point-max))) diff --git a/lisp/subr.el b/lisp/subr.el index e8eef541f27..e438a860cbc 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2143,6 +2143,13 @@ any other non-digit terminates the character code and is then used as input.")) (setq first nil)) code)) +(defconst read-passwd-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map minibuffer-local-map) + (define-key map "\C-u" #'delete-minibuffer-contents) ;bug#12570 + map) + "Keymap used while reading passwords.") + (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. @@ -2180,19 +2187,11 @@ by doing (clear-string STRING)." (setq minibuf (current-buffer)) ;; Turn off electricity. (set (make-local-variable 'post-self-insert-hook) nil) + (use-local-map read-passwd-map) (add-hook 'after-change-functions hide-chars-fun nil 'local)) (unwind-protect - (let ((enable-recursive-minibuffers t) - (map (make-sparse-keymap)) - result) - (set-keymap-parent map minibuffer-local-map) - (define-key map "\C-u" ; bug#12570 - (lambda () (interactive) (delete-minibuffer-contents))) - (setq result - ;; t = no history. - (read-from-minibuffer prompt nil map nil t default)) - (if (and (equal "" result) default) default - result)) + (let ((enable-recursive-minibuffers t)) + (read-string prompt nil t default)) ; t = "no history" (when (buffer-live-p minibuf) (with-current-buffer minibuf ;; Not sure why but it seems that there might be cases where the -- 2.11.4.GIT