Mercurial > hg > xemacs-beta
comparison src/eval.c @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | a4f53d9b3154 |
children | 8626e4521993 |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
1069 void.) | 1069 void.) |
1070 If SYMBOL is buffer-local, its default value is what is set; | 1070 If SYMBOL is buffer-local, its default value is what is set; |
1071 buffer-local values are not affected. | 1071 buffer-local values are not affected. |
1072 INITVALUE and DOCSTRING are optional. | 1072 INITVALUE and DOCSTRING are optional. |
1073 If DOCSTRING starts with *, this variable is identified as a user option. | 1073 If DOCSTRING starts with *, this variable is identified as a user option. |
1074 This means that M-x set-variable recognizes it. | 1074 This means that M-x set-variable and M-x edit-options recognize it. |
1075 If INITVALUE is missing, SYMBOL's value is not set. | 1075 If INITVALUE is missing, SYMBOL's value is not set. |
1076 | 1076 |
1077 In lisp-interaction-mode defvar is treated as defconst. | 1077 In lisp-interaction-mode defvar is treated as defconst. |
1078 */ | 1078 */ |
1079 (args)) | 1079 (args)) |
1120 Always sets the value of SYMBOL to the result of evalling INITVALUE. | 1120 Always sets the value of SYMBOL to the result of evalling INITVALUE. |
1121 If SYMBOL is buffer-local, its default value is what is set; | 1121 If SYMBOL is buffer-local, its default value is what is set; |
1122 buffer-local values are not affected. | 1122 buffer-local values are not affected. |
1123 DOCSTRING is optional. | 1123 DOCSTRING is optional. |
1124 If DOCSTRING starts with *, this variable is identified as a user option. | 1124 If DOCSTRING starts with *, this variable is identified as a user option. |
1125 This means that M-x set-variable recognizes it. | 1125 This means that M-x set-variable and M-x edit-options recognize it. |
1126 | 1126 |
1127 Note: do not use `defconst' for user options in libraries that are not | 1127 Note: do not use `defconst' for user options in libraries that are not |
1128 normally loaded, since it is useful for users to be able to specify | 1128 normally loaded, since it is useful for users to be able to specify |
1129 their own values for such variables before loading the library. | 1129 their own values for such variables before loading the library. |
1130 Since `defconst' unconditionally assigns the variable, | 1130 Since `defconst' unconditionally assigns the variable, |
1191 Return result of expanding macros at top level of FORM. | 1191 Return result of expanding macros at top level of FORM. |
1192 If FORM is not a macro call, it is returned unchanged. | 1192 If FORM is not a macro call, it is returned unchanged. |
1193 Otherwise, the macro is expanded and the expansion is considered | 1193 Otherwise, the macro is expanded and the expansion is considered |
1194 in place of FORM. When a non-macro-call results, it is returned. | 1194 in place of FORM. When a non-macro-call results, it is returned. |
1195 | 1195 |
1196 The second optional arg ENVIRONMENT specifies an environment of macro | 1196 The second optional arg ENVIRONMENT species an environment of macro |
1197 definitions to shadow the loaded ones for use in file byte-compilation. | 1197 definitions to shadow the loaded ones for use in file byte-compilation. |
1198 */ | 1198 */ |
1199 (form, environment)) | 1199 (form, env)) |
1200 { | 1200 { |
1201 /* This function can GC */ | 1201 /* This function can GC */ |
1202 /* With cleanups from Hallvard Furuseth. */ | 1202 /* With cleanups from Hallvard Furuseth. */ |
1203 REGISTER Lisp_Object expander, sym, def, tem; | 1203 REGISTER Lisp_Object expander, sym, def, tem; |
1204 | 1204 |
1215 until we get a symbol that is not an alias. */ | 1215 until we get a symbol that is not an alias. */ |
1216 while (SYMBOLP (def)) | 1216 while (SYMBOLP (def)) |
1217 { | 1217 { |
1218 QUIT; | 1218 QUIT; |
1219 sym = def; | 1219 sym = def; |
1220 tem = Fassq (sym, environment); | 1220 tem = Fassq (sym, env); |
1221 if (NILP (tem)) | 1221 if (NILP (tem)) |
1222 { | 1222 { |
1223 def = XSYMBOL (sym)->function; | 1223 def = XSYMBOL (sym)->function; |
1224 if (!UNBOUNDP (def)) | 1224 if (!UNBOUNDP (def)) |
1225 continue; | 1225 continue; |
1226 } | 1226 } |
1227 break; | 1227 break; |
1228 } | 1228 } |
1229 /* Right now TEM is the result from SYM in ENVIRONMENT, | 1229 /* Right now TEM is the result from SYM in ENV, |
1230 and if TEM is nil then DEF is SYM's function definition. */ | 1230 and if TEM is nil then DEF is SYM's function definition. */ |
1231 if (NILP (tem)) | 1231 if (NILP (tem)) |
1232 { | 1232 { |
1233 /* SYM is not mentioned in ENVIRONMENT. | 1233 /* SYM is not mentioned in ENV. |
1234 Look at its function definition. */ | 1234 Look at its function definition. */ |
1235 if (UNBOUNDP (def) | 1235 if (UNBOUNDP (def) |
1236 || !CONSP (def)) | 1236 || !CONSP (def)) |
1237 /* Not defined or definition not suitable */ | 1237 /* Not defined or definition not suitable */ |
1238 break; | 1238 break; |
3273 function = XCDR (function); | 3273 function = XCDR (function); |
3274 goto retry; | 3274 goto retry; |
3275 } | 3275 } |
3276 if (EQ (funcar, Qautoload)) | 3276 if (EQ (funcar, Qautoload)) |
3277 { | 3277 { |
3278 struct gcpro gcpro1; | |
3279 | |
3280 GCPRO1 (function); | |
3281 do_autoload (function, orig_function); | 3278 do_autoload (function, orig_function); |
3282 UNGCPRO; | |
3283 function = orig_function; | |
3284 goto retry; | 3279 goto retry; |
3285 } | 3280 } |
3286 if (EQ (funcar, Qlambda)) | 3281 if (EQ (funcar, Qlambda)) |
3287 arglist = Fcar (XCDR (function)); | 3282 arglist = Fcar (XCDR (function)); |
3288 else | 3283 else |
3341 function = XCDR (function); | 3336 function = XCDR (function); |
3342 goto retry; | 3337 goto retry; |
3343 } | 3338 } |
3344 if (EQ (funcar, Qautoload)) | 3339 if (EQ (funcar, Qautoload)) |
3345 { | 3340 { |
3346 struct gcpro gcpro1; | |
3347 | |
3348 GCPRO1 (function); | |
3349 do_autoload (function, orig_function); | 3341 do_autoload (function, orig_function); |
3350 UNGCPRO; | |
3351 function = orig_function; | |
3352 goto retry; | 3342 goto retry; |
3353 } | 3343 } |
3354 if (EQ (funcar, Qlambda)) | 3344 if (EQ (funcar, Qlambda)) |
3355 arglist = Fcar (XCDR (function)); | 3345 arglist = Fcar (XCDR (function)); |
3356 else | 3346 else |
3643 value, that value may be a function or a list of functions to be | 3633 value, that value may be a function or a list of functions to be |
3644 called to run the hook. If the value is a function, it is called with | 3634 called to run the hook. If the value is a function, it is called with |
3645 the given arguments and its return value is returned. If it is a list | 3635 the given arguments and its return value is returned. If it is a list |
3646 of functions, those functions are called, in order, | 3636 of functions, those functions are called, in order, |
3647 with the given arguments ARGS. | 3637 with the given arguments ARGS. |
3648 It is best not to depend on the value returned by `run-hook-with-args', | 3638 It is best not to depend on the value return by `run-hook-with-args', |
3649 as that may change. | 3639 as that may change. |
3650 | 3640 |
3651 To make a hook variable buffer-local, use `make-local-hook', | 3641 To make a hook variable buffer-local, use `make-local-hook', |
3652 not `make-local-variable'. | 3642 not `make-local-variable'. |
3653 */ | 3643 */ |
3699 Lisp_Object | 3689 Lisp_Object |
3700 run_hook_with_args_in_buffer (struct buffer *buf, int nargs, Lisp_Object *args, | 3690 run_hook_with_args_in_buffer (struct buffer *buf, int nargs, Lisp_Object *args, |
3701 enum run_hooks_condition cond) | 3691 enum run_hooks_condition cond) |
3702 { | 3692 { |
3703 Lisp_Object sym, val, ret; | 3693 Lisp_Object sym, val, ret; |
3694 struct gcpro gcpro1, gcpro2; | |
3704 | 3695 |
3705 if (!initialized || preparing_for_armageddon) | 3696 if (!initialized || preparing_for_armageddon) |
3706 /* We need to bail out of here pronto. */ | 3697 /* We need to bail out of here pronto. */ |
3707 return Qnil; | 3698 return Qnil; |
3708 | 3699 |
3721 args[0] = val; | 3712 args[0] = val; |
3722 return Ffuncall (nargs, args); | 3713 return Ffuncall (nargs, args); |
3723 } | 3714 } |
3724 else | 3715 else |
3725 { | 3716 { |
3726 struct gcpro gcpro1, gcpro2, gcpro3; | 3717 GCPRO2 (sym, val); |
3727 Lisp_Object globals = Qnil; | |
3728 GCPRO3 (sym, val, globals); | |
3729 | 3718 |
3730 for (; | 3719 for (; |
3731 CONSP (val) && ((cond == RUN_HOOKS_TO_COMPLETION) | 3720 CONSP (val) && ((cond == RUN_HOOKS_TO_COMPLETION) |
3732 || (cond == RUN_HOOKS_UNTIL_SUCCESS ? NILP (ret) | 3721 || (cond == RUN_HOOKS_UNTIL_SUCCESS ? NILP (ret) |
3733 : !NILP (ret))); | 3722 : !NILP (ret))); |
3735 { | 3724 { |
3736 if (EQ (XCAR (val), Qt)) | 3725 if (EQ (XCAR (val), Qt)) |
3737 { | 3726 { |
3738 /* t indicates this hook has a local binding; | 3727 /* t indicates this hook has a local binding; |
3739 it means to run the global binding too. */ | 3728 it means to run the global binding too. */ |
3740 globals = Fdefault_value (sym); | 3729 Lisp_Object globals = Fdefault_value (sym); |
3741 | 3730 |
3742 if ((! CONSP (globals) || EQ (XCAR (globals), Qlambda)) && | 3731 if ((! CONSP (globals) || EQ (XCAR (globals), Qlambda)) && |
3743 ! NILP (globals)) | 3732 ! NILP (globals)) |
3744 { | 3733 { |
3745 args[0] = globals; | 3734 args[0] = globals; |
4830 if (printing_bindings) write_c_string (")\n", stream); | 4819 if (printing_bindings) write_c_string (")\n", stream); |
4831 } | 4820 } |
4832 | 4821 |
4833 DEFUN ("backtrace", Fbacktrace, 0, 2, "", /* | 4822 DEFUN ("backtrace", Fbacktrace, 0, 2, "", /* |
4834 Print a trace of Lisp function calls currently active. | 4823 Print a trace of Lisp function calls currently active. |
4835 Optional arg STREAM specifies the output stream to send the backtrace to, | 4824 Option arg STREAM specifies the output stream to send the backtrace to, |
4836 and defaults to the value of `standard-output'. Optional second arg | 4825 and defaults to the value of `standard-output'. Optional second arg |
4837 DETAILED means show places where currently active variable bindings, | 4826 DETAILED means show places where currently active variable bindings, |
4838 catches, condition-cases, and unwind-protects were made as well as | 4827 catches, condition-cases, and unwind-protects were made as well as |
4839 function calls. | 4828 function calls. |
4840 */ | 4829 */ |
4873 for (;;) | 4862 for (;;) |
4874 { | 4863 { |
4875 if (!NILP (detailed) && catches && catches->backlist == backlist) | 4864 if (!NILP (detailed) && catches && catches->backlist == backlist) |
4876 { | 4865 { |
4877 int catchpdl = catches->pdlcount; | 4866 int catchpdl = catches->pdlcount; |
4878 if (speccount > catchpdl | 4867 if (specpdl[catchpdl].func == condition_case_unwind |
4879 && specpdl[catchpdl].func == condition_case_unwind) | 4868 && speccount > catchpdl) |
4880 /* This is a condition-case catchpoint */ | 4869 /* This is a condition-case catchpoint */ |
4881 catchpdl = catchpdl + 1; | 4870 catchpdl = catchpdl + 1; |
4882 | 4871 |
4883 backtrace_specials (speccount, catchpdl, stream); | 4872 backtrace_specials (speccount, catchpdl, stream); |
4884 | 4873 |
5257 specpdl_size = 50; | 5246 specpdl_size = 50; |
5258 specpdl_depth_counter = 0; | 5247 specpdl_depth_counter = 0; |
5259 specpdl = xnew_array (struct specbinding, specpdl_size); | 5248 specpdl = xnew_array (struct specbinding, specpdl_size); |
5260 /* XEmacs change: increase these values. */ | 5249 /* XEmacs change: increase these values. */ |
5261 max_specpdl_size = 3000; | 5250 max_specpdl_size = 3000; |
5262 max_lisp_eval_depth = 1000; | 5251 max_lisp_eval_depth = 500; |
5263 throw_level = 0; | 5252 throw_level = 0; |
5264 | 5253 |
5265 reinit_eval (); | 5254 reinit_eval (); |
5266 } | 5255 } |