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 Answer 1

(defun my-random-number-insert-at-point ()
  "Insert a random number between 0 and 1000."
  (insert (number-to-string (random 1000))))
  • 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, 2019 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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