Mercurial > emacs
comparison src/eval.c @ 82113:76ba0f031e99
(Fcommandp): Pay attention to the `interactive-form' property.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 25 Jul 2007 21:03:31 +0000 |
parents | 298a134523a5 |
children | b98604865ea0 |
comparison
equal
deleted
inserted
replaced
82112:dd8905ab6eaa | 82113:76ba0f031e99 |
---|---|
2038 (function, for_call_interactively) | 2038 (function, for_call_interactively) |
2039 Lisp_Object function, for_call_interactively; | 2039 Lisp_Object function, for_call_interactively; |
2040 { | 2040 { |
2041 register Lisp_Object fun; | 2041 register Lisp_Object fun; |
2042 register Lisp_Object funcar; | 2042 register Lisp_Object funcar; |
2043 Lisp_Object if_prop = Qnil; | |
2043 | 2044 |
2044 fun = function; | 2045 fun = function; |
2045 | 2046 |
2046 fun = indirect_function (fun); | 2047 fun = indirect_function (fun); /* Check cycles. */ |
2047 if (EQ (fun, Qunbound)) | 2048 if (NILP (fun) || EQ (fun, Qunbound)) |
2048 return Qnil; | 2049 return Qnil; |
2050 | |
2051 /* Check an `interactive-form' property if present, analogous to the | |
2052 function-documentation property. */ | |
2053 fun = function; | |
2054 while (SYMBOLP (fun)) | |
2055 { | |
2056 Lisp_Object tmp = Fget (fun, intern ("interactive-form")); | |
2057 if (!NILP (tmp)) | |
2058 if_prop = Qt; | |
2059 fun = Fsymbol_function (fun); | |
2060 } | |
2049 | 2061 |
2050 /* Emacs primitives are interactive if their DEFUN specifies an | 2062 /* Emacs primitives are interactive if their DEFUN specifies an |
2051 interactive spec. */ | 2063 interactive spec. */ |
2052 if (SUBRP (fun)) | 2064 if (SUBRP (fun)) |
2053 { | 2065 return XSUBR (fun)->prompt ? Qt : if_prop; |
2054 if (XSUBR (fun)->prompt) | |
2055 return Qt; | |
2056 else | |
2057 return Qnil; | |
2058 } | |
2059 | 2066 |
2060 /* Bytecode objects are interactive if they are long enough to | 2067 /* Bytecode objects are interactive if they are long enough to |
2061 have an element whose index is COMPILED_INTERACTIVE, which is | 2068 have an element whose index is COMPILED_INTERACTIVE, which is |
2062 where the interactive spec is stored. */ | 2069 where the interactive spec is stored. */ |
2063 else if (COMPILEDP (fun)) | 2070 else if (COMPILEDP (fun)) |
2064 return ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE | 2071 return ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE |
2065 ? Qt : Qnil); | 2072 ? Qt : if_prop); |
2066 | 2073 |
2067 /* Strings and vectors are keyboard macros. */ | 2074 /* Strings and vectors are keyboard macros. */ |
2068 if (NILP (for_call_interactively) && (STRINGP (fun) || VECTORP (fun))) | 2075 if (STRINGP (fun) || VECTORP (fun)) |
2069 return Qt; | 2076 return NILP (for_call_interactively) ? Qt : Qnil; |
2070 | 2077 |
2071 /* Lists may represent commands. */ | 2078 /* Lists may represent commands. */ |
2072 if (!CONSP (fun)) | 2079 if (!CONSP (fun)) |
2073 return Qnil; | 2080 return Qnil; |
2074 funcar = XCAR (fun); | 2081 funcar = XCAR (fun); |
2075 if (EQ (funcar, Qlambda)) | 2082 if (EQ (funcar, Qlambda)) |
2076 return Fassq (Qinteractive, Fcdr (XCDR (fun))); | 2083 return !NILP (Fassq (Qinteractive, Fcdr (XCDR (fun)))) ? Qt : if_prop; |
2077 if (EQ (funcar, Qautoload)) | 2084 if (EQ (funcar, Qautoload)) |
2078 return Fcar (Fcdr (Fcdr (XCDR (fun)))); | 2085 return !NILP (Fcar (Fcdr (Fcdr (XCDR (fun))))) ? Qt : if_prop; |
2079 else | 2086 else |
2080 return Qnil; | 2087 return Qnil; |
2081 } | 2088 } |
2082 | 2089 |
2083 /* ARGSUSED */ | 2090 /* ARGSUSED */ |