Function: command-modes
command-modes is a function defined in data.c.
Signature
(command-modes COMMAND)
Documentation
Return the modes COMMAND is defined for.
If COMMAND is not a command, the return value is nil. The value, if non-nil, is a list of mode name symbols.
Source Code
// Defined in /usr/src/emacs/src/data.c
{
Lisp_Object fun = indirect_function (command); /* Check cycles. */
if (NILP (fun))
return Qnil;
/* Use a `command-modes' property if present, analogous to the
function-documentation property. */
fun = command;
while (SYMBOLP (fun))
{
Lisp_Object modes = Fget (fun, Qcommand_modes);
if (!NILP (modes))
return modes;
else
fun = Fsymbol_function (fun);
}
if (SUBRP (fun))
{
return XSUBR (fun)->command_modes;
}
else if (COMPILEDP (fun))
{
if (PVSIZE (fun) <= COMPILED_INTERACTIVE)
return Qnil;
Lisp_Object form = AREF (fun, COMPILED_INTERACTIVE);
if (VECTORP (form))
/* New form -- the second element is the command modes. */
return AREF (form, 1);
else
/* Old .elc file -- no command modes. */
return Qnil;
}
#ifdef HAVE_MODULES
else if (MODULE_FUNCTIONP (fun))
{
Lisp_Object form
= module_function_command_modes (XMODULE_FUNCTION (fun));
if (! NILP (form))
return form;
}
#endif
else if (AUTOLOADP (fun))
{
Lisp_Object modes = Fnth (make_int (3), fun);
if (CONSP (modes))
return modes;
else
return Qnil;
}
else if (CONSP (fun))
{
Lisp_Object funcar = XCAR (fun);
if (EQ (funcar, Qclosure)
|| EQ (funcar, Qlambda))
{
Lisp_Object form = Fcdr (XCDR (fun));
if (EQ (funcar, Qclosure))
form = Fcdr (form);
return Fcdr (Fcdr (Fassq (Qinteractive, form)));
}
}
return Qnil;
}