0

Something like the example below, which I want to test whether you are eligible to enter a number before you actually enter this number

(defun foo (x)
  (cond (condition (progn (interactive "nEnter your number: ") ...))
        (t (message "You cannot enter a number right now!"))))
  • You can pass an expression that evaluates to the list of arguments to interactive. – DoMiNeLa10 Feb 7 at 16:31
0

You want something like this, as suggested by @DoMiNeLa10.

(defun foo(x)
  (interactive (list (if condition
             (read-number "Enter your number: ")
               (error"You cannot enter a number right now!"))))
  (message "%s" x))
  • Perfect, an example is exactly what`s needed for a beginner like me! Thank you! – Matthew Zeng Feb 7 at 20:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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