1

How can I use prefix argument with list in the interactive clause? It is the more general way instead of Code Characters.

1 Answer 1

1

The question isn't clear. But I'm guessing you're asking how to pass the value of the prefix arg as an argument to a command, in an interactive spec that gets a list (not a string) argument.

As the doc tells you:

  • Use list to put things in a list.
  • Use variable current-prefix-arg to get the raw prefix-arg value.
  • Use (prefix-numeric-value current-prefix-arg) to get the numeric prefix-arg value.

Example:

(defun cmd (raw numeric)
  (interactive (list current-prefix-arg
                     (prefix-numeric-value current-prefix-arg)))
  (message "RAW: %S, NUMERIC: %S" raw numeric))

That's equivalent to this:

(defun cmd (raw numeric)
  (interactive "P\np")
  (message "RAW: %S, NUMERIC: %S" raw numeric))

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.