What does (interactive) mean in an Emacs Lisp function

emacslisp

Emacs Lisp function often start like this:

(lambda () (interactive) ...

What does "(interactive)" do?

Best Answer

Just to clarify (it is in the quoted docs that Charlie cites) (interactive) is not just for key-bound functions, but for any function. Without (interactive), it can only be called programmatically, not from M-x (or via key-binding).

EDIT: Note that just adding "(interactive)" to a function won't necessarily make it work that way, either -- there could be many reasons functions are not interactive. Scoping, dependencies, parameters, etc.