Mercurial > emacs
comparison lisp/emacs-lisp/lucid.el @ 10589:4d7bc901319a
(read-number): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 30 Jan 1995 00:34:44 +0000 |
parents | 8deb32278622 |
children | 3cda29fdf5f6 |
comparison
equal
deleted
inserted
replaced
10588:2a8f29cd9e9f | 10589:4d7bc901319a |
---|---|
96 (vector (car keymap))) | 96 (vector (car keymap))) |
97 (while (>= i 0) | 97 (while (>= i 0) |
98 (funcall function i (aref vector i)) | 98 (funcall function i (aref vector i)) |
99 (setq i (1- i)))))) | 99 (setq i (1- i)))))) |
100 (setq keymap (cdr keymap))))) | 100 (setq keymap (cdr keymap))))) |
101 | |
102 (defun read-number (prompt &optional integers-only) | |
103 "Read a number from the minibuffer. | |
104 Keep reentering the minibuffer until we get suitable input. | |
105 If optional argument INTEGERS-ONLY is non-nil, insist on an integer." | |
106 (interactive) | |
107 (let (success | |
108 (number nil) | |
109 (predicate (if integers-only 'integerp 'numberp))) | |
110 (while (not success) | |
111 (let ((input-string (read-string prompt))) | |
112 (condition-case () | |
113 (setq number (read input-string)) | |
114 (error)) | |
115 (if (funcall predicate number) | |
116 (setq success t) | |
117 (let ((cursor-in-echo-area t)) | |
118 (message "Please type %s" | |
119 (if integers-only "an integer" "a number")) | |
120 (sit-for 1))))) | |
121 number)) | |
101 | 122 |
102 (defun real-path-name (name &optional default) | 123 (defun real-path-name (name &optional default) |
103 (file-truename (expand-file-name name default))) | 124 (file-truename (expand-file-name name default))) |
104 | 125 |
105 ;; It's not clear what to return if the mouse is not in FRAME. | 126 ;; It's not clear what to return if the mouse is not in FRAME. |