aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorAndrea Corallo2021-02-17 22:26:28 +0100
committerAndrea Corallo2021-02-17 22:26:28 +0100
commitf92bb788a073c6b3ca7f188e0edea714598193fd (patch)
tree9bea27955098bfc33d0daaa345cfa3dca5b695fd /src/data.c
parent1fe5994bcb8b58012dbba0a5f7d03138c293286f (diff)
parent6735bb3d22dc64f3fe42e4a7f439ea9d62f75b5a (diff)
downloademacs-f92bb788a073c6b3ca7f188e0edea714598193fd.tar.gz
emacs-f92bb788a073c6b3ca7f188e0edea714598193fd.zip
Merge remote-tracking branch 'savannah/master' into native-comp
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c87
1 files changed, 82 insertions, 5 deletions
diff --git a/src/data.c b/src/data.c
index 2fa92fecc4f..5177a7cc649 100644
--- a/src/data.c
+++ b/src/data.c
@@ -978,7 +978,17 @@ Value, if non-nil, is a list (interactive SPEC). */)
978 else if (COMPILEDP (fun)) 978 else if (COMPILEDP (fun))
979 { 979 {
980 if (PVSIZE (fun) > COMPILED_INTERACTIVE) 980 if (PVSIZE (fun) > COMPILED_INTERACTIVE)
981 return list2 (Qinteractive, AREF (fun, COMPILED_INTERACTIVE)); 981 {
982 Lisp_Object form = AREF (fun, COMPILED_INTERACTIVE);
983 if (VECTORP (form))
984 /* The vector form is the new form, where the first
985 element is the interactive spec, and the second is the
986 command modes. */
987 return list2 (Qinteractive, AREF (form, 0));
988 else
989 /* Old form -- just the interactive spec. */
990 return list2 (Qinteractive, form);
991 }
982 } 992 }
983#ifdef HAVE_MODULES 993#ifdef HAVE_MODULES
984 else if (MODULE_FUNCTIONP (fun)) 994 else if (MODULE_FUNCTIONP (fun))
@@ -994,10 +1004,75 @@ Value, if non-nil, is a list (interactive SPEC). */)
994 else if (CONSP (fun)) 1004 else if (CONSP (fun))
995 { 1005 {
996 Lisp_Object funcar = XCAR (fun); 1006 Lisp_Object funcar = XCAR (fun);
997 if (EQ (funcar, Qclosure)) 1007 if (EQ (funcar, Qclosure)
998 return Fassq (Qinteractive, Fcdr (Fcdr (XCDR (fun)))); 1008 || EQ (funcar, Qlambda))
999 else if (EQ (funcar, Qlambda)) 1009 {
1000 return Fassq (Qinteractive, Fcdr (XCDR (fun))); 1010 Lisp_Object form = Fcdr (XCDR (fun));
1011 if (EQ (funcar, Qclosure))
1012 form = Fcdr (form);
1013 Lisp_Object spec = Fassq (Qinteractive, form);
1014 if (NILP (Fcdr (Fcdr (spec))))
1015 return spec;
1016 else
1017 return list2 (Qinteractive, Fcar (Fcdr (spec)));
1018 }
1019 }
1020 return Qnil;
1021}
1022
1023DEFUN ("command-modes", Fcommand_modes, Scommand_modes, 1, 1, 0,
1024 doc: /* Return the modes COMMAND is defined for.
1025If COMMAND is not a command, the return value is nil.
1026The value, if non-nil, is a list of mode name symbols. */)
1027 (Lisp_Object command)
1028{
1029 Lisp_Object fun = indirect_function (command); /* Check cycles. */
1030
1031 if (NILP (fun))
1032 return Qnil;
1033
1034 fun = command;
1035 while (SYMBOLP (fun))
1036 fun = Fsymbol_function (fun);
1037
1038 if (COMPILEDP (fun))
1039 {
1040 Lisp_Object form = AREF (fun, COMPILED_INTERACTIVE);
1041 if (VECTORP (form))
1042 /* New form -- the second element is the command modes. */
1043 return AREF (form, 1);
1044 else
1045 /* Old .elc file -- no command modes. */
1046 return Qnil;
1047 }
1048#ifdef HAVE_MODULES
1049 else if (MODULE_FUNCTIONP (fun))
1050 {
1051 Lisp_Object form
1052 = module_function_command_modes (XMODULE_FUNCTION (fun));
1053 if (! NILP (form))
1054 return form;
1055 }
1056#endif
1057 else if (AUTOLOADP (fun))
1058 {
1059 Lisp_Object modes = Fnth (make_int (3), fun);
1060 if (CONSP (modes))
1061 return modes;
1062 else
1063 return Qnil;
1064 }
1065 else if (CONSP (fun))
1066 {
1067 Lisp_Object funcar = XCAR (fun);
1068 if (EQ (funcar, Qclosure)
1069 || EQ (funcar, Qlambda))
1070 {
1071 Lisp_Object form = Fcdr (XCDR (fun));
1072 if (EQ (funcar, Qclosure))
1073 form = Fcdr (form);
1074 return Fcdr (Fcdr (Fassq (Qinteractive, form)));
1075 }
1001 } 1076 }
1002 return Qnil; 1077 return Qnil;
1003} 1078}
@@ -3983,6 +4058,7 @@ syms_of_data (void)
3983 4058
3984 defsubr (&Sindirect_variable); 4059 defsubr (&Sindirect_variable);
3985 defsubr (&Sinteractive_form); 4060 defsubr (&Sinteractive_form);
4061 defsubr (&Scommand_modes);
3986 defsubr (&Seq); 4062 defsubr (&Seq);
3987 defsubr (&Snull); 4063 defsubr (&Snull);
3988 defsubr (&Stype_of); 4064 defsubr (&Stype_of);
@@ -4113,6 +4189,7 @@ This variable cannot be set; trying to do so will signal an error. */);
4113 DEFSYM (Qunlet, "unlet"); 4189 DEFSYM (Qunlet, "unlet");
4114 DEFSYM (Qset, "set"); 4190 DEFSYM (Qset, "set");
4115 DEFSYM (Qset_default, "set-default"); 4191 DEFSYM (Qset_default, "set-default");
4192 DEFSYM (Qcommand_modes, "command-modes");
4116 defsubr (&Sadd_variable_watcher); 4193 defsubr (&Sadd_variable_watcher);
4117 defsubr (&Sremove_variable_watcher); 4194 defsubr (&Sremove_variable_watcher);
4118 defsubr (&Sget_variable_watchers); 4195 defsubr (&Sget_variable_watchers);