unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: 14254@debbugs.gnu.org
Subject: bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number to blame)
Date: Wed, 24 Apr 2013 23:57:18 +0300	[thread overview]
Message-ID: <87bo93abt8.fsf@mail.jurta.org> (raw)
In-Reply-To: <87ehe0ayf9.fsf@gmail.com> (Vitalie Spinu's message of "Wed, 24 Apr 2013 14:46:50 +0200")

> Try (read-number "Number: ") and insert some non-numeric junk. The
> expected behavior is for the read-number to recognize the faulty string
> and ask again, like documented in (elisp) Interactive Codes:
>
>    `n'
>         A number, read with the minibuffer.  If the input is not a number,
>         the user has to try again.

`call-interactively' doesn't use `read-number'.  It duplicates code
from `read-number' with a similar loop to re-read non-numbers.
However, it uses `read' instead of `string-to-number'.
So I agree it's better to revert the regression and to use `read'
in both `read-number' and `call-interactively' for consistency.

BTW, while comparing `read-number' and `call-interactively'
I noticed a difference between them.  Try to evaluate:

(defun read-num (n)
  (interactive "nNumber: ")
  (message "Number: %s" n))

then `M-x read-num RET non-number RET' clears the prompt to the empty string.

This is because `callint_message' is a global variable whose value gets
cleared while reading a number from the minibuffer recursively.
It should be re-initialized before re-reading the next number.

Since this bug is not a regression, I propose to install this patch to trunk:

=== modified file 'src/callint.c'
--- src/callint.c	2013-02-27 07:42:43 +0000
+++ src/callint.c	2013-04-24 20:54:52 +0000
@@ -692,6 +692,11 @@ (at your option) any later version.
 		  {
 		    message1 ("Please enter a number.");
 		    sit_for (make_number (1), 0, 0);
+		    /* Re-initialize callint_message for next iteration.  */
+		    if (strchr (SSDATA (visargs[0]), '%'))
+		      callint_message = Fformat (i, visargs);
+		    else
+		      callint_message = visargs[0];
 		  }
 		first = 0;
 





  parent reply	other threads:[~2013-04-24 20:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24 12:46 bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number to blame) Vitalie Spinu
2013-04-24 13:09 ` bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number toblame) Drew Adams
2013-04-24 14:21 ` bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number to blame) Andreas Schwab
2013-04-24 14:44   ` bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number toblame) Drew Adams
2013-04-24 14:48   ` bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number to blame) Vitalie Spinu
2013-04-24 15:13     ` bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number toblame) Drew Adams
2013-04-24 17:29 ` bug#14254: 24.3; read-number fails to recognize faulty numbers (string-to-number to blame) Glenn Morris
2013-04-24 20:57 ` Juri Linkov [this message]
2013-04-25  3:33   ` Stefan Monnier
2013-04-25 20:44     ` Juri Linkov
2013-04-26  1:46       ` Stefan Monnier
2013-05-07  8:42       ` Juri Linkov
2013-05-07 13:38         ` Stefan Monnier
2013-05-07 20:51           ` Juri Linkov
2013-05-07 21:31             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bo93abt8.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=14254@debbugs.gnu.org \
    --cc=spinuvit@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).