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


25.2.1 Using interactive

This section describes how to write the interactive form that makes a Lisp function an interactively-callable command.

Special Form: interactive arg-descriptor

This special form declares that the function in which it appears is a command, and that it may therefore be called interactively (via M-x or by entering a key sequence bound to it). The argument arg-descriptor declares how to compute the arguments to the command when the command is called interactively.

A command may be called from Lisp programs like any other function, but then the caller supplies the arguments and arg-descriptor has no effect.

The interactive form has its effect because the command loop (actually, its subroutine call-interactively) scans through the function definition looking for it, before calling the function. Once the function is called, all its body forms including the interactive form are executed, but at this time interactive simply returns nil without even evaluating its argument.

There are three possibilities for the argument arg-descriptor:

Function: function-interactive function

This function retrieves the interactive specification of function, which may be any funcallable object. The specification will be returned as the list of the symbol interactive and the specs. If function is not interactive, nil will be returned.


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