0

Suppose I has text:

test hello

The cursor is after word test. I need to insert random number? Also I need to set range of random (e.g. from 0 to 1000)

The result maybe like this:

test100 hello
1
(random t) ; seed it randomly
(defun my-random-number-insert-at-point ()
"Insert at point a four-digit random number between 0000 to 1000."
(interactive)
(insert (number-to-string (random 100))))
  • 2
    Don't call (random t) since it should be unnecessary. Also, please indent your code properly so it's more readable. Also, you may like to check the consistency between your docstring and your code ;-) – Stefan Aug 26 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.