# HG changeset patch # User Richard M. Stallman # Date 791426084 0 # Node ID 4d7bc901319af5584a81351d220b5f879ae8b811 # Parent 2a8f29cd9e9f9b448a0675c098602a6a453dc428 (read-number): New function. diff -r 2a8f29cd9e9f -r 4d7bc901319a lisp/emacs-lisp/lucid.el --- a/lisp/emacs-lisp/lucid.el Sun Jan 29 22:04:10 1995 +0000 +++ b/lisp/emacs-lisp/lucid.el Mon Jan 30 00:34:44 1995 +0000 @@ -99,6 +99,27 @@ (setq i (1- i)))))) (setq keymap (cdr keymap))))) +(defun read-number (prompt &optional integers-only) + "Read a number from the minibuffer. +Keep reentering the minibuffer until we get suitable input. +If optional argument INTEGERS-ONLY is non-nil, insist on an integer." + (interactive) + (let (success + (number nil) + (predicate (if integers-only 'integerp 'numberp))) + (while (not success) + (let ((input-string (read-string prompt))) + (condition-case () + (setq number (read input-string)) + (error)) + (if (funcall predicate number) + (setq success t) + (let ((cursor-in-echo-area t)) + (message "Please type %s" + (if integers-only "an integer" "a number")) + (sit-for 1))))) + number)) + (defun real-path-name (name &optional default) (file-truename (expand-file-name name default)))