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: Gregory Heytings
Subject: Re: How to read an integer from the minibuffer
Date: Fri, 12 Nov 2021 00:37:01 +0000



Rather, I meant show how to use the second solution to solve
the OPs example, i.e. to read an integer and only an integer.


Just use

(restricted-read-from-minibuffer "Integer? " "^[0-9][0-9]*$")

instead of

(restricted-read-from-minibuffer "Integer? " "^[0-9][0-9]*$" "0123456789")


I get if: Wrong number of arguments: string-match, 4


The fourth argument is new in Emacs 29, indeed.

(BTW, it seems that there's no way in Elisp to "expand" a regexp charset, e.g. "[0-9]" into "0123456789". That would make the ALLOWED-CHARS argument easier to type in.)

There is such a package, xr - the reverse of rx, LOL :)

 https://elpa.gnu.org/packages/xr.html


Apparently it doesn't do what I want here, namely converting "[0-9]" into "0123456789", "[0-9a-f]" into "0123456789abcdef", and so forth.



reply via email to

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