Previous: , Up: Commands   [Contents][Index]


17.5 Invoking Commands

When a command is to be invoked, the call-command function is used. This builds a list of argument values to apply to the command (using its interactive declaration) then calls the command.

Function: call-command command #!optional prefix-arg

This function calls the command command interactively. See the documentation of commandp above for what constitutes a command.

If the prefix-argument is non-nil it defines the value of the current-prefix-arg variable for this command, normally the value of this variable would be taken from the global prefix-arg variable.

There is a corresponding call-command command that prompts for a command to execute.

Function: apply-command name &rest args

Call the function underlying the command name, passing in args as the arguments. This is useful for calling a command in a non-interactive context.

Variable: current-prefix-arg

When invoking an interactive command, this is set to the current prefix argument.

Variable: this-command

The command currently being called. The value is only set during command call, and nil anytime else.

Variable: last-command

The command previously called, or ‘nil’ if there is no such command.

See Command Hooks, for hooks run before and after commands.