Function: define-prefix-command

define-prefix-command is a byte-compiled function defined in subr.el.gz.

Signature

(define-prefix-command COMMAND &optional MAPVAR NAME)

Documentation

Define COMMAND as a prefix command. COMMAND should be a symbol.

A new sparse keymap is stored as COMMAND's function definition and its value. This prepares COMMAND for use as a prefix key's binding. If a second optional argument MAPVAR is given, it should be a symbol. The map is then stored as MAPVAR's value instead of as COMMAND's value; but COMMAND is still defined as a function. The third optional argument NAME, if given, supplies a menu name string for the map. This is required to use the keymap as a menu. This function returns COMMAND.

View in manual

Probably introduced at or before Emacs version 20.4.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun define-prefix-command (command &optional mapvar name)
  "Define COMMAND as a prefix command.  COMMAND should be a symbol.
A new sparse keymap is stored as COMMAND's function definition and its
value.
This prepares COMMAND for use as a prefix key's binding.
If a second optional argument MAPVAR is given, it should be a symbol.
The map is then stored as MAPVAR's value instead of as COMMAND's
value; but COMMAND is still defined as a function.
The third optional argument NAME, if given, supplies a menu name
string for the map.  This is required to use the keymap as a menu.
This function returns COMMAND."
  (let ((map (make-sparse-keymap name)))
    (fset command map)
    (set (or mapvar command) map)
    command))