aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-11-16 20:02:49 +0000
committerChong Yidong2008-11-16 20:02:49 +0000
commit08640de52c5c5add4039f0b7334eaba967d66055 (patch)
tree40028c8bc674e71f281cfb7e4b501c51626809bc
parentf5f895cf8e2fcce0b591092ec5804f9ccbe000e9 (diff)
downloademacs-08640de52c5c5add4039f0b7334eaba967d66055.tar.gz
emacs-08640de52c5c5add4039f0b7334eaba967d66055.zip
(read-passwd): Yank current kill if the user enters C-y.
-rw-r--r--lisp/subr.el45
1 files changed, 29 insertions, 16 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index ccb235b5c4d..fac523d4a7f 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1781,7 +1781,9 @@ If optional CONFIRM is non-nil, read the password twice to make sure.
1781Optional DEFAULT is a default password to use instead of empty input. 1781Optional DEFAULT is a default password to use instead of empty input.
1782 1782
1783This function echoes `.' for each character that the user types. 1783This function echoes `.' for each character that the user types.
1784The user ends with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. 1784
1785The user ends with RET, LFD, or ESC. DEL or C-h rubs out.
1786C-y yanks the current kill. C-u kills line.
1785C-g quits; if `inhibit-quit' was non-nil around this function, 1787C-g quits; if `inhibit-quit' was non-nil around this function,
1786then it returns nil if the user types C-g, but quit-flag remains set. 1788then it returns nil if the user types C-g, but quit-flag remains set.
1787 1789
@@ -1818,21 +1820,32 @@ by doing (clear-string STRING)."
1818 (setq c (read-char-exclusive nil t)) 1820 (setq c (read-char-exclusive nil t))
1819 (and (/= c ?\r) (/= c ?\n) (/= c ?\e))) 1821 (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
1820 (clear-this-command-keys) 1822 (clear-this-command-keys)
1821 (if (= c ?\C-u) 1823 (cond ((= c ?\C-u) ; kill line
1822 (progn 1824 (and (arrayp pass) (clear-string pass))
1823 (and (arrayp pass) (clear-string pass)) 1825 (setq pass ""))
1824 (setq pass "")) 1826 ((= c ?\C-y) ; yank
1825 (if (and (/= c ?\b) (/= c ?\177)) 1827 (let* ((str (condition-case nil
1826 (let* ((new-char (char-to-string c)) 1828 (current-kill 0)
1827 (new-pass (concat pass new-char))) 1829 (error nil)))
1828 (and (arrayp pass) (clear-string pass)) 1830 new-pass)
1829 (clear-string new-char) 1831 (when str
1830 (setq c ?\0) 1832 (setq new-pass
1831 (setq pass new-pass)) 1833 (concat pass
1832 (if (> (length pass) 0) 1834 (substring-no-properties str)))
1833 (let ((new-pass (substring pass 0 -1))) 1835 (and (arrayp pass) (clear-string pass))
1834 (and (arrayp pass) (clear-string pass)) 1836 (setq c ?\0)
1835 (setq pass new-pass)))))) 1837 (setq pass new-pass))))
1838 ((and (/= c ?\b) (/= c ?\177)) ; insert char
1839 (let* ((new-char (char-to-string c))
1840 (new-pass (concat pass new-char)))
1841 (and (arrayp pass) (clear-string pass))
1842 (clear-string new-char)
1843 (setq c ?\0)
1844 (setq pass new-pass)))
1845 ((> (length pass) 0) ; rubout
1846 (let ((new-pass (substring pass 0 -1)))
1847 (and (arrayp pass) (clear-string pass))
1848 (setq pass new-pass)))))
1836 (message nil) 1849 (message nil)
1837 (or pass default ""))))) 1850 (or pass default "")))))
1838 1851