Mercurial > emacs
changeset 10589:4d7bc901319a
(read-number): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 30 Jan 1995 00:34:44 +0000 |
parents | 2a8f29cd9e9f |
children | 9f68d8d6357b |
files | lisp/emacs-lisp/lucid.el |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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)))