I want to write a command which uses a prefix argument and reads some strings.

I know both parts individually:

(defun xtest(arg)
  (interactive "P")

reads the prefix arg.

(defun xtest(t1 t2)
  (interactive "stEins: \nstZwei: ")
  (message "%s %s %s" arg t1 t2))```

reads two strings. But when I put it together to use both:

(defun xtest(arg t1 t2)
  (interactive "PstEins: \nstZwei: ")

then I get on execution of the command the error "funcall-interactively: Wrong number of arguments".

How do I set up the function definition correctly?


Your string example shows that you already know how to separate multiple interactive arguments, by putting a newline between each one in the interactive spec.

So rather than:

(interactive "PstEins: \nstZwei: ")

You wanted:

(interactive "P\nstEins: \nstZwei: ")
  • Cool! I though the newline is just a divider for strings...
    – halloleo
    Jul 4 '19 at 5:01

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.