There's no convenient interface for that.
For some simple operations, you can make use of two facts:
- Using
C-u
with no number gives you powers of 4. C-u C-n
moves 4 lines down, C-u c-u C-n
moves 16 lines down, etc. (There are rare exceptions with commands that treat the no-number case differently.)
- The prefix argument is usually a repeat count, so you can do additions by repeating the command.
If you want a complex calculation, you can use M-:
(eval-expression
) to call the command. First, if you need to, look up the command name by pressing C-h c
(or f1 c
) and the keyboard shortcut you meant to invoke. To copy-paste the command name, switch to the *Messages*
buffer, or alternatively use C-h k
rather than C-h c
and switch to the *Help*
buffer. Then invoke eval-expression
with M-:
and specify M-: (the-command-name (the-argument-expression))
. This assumes that the prefix argument is the sole argument to the function, which is often but not always the case: check the function's documentation.
Another approach, which works regardless of how the command consumes its prefix argument, is to set prefix-arg
explicitly. invoke eval-expression
with M-:
and specify M-: (setq prefix-arg (the-argument-expression))
, then immediately invoke the command. Under the hood, commands read the prefix argument from current-prefix-arg
. Between each interactive command, Emacs sets current-prefix-arg
to the value of prefix-arg
and resets prefix-arg
to nil
.