]> git.eshelyaron.com Git - emacs.git/commitdiff
* subr.el (read-passwd): Move to net/password.el.
authorSimon Josefsson <jas@extundo.com>
Mon, 25 Oct 2004 13:22:17 +0000 (13:22 +0000)
committerSimon Josefsson <jas@extundo.com>
Mon, 25 Oct 2004 13:22:17 +0000 (13:22 +0000)
* net/password.el (read-passwd): Add.  Autoload it.

lisp/ChangeLog
lisp/net/password.el
lisp/subr.el

index 21db50ad5645f70dd54932706a67db081df76311..789e675d1b4d35ea94850b0b2837c61a134ac834 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-25  Simon Josefsson  <jas@extundo.com>
+
+       * subr.el (read-passwd): Move to net/password.el.
+
+       * net/password.el (read-passwd): Add.  Autoload it.
+
 2004-10-25  Kai Grossjohann  <kai.grossjohann@gmx.net>
 
        * mouse-sel.el (mouse-sel-mode): Specify custom group.
index e8be612ecca21998665e1fe7fb6d672b519b1ca8..da009ed9ea02c8a8bb09aac95781a4f8952ec041 100644 (file)
@@ -122,6 +122,62 @@ seconds."
                 key))
   nil)
 
+;;;###autoload
+(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.
+The user ends with RET, LFD, or ESC.  DEL or C-h rubs out.  C-u kills line.
+C-g quits; if `inhibit-quit' was non-nil around this function,
+then it returns nil if the user types C-g.
+
+Once the caller uses the password, it can erase the password
+by doing (clear-string STRING)."
+  (with-local-quit
+    (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 ((pass nil)
+           (c 0)
+           (echo-keystrokes 0)
+           (cursor-in-echo-area t))
+       (while (progn (message "%s%s"
+                              prompt
+                              (make-string (length pass) ?.))
+                     (setq c (read-char-exclusive nil t))
+                     (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
+         (clear-this-command-keys)
+         (if (= c ?\C-u)
+             (progn
+               (and (arrayp pass) (clear-string pass))
+               (setq pass ""))
+           (if (and (/= c ?\b) (/= c ?\177))
+               (let* ((new-char (char-to-string c))
+                      (new-pass (concat pass new-char)))
+                 (and (arrayp pass) (clear-string pass))
+                 (clear-string new-char)
+                 (setq c ?\0)
+                 (setq pass new-pass))
+             (if (> (length pass) 0)
+                 (let ((new-pass (substring pass 0 -1)))
+                   (and (arrayp pass) (clear-string pass))
+                   (setq pass new-pass))))))
+       (message nil)
+       (or pass default "")))))
+
 (provide 'password)
 
 ;;; arch-tag: ab160494-16c8-4c68-a4a1-73eebf6686e5
index b137e7fdfd7f2c960697d57eafece81113ead49d..ee0823c89e6f41a02c18404c82c305cc2012a8e9 100644 (file)
@@ -1211,61 +1211,6 @@ any other non-digit terminates the character code and is then used as input."))
       (setq first nil))
     code))
 
-(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.
-The user ends with RET, LFD, or ESC.  DEL or C-h rubs out.  C-u kills line.
-C-g quits; if `inhibit-quit' was non-nil around this function,
-then it returns nil if the user types C-g.
-
-Once the caller uses the password, it can erase the password
-by doing (clear-string STRING)."
-  (with-local-quit
-    (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 ((pass nil)
-           (c 0)
-           (echo-keystrokes 0)
-           (cursor-in-echo-area t))
-       (while (progn (message "%s%s"
-                              prompt
-                              (make-string (length pass) ?.))
-                     (setq c (read-char-exclusive nil t))
-                     (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
-         (clear-this-command-keys)
-         (if (= c ?\C-u)
-             (progn
-               (and (arrayp pass) (clear-string pass))
-               (setq pass ""))
-           (if (and (/= c ?\b) (/= c ?\177))
-               (let* ((new-char (char-to-string c))
-                      (new-pass (concat pass new-char)))
-                 (and (arrayp pass) (clear-string pass))
-                 (clear-string new-char)
-                 (setq c ?\0)
-                 (setq pass new-pass))
-             (if (> (length pass) 0)
-                 (let ((new-pass (substring pass 0 -1)))
-                   (and (arrayp pass) (clear-string pass))
-                   (setq pass new-pass))))))
-       (message nil)
-       (or pass default "")))))
-
 ;; This should be used by `call-interactively' for `n' specs.
 (defun read-number (prompt &optional default)
   (let ((n nil))