Node: Invoking Commands, Next: , Previous: Operations on Commands, Up: Commands



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.

call-command command &optional prefix-arg Function
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.

apply-command name &rest args Function
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.

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

this-command Variable
The command currently being called, or nil if no command is being called.

last-command Variable
The command previously called, or nil if there is no such command.

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