help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read an integer from the minibuffer


From: Jean Louis
Subject: Re: How to read an integer from the minibuffer
Date: Sat, 13 Nov 2021 09:46:10 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* Emanuel Berg via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> [2021-11-13 00:21]:
> tomas wrote:
> 
> > Why not simply numberp?
> >
> >   (and (numberp s) (string-to-number s))
> 
> King :)

(let ((s " 123"))
(and (numberp s) (string-to-number s))) ⇒ nil

I do not see how it helps in my use case as I want to ensure that
number in the string is actual number and nothing else.

Example is here:

(let ((s " 123n"))
  (string-to-number "123n")) ⇒ 123

I don't need such cases where I get result "123" from " 123n"
as " 123n" is not number for my use case and I would not like
converting it to close match. 

What is my actual use case? In the Dynamic Knowledge Repository
each elementary object may have its ID, it is usually integer. 

A cursor may be positioned on the word that could be number, but
should not be number with some letters. It should act on
integers, then if search key is pressed it would quickly find the
object. Otherwise it could ask for the query to find the object.

The database will search for any combination of "123n" as this
combination could be part of the email address, but it will
rather start searching for the object ID 123 if there is no "n"
in the combination of letters, it will prefer ID numbers then.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]