[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#14254: 24.3; read-number fails to recognize faulty numbers (string-t
From: |
Juri Linkov |
Subject: |
bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number to blame) |
Date: |
Thu, 25 Apr 2013 23:44:45 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) |
>> `call-interactively' doesn't use `read-number'. It duplicates code
>> from `read-number' with a similar loop to re-read non-numbers.
>
> Could you try and see if/how the C code could be changed to just call
> the Elisp function?
I tried and see no problems with this patch:
=== modified file 'src/callint.c'
--- src/callint.c 2013-02-27 07:42:43 +0000
+++ src/callint.c 2013-04-25 20:41:12 +0000
@@ -34,6 +34,7 @@ (at your option) any later version.
static Lisp_Object Qenable_recursive_minibuffers;
static Lisp_Object Qhandle_shift_selection;
+static Lisp_Object Qread_number;
Lisp_Object Qmouse_leave_buffer_hook;
@@ -683,29 +684,7 @@ (at your option) any later version.
if (!NILP (prefix_arg))
goto have_prefix_arg;
case 'n': /* Read number from minibuffer. */
- {
- bool first = 1;
- do
- {
- Lisp_Object str;
- if (! first)
- {
- message1 ("Please enter a number.");
- sit_for (make_number (1), 0, 0);
- }
- first = 0;
-
- str = Fread_from_minibuffer (callint_message,
- Qnil, Qnil, Qnil, Qnil, Qnil,
- Qnil);
- if (! STRINGP (str) || SCHARS (str) == 0)
- args[i] = Qnil;
- else
- args[i] = Fread (str);
- }
- while (! NUMBERP (args[i]));
- }
- visargs[i] = args[i];
+ args[i] = call1 (Qread_number, callint_message);
break;
case 'P': /* Prefix arg in raw form. Does no I/O. */
@@ -903,6 +882,7 @@ (at your option) any later version.
DEFSYM (Qminus, "-");
DEFSYM (Qplus, "+");
DEFSYM (Qhandle_shift_selection, "handle-shift-selection");
+ DEFSYM (Qread_number, "read-number");
DEFSYM (Qcall_interactively, "call-interactively");
DEFSYM (Qcommand_debug_status, "command-debug-status");
DEFSYM (Qenable_recursive_minibuffers, "enable-recursive-minibuffers");
=== modified file 'lisp/subr.el'
--- lisp/subr.el 2013-04-18 00:12:33 +0000
+++ lisp/subr.el 2013-04-25 20:41:35 +0000
@@ -2200,11 +2200,11 @@ (defun read-passwd (prompt &optional con
;; And of course, don't keep the sensitive data around.
(erase-buffer))))))))
-;; This should be used by `call-interactively' for `n' specs.
(defun read-number (prompt &optional default)
"Read a numeric value in the minibuffer, prompting with PROMPT.
DEFAULT specifies a default value to return if the user just types RET.
-The value of DEFAULT is inserted into PROMPT."
+The value of DEFAULT is inserted into PROMPT.
+This function is used by the `interactive' code letter `n'."
(let ((n nil)
(default1 (if (consp default) (car default) default)))
(when default1