I want to make a function that calls run-at-time while setting its repeat to nil. The only thing I want to be asked to supply is the duration after which run-at-time should call a function.

Evaluating the following does what I want except for interactively asking me to input the duration: (run-at-time "120 min" nil 'my-custom-command)

None of my attempts to turn this into an interactive function have succeeded.

I have tried the following:

(defun foo ()
  (call-interactively 'run-at-time 'my-custom-command))

However, evaluating this causes me to be asked to input run-at-time's repeat variable and the function to be called, neither of which I wish to supply. Putting 'nil' after 'run-at-time' to bypass the request for the repeat interval returns a "too many arguments" error message.

I have experimented within the forms of run-at-time (run-at-time TIME REPEAT FUNCTION &rest ARGS) and call-interactively (call-interactively FUNCTION &optional RECORD-FLAG KEYS), but to no avail.

I have also tried using the "s" and "n" flags (perhaps incorrectly) in case they might allow a string or a number to supply run-at-time's duration, but though this results in a string or a number being asked for, supplying either returns an error message.

What would make this function work?

1 Answer 1


You don’t need or want call-interactively. You just want to supply enough information to interactive to prompt for a single value, and then call run-at-time with that value:

(defun foo (time)
  (interactive "sRun at time: ")
  (run-at-time time nil 'my-custom-command))
  • Thank you very much; that works perfectly.
    – Orixi
    Commented Mar 1, 2023 at 2:53
  • You’re welcome.
    – db48x
    Commented Mar 1, 2023 at 3:14

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.