Go to the first, previous, next, last section, table of contents.


Interactive Declarations

When you define a command (using the defun special form in the same way you would define a function) the first of its body forms (after the optional documentation string) must be an interactive declaration.

This form looks like a call to the special form interactive, in actual fact this special form always returns nil and has no side-effects. The only effect of this form is to show the call-command function, which invokes commands, that this function definition is actually a command (i.e. it may be called interactively). The second element of the declaration form (after the interactive symbol) defines how the argument values applied to the command are computed.

The structure of an interactive declaration, then, is:

(interactive [calling-spec])

When a command is defined this is how it is defined with the interactive declaration:

(defun some-command (arg1)
  "Optional documentation string."
  (interactive ...)
  ...

The calling-spec form defines the argument values applied to the command when it is called interactively, it may be one of,

Some example interactive declarations,

;; No arguments, but the function may be called
;; as a command.
(interactive)

;; One argument, an existing buffer
(interactive "bBuffer to kill:")

;; If buffer isn't read-only, three arguments:
;; nil, a Lisp object and t.
(interactive "*\nxLisp form:\nt")


Go to the first, previous, next, last section, table of contents.