I am trying to make a function that prompt the user to enter a number during a while (so the number of time the prompt appears will change, that is why I don't want to use something like (interactive "n Enter a Number : ")). My code is like this:
(setq nb_str (read-string "Enter a Number:"))
(setq nb (string-to-number nb_str))
(insert nb)
When I want to insert the variable nb, instead of having my number inserted, I get some weird output from string-to-number function like ^C (if I typed 3) or ^D (if I typed 4) or ^E (if I typed 5). I need that value as number for after. How can I do this?
insert inserts strings or characters, and a number in Emacs Lisp is a character (if it is in the right range), so 3 is inserted as the 3rd ASCII char, ^C.
You need to either pass nb-str to insert, or use number-to-string:
(insert (number-to-string nb))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With