I know that C-u sends the prefix 4. Is there any way to make C-u <key> a special case of a command, while still allowing C-u 4 <key>?


Sure. Use the raw prefix argument instead:

(defun my-prefix-test (arg)
  (interactive "P")
   ((consp arg)   (message "Prefix argument"))
   ((numberp arg) (message "Numeric argument"))
   ((eq '- arg)   (message "Negative argument"))
   ((not arg)     (message "No argument"))))

As you can see, current-prefix-arg can be a list, a number, - or nil.

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.