1

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
2
(defun my-random-number-insert-at-point ()
  "Insert a random number between 0 and 1000."
  (interactive)
  (insert (number-to-string (random 1000))))
| improve this answer | |
  • 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 '19 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.