summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/lucid.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-01-30 00:34:44 +0000
committerRichard M. Stallman <rms@gnu.org>1995-01-30 00:34:44 +0000
commit3b787dc3332b381eef7a1918396d826f0b92878f (patch)
tree86729d838d90cb0ed45ffbfd59e401afa294bc3f /lisp/emacs-lisp/lucid.el
parent0fb5a19cb51008207cf11d3ce56fc22bcdf3a014 (diff)
downloademacs-3b787dc3332b381eef7a1918396d826f0b92878f.tar.gz
(read-number): New function.
Diffstat (limited to 'lisp/emacs-lisp/lucid.el')
-rw-r--r--lisp/emacs-lisp/lucid.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/lucid.el b/lisp/emacs-lisp/lucid.el
index c248348d954..d32ec9de75e 100644
--- a/lisp/emacs-lisp/lucid.el
+++ b/lisp/emacs-lisp/lucid.el
@@ -99,6 +99,27 @@ type that you get. That will work in both versions of Emacs."
(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)))