Mercurial > emacs
annotate src/eval.c @ 26307:155d5adcdff4
(init_eval): Conditionalize declaration of gcpro_level.
| author | Dave Love <fx@gnu.org> |
|---|---|
| date | Tue, 02 Nov 1999 12:55:29 +0000 |
| parents | 4d1e267efd41 |
| children | 6527989cb214 |
| rev | line source |
|---|---|
| 272 | 1 /* Evaluator for GNU Emacs Lisp interpreter. |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25783
diff
changeset
|
2 Copyright (C) 1985, 86, 87, 93, 94, 95, 1999 Free Software Foundation, Inc. |
| 272 | 3 |
| 4 This file is part of GNU Emacs. | |
| 5 | |
| 6 GNU Emacs is free software; you can redistribute it and/or modify | |
| 7 it under the terms of the GNU General Public License as published by | |
|
10342
01d13c22797e
(Fcommandp): Use & PSEUDOVECTOR_SIZE_MASK on `size' field of compiled
Roland McGrath <roland@gnu.org>
parents:
10201
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
| 272 | 9 any later version. |
| 10 | |
| 11 GNU Emacs is distributed in the hope that it will be useful, | |
| 12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 GNU General Public License for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
| 17 along with GNU Emacs; see the file COPYING. If not, write to | |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14073
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14073
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
| 272 | 20 |
| 21 | |
|
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4474
diff
changeset
|
22 #include <config.h> |
| 21514 | 23 |
| 272 | 24 #include "lisp.h" |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
1564
diff
changeset
|
25 #include "blockinput.h" |
| 272 | 26 |
| 27 #ifndef standalone | |
| 28 #include "commands.h" | |
| 515 | 29 #include "keyboard.h" |
| 272 | 30 #else |
| 31 #define INTERACTIVE 1 | |
| 32 #endif | |
| 33 | |
| 34 #include <setjmp.h> | |
| 35 | |
| 36 /* This definition is duplicated in alloc.c and keyboard.c */ | |
| 37 /* Putting it in lisp.h makes cc bomb out! */ | |
| 38 | |
| 39 struct backtrace | |
| 40 { | |
| 41 struct backtrace *next; | |
| 42 Lisp_Object *function; | |
| 43 Lisp_Object *args; /* Points to vector of args. */ | |
| 727 | 44 int nargs; /* Length of vector. |
| 45 If nargs is UNEVALLED, args points to slot holding | |
| 46 list of unevalled args */ | |
| 272 | 47 char evalargs; |
| 48 /* Nonzero means call value of debugger when done with this operation. */ | |
| 49 char debug_on_exit; | |
| 50 }; | |
| 51 | |
| 52 struct backtrace *backtrace_list; | |
| 53 | |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
54 /* This structure helps implement the `catch' and `throw' control |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
55 structure. A struct catchtag contains all the information needed |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
56 to restore the state of the interpreter after a non-local jump. |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
57 |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
58 Handlers for error conditions (represented by `struct handler' |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
59 structures) just point to a catch tag to do the cleanup required |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
60 for their jumps. |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
61 |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
62 catchtag structures are chained together in the C calling stack; |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
63 the `next' member points to the next outer catchtag. |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
64 |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
65 A call like (throw TAG VAL) searches for a catchtag whose `tag' |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
66 member is TAG, and then unbinds to it. The `val' member is used to |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
67 hold VAL while the stack is unwound; `val' is returned as the value |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
68 of the catch form. |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
69 |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
70 All the other members are concerned with restoring the interpreter |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
71 state. */ |
| 272 | 72 struct catchtag |
| 73 { | |
| 74 Lisp_Object tag; | |
| 75 Lisp_Object val; | |
| 76 struct catchtag *next; | |
| 77 struct gcpro *gcpro; | |
| 78 jmp_buf jmp; | |
| 79 struct backtrace *backlist; | |
| 80 struct handler *handlerlist; | |
| 81 int lisp_eval_depth; | |
| 82 int pdlcount; | |
| 83 int poll_suppress_count; | |
| 84 }; | |
| 85 | |
| 86 struct catchtag *catchlist; | |
| 87 | |
|
26297
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
88 #ifdef DEBUG_GCPRO |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
89 /* Count levels of GCPRO to detect failure to UNGCPRO. */ |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
90 int gcpro_level; |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
91 #endif |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
92 |
| 272 | 93 Lisp_Object Qautoload, Qmacro, Qexit, Qinteractive, Qcommandp, Qdefun; |
| 381 | 94 Lisp_Object Qinhibit_quit, Vinhibit_quit, Vquit_flag; |
| 272 | 95 Lisp_Object Qmocklisp_arguments, Vmocklisp_arguments, Qmocklisp; |
| 96 Lisp_Object Qand_rest, Qand_optional; | |
| 97 Lisp_Object Qdebug_on_error; | |
| 98 | |
|
16296
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
99 /* This holds either the symbol `run-hooks' or nil. |
|
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
100 It is nil at an early stage of startup, and when Emacs |
|
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
101 is shutting down. */ |
| 272 | 102 Lisp_Object Vrun_hooks; |
| 103 | |
| 104 /* Non-nil means record all fset's and provide's, to be undone | |
| 105 if the file being autoloaded is not fully loaded. | |
| 106 They are recorded by being consed onto the front of Vautoload_queue: | |
| 107 (FUN . ODEF) for a defun, (OFEATURES . nil) for a provide. */ | |
| 108 | |
| 109 Lisp_Object Vautoload_queue; | |
| 110 | |
| 111 /* Current number of specbindings allocated in specpdl. */ | |
| 112 int specpdl_size; | |
| 113 | |
| 114 /* Pointer to beginning of specpdl. */ | |
| 115 struct specbinding *specpdl; | |
| 116 | |
| 117 /* Pointer to first unused element in specpdl. */ | |
| 118 struct specbinding *specpdl_ptr; | |
| 119 | |
| 120 /* Maximum size allowed for specpdl allocation */ | |
| 121 int max_specpdl_size; | |
| 122 | |
| 123 /* Depth in Lisp evaluations and function calls. */ | |
| 124 int lisp_eval_depth; | |
| 125 | |
| 126 /* Maximum allowed depth in Lisp evaluations and function calls. */ | |
| 127 int max_lisp_eval_depth; | |
| 128 | |
| 129 /* Nonzero means enter debugger before next function call */ | |
| 130 int debug_on_next_call; | |
| 131 | |
| 684 | 132 /* List of conditions (non-nil atom means all) which cause a backtrace |
|
706
86cb5db0b6c3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
133 if an error is handled by the command loop's error handler. */ |
| 684 | 134 Lisp_Object Vstack_trace_on_error; |
| 272 | 135 |
| 684 | 136 /* List of conditions (non-nil atom means all) which enter the debugger |
|
706
86cb5db0b6c3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
137 if an error is handled by the command loop's error handler. */ |
| 684 | 138 Lisp_Object Vdebug_on_error; |
| 272 | 139 |
| 13768 | 140 /* List of conditions and regexps specifying error messages which |
| 141 do not enter the debugger even if Vdebug_on_errors says they should. */ | |
| 142 Lisp_Object Vdebug_ignored_errors; | |
| 143 | |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
144 /* Non-nil means call the debugger even if the error will be handled. */ |
|
16443
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
145 Lisp_Object Vdebug_on_signal; |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
146 |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
147 /* Hook for edebug to use. */ |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
148 Lisp_Object Vsignal_hook_function; |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
149 |
| 272 | 150 /* Nonzero means enter debugger if a quit signal |
| 684 | 151 is handled by the command loop's error handler. */ |
| 272 | 152 int debug_on_quit; |
| 153 | |
|
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
154 /* The value of num_nonmacro_input_events as of the last time we |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
155 started to enter the debugger. If we decide to enter the debugger |
|
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
156 again when this is still equal to num_nonmacro_input_events, then we |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
157 know that the debugger itself has an error, and we should just |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
158 signal the error instead of entering an infinite loop of debugger |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
159 invocations. */ |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
160 int when_entered_debugger; |
| 272 | 161 |
| 162 Lisp_Object Vdebugger; | |
| 163 | |
| 164 void specbind (), record_unwind_protect (); | |
| 165 | |
|
13314
661060193eb8
(run_hook_with_args): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
13103
diff
changeset
|
166 Lisp_Object run_hook_with_args (); |
|
661060193eb8
(run_hook_with_args): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
13103
diff
changeset
|
167 |
| 272 | 168 Lisp_Object funcall_lambda (); |
| 169 extern Lisp_Object ml_apply (); /* Apply a mocklisp function to unevaluated argument list */ | |
| 170 | |
| 21514 | 171 void |
| 272 | 172 init_eval_once () |
| 173 { | |
| 174 specpdl_size = 50; | |
|
7885
bc6406a90796
(init_eval_once): Call xmalloc, not malloc.
Richard M. Stallman <rms@gnu.org>
parents:
7533
diff
changeset
|
175 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); |
|
14600
f32beac333a0
(init_eval_once): Initialize specpdl_ptr.
Karl Heuer <kwzh@gnu.org>
parents:
14218
diff
changeset
|
176 specpdl_ptr = specpdl; |
| 272 | 177 max_specpdl_size = 600; |
|
17061
bc9a4db95edb
(init_eval_once): Increase max_lisp_eval_depth to 300.
Karl Heuer <kwzh@gnu.org>
parents:
16930
diff
changeset
|
178 max_lisp_eval_depth = 300; |
|
8980
e641b60610a1
(init_eval_once): Init Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
8902
diff
changeset
|
179 |
|
e641b60610a1
(init_eval_once): Init Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
8902
diff
changeset
|
180 Vrun_hooks = Qnil; |
| 272 | 181 } |
| 182 | |
| 21514 | 183 void |
| 272 | 184 init_eval () |
| 185 { | |
| 186 specpdl_ptr = specpdl; | |
| 187 catchlist = 0; | |
| 188 handlerlist = 0; | |
| 189 backtrace_list = 0; | |
| 190 Vquit_flag = Qnil; | |
| 191 debug_on_next_call = 0; | |
| 192 lisp_eval_depth = 0; | |
|
26307
155d5adcdff4
(init_eval): Conditionalize declaration of gcpro_level.
Dave Love <fx@gnu.org>
parents:
26297
diff
changeset
|
193 #ifdef DEBUG_GCPRO |
|
26297
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
194 gcpro_level = 0; |
|
26307
155d5adcdff4
(init_eval): Conditionalize declaration of gcpro_level.
Dave Love <fx@gnu.org>
parents:
26297
diff
changeset
|
195 #endif |
|
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
196 /* This is less than the initial value of num_nonmacro_input_events. */ |
|
7213
bb5db306a305
(init_eval): Initialize when_entered_debugger to -1.
Richard M. Stallman <rms@gnu.org>
parents:
6918
diff
changeset
|
197 when_entered_debugger = -1; |
| 272 | 198 } |
| 199 | |
| 200 Lisp_Object | |
| 201 call_debugger (arg) | |
| 202 Lisp_Object arg; | |
| 203 { | |
| 204 if (lisp_eval_depth + 20 > max_lisp_eval_depth) | |
| 205 max_lisp_eval_depth = lisp_eval_depth + 20; | |
| 206 if (specpdl_size + 40 > max_specpdl_size) | |
| 207 max_specpdl_size = specpdl_size + 40; | |
| 208 debug_on_next_call = 0; | |
|
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
209 when_entered_debugger = num_nonmacro_input_events; |
| 272 | 210 return apply1 (Vdebugger, arg); |
| 211 } | |
| 212 | |
| 21514 | 213 void |
| 272 | 214 do_debug_on_call (code) |
| 215 Lisp_Object code; | |
| 216 { | |
| 217 debug_on_next_call = 0; | |
| 218 backtrace_list->debug_on_exit = 1; | |
| 219 call_debugger (Fcons (code, Qnil)); | |
| 220 } | |
| 221 | |
| 222 /* NOTE!!! Every function that can call EVAL must protect its args | |
| 223 and temporaries from garbage collection while it needs them. | |
| 224 The definition of `For' shows what you have to do. */ | |
| 225 | |
| 226 DEFUN ("or", For, Sor, 0, UNEVALLED, 0, | |
| 227 "Eval args until one of them yields non-nil, then return that value.\n\ | |
| 228 The remaining args are not evalled at all.\n\ | |
| 229 If all args return nil, return nil.") | |
| 230 (args) | |
| 231 Lisp_Object args; | |
| 232 { | |
| 233 register Lisp_Object val; | |
| 234 Lisp_Object args_left; | |
| 235 struct gcpro gcpro1; | |
| 236 | |
| 485 | 237 if (NILP(args)) |
| 272 | 238 return Qnil; |
| 239 | |
| 240 args_left = args; | |
| 241 GCPRO1 (args_left); | |
| 242 | |
| 243 do | |
| 244 { | |
| 245 val = Feval (Fcar (args_left)); | |
| 485 | 246 if (!NILP (val)) |
| 272 | 247 break; |
| 248 args_left = Fcdr (args_left); | |
| 249 } | |
| 485 | 250 while (!NILP(args_left)); |
| 272 | 251 |
| 252 UNGCPRO; | |
| 253 return val; | |
| 254 } | |
| 255 | |
| 256 DEFUN ("and", Fand, Sand, 0, UNEVALLED, 0, | |
| 257 "Eval args until one of them yields nil, then return nil.\n\ | |
| 258 The remaining args are not evalled at all.\n\ | |
| 259 If no arg yields nil, return the last arg's value.") | |
| 260 (args) | |
| 261 Lisp_Object args; | |
| 262 { | |
| 263 register Lisp_Object val; | |
| 264 Lisp_Object args_left; | |
| 265 struct gcpro gcpro1; | |
| 266 | |
| 485 | 267 if (NILP(args)) |
| 272 | 268 return Qt; |
| 269 | |
| 270 args_left = args; | |
| 271 GCPRO1 (args_left); | |
| 272 | |
| 273 do | |
| 274 { | |
| 275 val = Feval (Fcar (args_left)); | |
| 485 | 276 if (NILP (val)) |
| 272 | 277 break; |
| 278 args_left = Fcdr (args_left); | |
| 279 } | |
| 485 | 280 while (!NILP(args_left)); |
| 272 | 281 |
| 282 UNGCPRO; | |
| 283 return val; | |
| 284 } | |
| 285 | |
| 286 DEFUN ("if", Fif, Sif, 2, UNEVALLED, 0, | |
| 287 "(if COND THEN ELSE...): if COND yields non-nil, do THEN, else do ELSE...\n\ | |
| 288 Returns the value of THEN or the value of the last of the ELSE's.\n\ | |
| 289 THEN must be one expression, but ELSE... can be zero or more expressions.\n\ | |
| 290 If COND yields nil, and there are no ELSE's, the value is nil.") | |
| 291 (args) | |
| 292 Lisp_Object args; | |
| 293 { | |
| 294 register Lisp_Object cond; | |
| 295 struct gcpro gcpro1; | |
| 296 | |
| 297 GCPRO1 (args); | |
| 298 cond = Feval (Fcar (args)); | |
| 299 UNGCPRO; | |
| 300 | |
| 485 | 301 if (!NILP (cond)) |
| 272 | 302 return Feval (Fcar (Fcdr (args))); |
| 303 return Fprogn (Fcdr (Fcdr (args))); | |
| 304 } | |
| 305 | |
| 306 DEFUN ("cond", Fcond, Scond, 0, UNEVALLED, 0, | |
| 307 "(cond CLAUSES...): try each clause until one succeeds.\n\ | |
| 308 Each clause looks like (CONDITION BODY...). CONDITION is evaluated\n\ | |
| 309 and, if the value is non-nil, this clause succeeds:\n\ | |
| 310 then the expressions in BODY are evaluated and the last one's\n\ | |
| 311 value is the value of the cond-form.\n\ | |
| 312 If no clause succeeds, cond returns nil.\n\ | |
| 313 If a clause has one element, as in (CONDITION),\n\ | |
| 314 CONDITION's value if non-nil is returned from the cond-form.") | |
| 315 (args) | |
| 316 Lisp_Object args; | |
| 317 { | |
| 318 register Lisp_Object clause, val; | |
| 319 struct gcpro gcpro1; | |
| 320 | |
| 321 val = Qnil; | |
| 322 GCPRO1 (args); | |
| 485 | 323 while (!NILP (args)) |
| 272 | 324 { |
| 325 clause = Fcar (args); | |
| 326 val = Feval (Fcar (clause)); | |
| 485 | 327 if (!NILP (val)) |
| 272 | 328 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
329 if (!EQ (XCDR (clause), Qnil)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
330 val = Fprogn (XCDR (clause)); |
| 272 | 331 break; |
| 332 } | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
333 args = XCDR (args); |
| 272 | 334 } |
| 335 UNGCPRO; | |
| 336 | |
| 337 return val; | |
| 338 } | |
| 339 | |
| 340 DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, | |
| 341 "(progn BODY...): eval BODY forms sequentially and return value of last one.") | |
| 342 (args) | |
| 343 Lisp_Object args; | |
| 344 { | |
| 345 register Lisp_Object val, tem; | |
| 346 Lisp_Object args_left; | |
| 347 struct gcpro gcpro1; | |
| 348 | |
| 349 /* In Mocklisp code, symbols at the front of the progn arglist | |
| 350 are to be bound to zero. */ | |
| 351 if (!EQ (Vmocklisp_arguments, Qt)) | |
| 352 { | |
| 353 val = make_number (0); | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
354 while (!NILP (args) && (tem = Fcar (args), SYMBOLP (tem))) |
| 272 | 355 { |
| 356 QUIT; | |
| 357 specbind (tem, val), args = Fcdr (args); | |
| 358 } | |
| 359 } | |
| 360 | |
| 485 | 361 if (NILP(args)) |
| 272 | 362 return Qnil; |
| 363 | |
| 364 args_left = args; | |
| 365 GCPRO1 (args_left); | |
| 366 | |
| 367 do | |
| 368 { | |
| 369 val = Feval (Fcar (args_left)); | |
| 370 args_left = Fcdr (args_left); | |
| 371 } | |
| 485 | 372 while (!NILP(args_left)); |
| 272 | 373 |
| 374 UNGCPRO; | |
| 375 return val; | |
| 376 } | |
| 377 | |
| 378 DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0, | |
| 379 "(prog1 FIRST BODY...): eval FIRST and BODY sequentially; value from FIRST.\n\ | |
| 380 The value of FIRST is saved during the evaluation of the remaining args,\n\ | |
| 381 whose values are discarded.") | |
| 382 (args) | |
| 383 Lisp_Object args; | |
| 384 { | |
| 385 Lisp_Object val; | |
| 386 register Lisp_Object args_left; | |
| 387 struct gcpro gcpro1, gcpro2; | |
| 388 register int argnum = 0; | |
| 389 | |
| 485 | 390 if (NILP(args)) |
| 272 | 391 return Qnil; |
| 392 | |
| 393 args_left = args; | |
| 394 val = Qnil; | |
| 395 GCPRO2 (args, val); | |
| 396 | |
| 397 do | |
| 398 { | |
| 399 if (!(argnum++)) | |
| 400 val = Feval (Fcar (args_left)); | |
| 401 else | |
| 402 Feval (Fcar (args_left)); | |
| 403 args_left = Fcdr (args_left); | |
| 404 } | |
| 485 | 405 while (!NILP(args_left)); |
| 272 | 406 |
| 407 UNGCPRO; | |
| 408 return val; | |
| 409 } | |
| 410 | |
| 411 DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0, | |
| 8412 | 412 "(prog2 X Y BODY...): eval X, Y and BODY sequentially; value from Y.\n\ |
| 272 | 413 The value of Y is saved during the evaluation of the remaining args,\n\ |
| 414 whose values are discarded.") | |
| 415 (args) | |
| 416 Lisp_Object args; | |
| 417 { | |
| 418 Lisp_Object val; | |
| 419 register Lisp_Object args_left; | |
| 420 struct gcpro gcpro1, gcpro2; | |
| 421 register int argnum = -1; | |
| 422 | |
| 423 val = Qnil; | |
| 424 | |
| 6803 | 425 if (NILP (args)) |
| 272 | 426 return Qnil; |
| 427 | |
| 428 args_left = args; | |
| 429 val = Qnil; | |
| 430 GCPRO2 (args, val); | |
| 431 | |
| 432 do | |
| 433 { | |
| 434 if (!(argnum++)) | |
| 435 val = Feval (Fcar (args_left)); | |
| 436 else | |
| 437 Feval (Fcar (args_left)); | |
| 438 args_left = Fcdr (args_left); | |
| 439 } | |
| 6803 | 440 while (!NILP (args_left)); |
| 272 | 441 |
| 442 UNGCPRO; | |
| 443 return val; | |
| 444 } | |
| 445 | |
| 446 DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0, | |
| 447 "(setq SYM VAL SYM VAL ...): set each SYM to the value of its VAL.\n\ | |
| 6918 | 448 The symbols SYM are variables; they are literal (not evaluated).\n\ |
| 449 The values VAL are expressions; they are evaluated.\n\ | |
| 450 Thus, (setq x (1+ y)) sets `x' to the value of `(1+ y)'.\n\ | |
| 451 The second VAL is not computed until after the first SYM is set, and so on;\n\ | |
| 452 each VAL can use the new value of variables set earlier in the `setq'.\n\ | |
| 6713 | 453 The return value of the `setq' form is the value of the last VAL.") |
| 272 | 454 (args) |
| 455 Lisp_Object args; | |
| 456 { | |
| 457 register Lisp_Object args_left; | |
| 458 register Lisp_Object val, sym; | |
| 459 struct gcpro gcpro1; | |
| 460 | |
| 485 | 461 if (NILP(args)) |
| 272 | 462 return Qnil; |
| 463 | |
| 464 args_left = args; | |
| 465 GCPRO1 (args); | |
| 466 | |
| 467 do | |
| 468 { | |
| 469 val = Feval (Fcar (Fcdr (args_left))); | |
| 470 sym = Fcar (args_left); | |
| 471 Fset (sym, val); | |
| 472 args_left = Fcdr (Fcdr (args_left)); | |
| 473 } | |
| 485 | 474 while (!NILP(args_left)); |
| 272 | 475 |
| 476 UNGCPRO; | |
| 477 return val; | |
| 478 } | |
| 479 | |
| 480 DEFUN ("quote", Fquote, Squote, 1, UNEVALLED, 0, | |
| 481 "Return the argument, without evaluating it. `(quote x)' yields `x'.") | |
| 482 (args) | |
| 483 Lisp_Object args; | |
| 484 { | |
| 485 return Fcar (args); | |
| 486 } | |
| 487 | |
| 488 DEFUN ("function", Ffunction, Sfunction, 1, UNEVALLED, 0, | |
| 489 "Like `quote', but preferred for objects which are functions.\n\ | |
| 490 In byte compilation, `function' causes its argument to be compiled.\n\ | |
| 491 `quote' cannot do that.") | |
| 492 (args) | |
| 493 Lisp_Object args; | |
| 494 { | |
| 495 return Fcar (args); | |
| 496 } | |
| 497 | |
| 498 DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, | |
| 499 "Return t if function in which this appears was called interactively.\n\ | |
| 500 This means that the function was called with call-interactively (which\n\ | |
| 501 includes being called as the binding of a key)\n\ | |
| 502 and input is currently coming from the keyboard (not in keyboard macro).") | |
| 503 () | |
| 504 { | |
| 505 register struct backtrace *btp; | |
| 506 register Lisp_Object fun; | |
| 507 | |
| 508 if (!INTERACTIVE) | |
| 509 return Qnil; | |
| 510 | |
| 511 btp = backtrace_list; | |
| 727 | 512 |
| 513 /* If this isn't a byte-compiled function, there may be a frame at | |
| 514 the top for Finteractive_p itself. If so, skip it. */ | |
| 515 fun = Findirect_function (*btp->function); | |
|
9959
c942c7e6ebbd
(Finteractive_p): Use XSUBR instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents:
9306
diff
changeset
|
516 if (SUBRP (fun) && XSUBR (fun) == &Sinteractive_p) |
| 323 | 517 btp = btp->next; |
| 518 | |
| 727 | 519 /* If we're running an Emacs 18-style byte-compiled function, there |
| 520 may be a frame for Fbytecode. Now, given the strictest | |
| 521 definition, this function isn't really being called | |
| 522 interactively, but because that's the way Emacs 18 always builds | |
| 523 byte-compiled functions, we'll accept it for now. */ | |
| 524 if (EQ (*btp->function, Qbytecode)) | |
| 525 btp = btp->next; | |
| 526 | |
| 527 /* If this isn't a byte-compiled function, then we may now be | |
| 528 looking at several frames for special forms. Skip past them. */ | |
| 529 while (btp && | |
| 530 btp->nargs == UNEVALLED) | |
| 531 btp = btp->next; | |
| 532 | |
| 533 /* btp now points at the frame of the innermost function that isn't | |
| 534 a special form, ignoring frames for Finteractive_p and/or | |
| 535 Fbytecode at the top. If this frame is for a built-in function | |
| 536 (such as load or eval-region) return nil. */ | |
| 648 | 537 fun = Findirect_function (*btp->function); |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
538 if (SUBRP (fun)) |
| 272 | 539 return Qnil; |
| 540 /* btp points to the frame of a Lisp function that called interactive-p. | |
| 541 Return t if that function was called interactively. */ | |
| 542 if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively)) | |
| 543 return Qt; | |
| 544 return Qnil; | |
| 545 } | |
| 546 | |
| 547 DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0, | |
| 548 "(defun NAME ARGLIST [DOCSTRING] BODY...): define NAME as a function.\n\ | |
| 549 The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\ | |
| 550 See also the function `interactive'.") | |
| 551 (args) | |
| 552 Lisp_Object args; | |
| 553 { | |
| 554 register Lisp_Object fn_name; | |
| 555 register Lisp_Object defn; | |
| 556 | |
| 557 fn_name = Fcar (args); | |
| 558 defn = Fcons (Qlambda, Fcdr (args)); | |
| 485 | 559 if (!NILP (Vpurify_flag)) |
| 272 | 560 defn = Fpurecopy (defn); |
| 561 Ffset (fn_name, defn); | |
|
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
562 LOADHIST_ATTACH (fn_name); |
| 272 | 563 return fn_name; |
| 564 } | |
| 565 | |
| 566 DEFUN ("defmacro", Fdefmacro, Sdefmacro, 2, UNEVALLED, 0, | |
| 567 "(defmacro NAME ARGLIST [DOCSTRING] BODY...): define NAME as a macro.\n\ | |
| 568 The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).\n\ | |
| 569 When the macro is called, as in (NAME ARGS...),\n\ | |
| 570 the function (lambda ARGLIST BODY...) is applied to\n\ | |
| 571 the list ARGS... as it appears in the expression,\n\ | |
| 572 and the result should be a form to be evaluated instead of the original.") | |
| 573 (args) | |
| 574 Lisp_Object args; | |
| 575 { | |
| 576 register Lisp_Object fn_name; | |
| 577 register Lisp_Object defn; | |
| 578 | |
| 579 fn_name = Fcar (args); | |
| 580 defn = Fcons (Qmacro, Fcons (Qlambda, Fcdr (args))); | |
| 485 | 581 if (!NILP (Vpurify_flag)) |
| 272 | 582 defn = Fpurecopy (defn); |
| 583 Ffset (fn_name, defn); | |
|
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
584 LOADHIST_ATTACH (fn_name); |
| 272 | 585 return fn_name; |
| 586 } | |
| 587 | |
| 588 DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0, | |
| 589 "(defvar SYMBOL INITVALUE DOCSTRING): define SYMBOL as a variable.\n\ | |
| 590 You are not required to define a variable in order to use it,\n\ | |
| 591 but the definition can supply documentation and an initial value\n\ | |
| 592 in a way that tags can recognize.\n\n\ | |
| 593 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is void.\n\ | |
|
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
684
diff
changeset
|
594 If SYMBOL is buffer-local, its default value is what is set;\n\ |
|
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
684
diff
changeset
|
595 buffer-local values are not affected.\n\ |
| 272 | 596 INITVALUE and DOCSTRING are optional.\n\ |
| 597 If DOCSTRING starts with *, this variable is identified as a user option.\n\ | |
| 598 This means that M-x set-variable and M-x edit-options recognize it.\n\ | |
| 599 If INITVALUE is missing, SYMBOL's value is not set.") | |
| 600 (args) | |
| 601 Lisp_Object args; | |
| 602 { | |
|
10161
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
603 register Lisp_Object sym, tem, tail; |
| 272 | 604 |
| 605 sym = Fcar (args); | |
|
10161
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
606 tail = Fcdr (args); |
|
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
607 if (!NILP (Fcdr (Fcdr (tail)))) |
|
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
608 error ("too many arguments"); |
|
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
609 |
|
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
610 if (!NILP (tail)) |
| 272 | 611 { |
| 612 tem = Fdefault_boundp (sym); | |
| 485 | 613 if (NILP (tem)) |
| 272 | 614 Fset_default (sym, Feval (Fcar (Fcdr (args)))); |
| 615 } | |
|
10161
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
616 tail = Fcdr (Fcdr (args)); |
|
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
617 if (!NILP (Fcar (tail))) |
| 272 | 618 { |
|
10201
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
619 tem = Fcar (tail); |
| 485 | 620 if (!NILP (Vpurify_flag)) |
| 272 | 621 tem = Fpurecopy (tem); |
| 622 Fput (sym, Qvariable_documentation, tem); | |
| 623 } | |
|
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
624 LOADHIST_ATTACH (sym); |
| 272 | 625 return sym; |
| 626 } | |
| 627 | |
| 628 DEFUN ("defconst", Fdefconst, Sdefconst, 2, UNEVALLED, 0, | |
| 629 "(defconst SYMBOL INITVALUE DOCSTRING): define SYMBOL as a constant variable.\n\ | |
| 24427 | 630 The intent is that neither programs nor users should ever change this value.\n\ |
| 272 | 631 Always sets the value of SYMBOL to the result of evalling INITVALUE.\n\ |
|
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
684
diff
changeset
|
632 If SYMBOL is buffer-local, its default value is what is set;\n\ |
|
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
684
diff
changeset
|
633 buffer-local values are not affected.\n\ |
| 24391 | 634 DOCSTRING is optional.") |
| 272 | 635 (args) |
| 636 Lisp_Object args; | |
| 637 { | |
| 638 register Lisp_Object sym, tem; | |
| 639 | |
| 640 sym = Fcar (args); | |
|
10161
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
641 if (!NILP (Fcdr (Fcdr (Fcdr (args))))) |
|
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
642 error ("too many arguments"); |
|
512a84fb3c75
(Fdefconst, Fdefvar): Error if too many arguments.
Richard M. Stallman <rms@gnu.org>
parents:
9959
diff
changeset
|
643 |
| 272 | 644 Fset_default (sym, Feval (Fcar (Fcdr (args)))); |
| 645 tem = Fcar (Fcdr (Fcdr (args))); | |
| 485 | 646 if (!NILP (tem)) |
| 272 | 647 { |
| 485 | 648 if (!NILP (Vpurify_flag)) |
| 272 | 649 tem = Fpurecopy (tem); |
| 650 Fput (sym, Qvariable_documentation, tem); | |
| 651 } | |
|
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
652 LOADHIST_ATTACH (sym); |
| 272 | 653 return sym; |
| 654 } | |
| 655 | |
| 656 DEFUN ("user-variable-p", Fuser_variable_p, Suser_variable_p, 1, 1, 0, | |
| 657 "Returns t if VARIABLE is intended to be set and modified by users.\n\ | |
| 658 \(The alternative is a variable used internally in a Lisp program.)\n\ | |
| 659 Determined by whether the first character of the documentation\n\ | |
|
11251
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
660 for the variable is `*'.") |
| 272 | 661 (variable) |
| 662 Lisp_Object variable; | |
| 663 { | |
| 664 Lisp_Object documentation; | |
| 665 | |
|
17275
03f89f7e614e
(Fuser_variable_p): If not a symbol, return nil.
Richard M. Stallman <rms@gnu.org>
parents:
17061
diff
changeset
|
666 if (!SYMBOLP (variable)) |
|
03f89f7e614e
(Fuser_variable_p): If not a symbol, return nil.
Richard M. Stallman <rms@gnu.org>
parents:
17061
diff
changeset
|
667 return Qnil; |
|
03f89f7e614e
(Fuser_variable_p): If not a symbol, return nil.
Richard M. Stallman <rms@gnu.org>
parents:
17061
diff
changeset
|
668 |
| 272 | 669 documentation = Fget (variable, Qvariable_documentation); |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
670 if (INTEGERP (documentation) && XINT (documentation) < 0) |
| 272 | 671 return Qt; |
|
11251
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
672 if (STRINGP (documentation) |
|
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
673 && ((unsigned char) XSTRING (documentation)->data[0] == '*')) |
|
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
674 return Qt; |
|
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
675 /* If it is (STRING . INTEGER), a negative integer means a user variable. */ |
|
f6bc91242185
(Fuser_variable_p): For (STRING . INTEGER), test sign.
Richard M. Stallman <rms@gnu.org>
parents:
11205
diff
changeset
|
676 if (CONSP (documentation) |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
677 && STRINGP (XCAR (documentation)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
678 && INTEGERP (XCDR (documentation)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
679 && XINT (XCDR (documentation)) < 0) |
| 272 | 680 return Qt; |
| 681 return Qnil; | |
| 682 } | |
| 683 | |
| 684 DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0, | |
| 685 "(let* VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\ | |
| 686 The value of the last form in BODY is returned.\n\ | |
| 687 Each element of VARLIST is a symbol (which is bound to nil)\n\ | |
| 688 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\ | |
| 689 Each VALUEFORM can refer to the symbols already bound by this VARLIST.") | |
| 690 (args) | |
| 691 Lisp_Object args; | |
| 692 { | |
| 693 Lisp_Object varlist, val, elt; | |
| 694 int count = specpdl_ptr - specpdl; | |
| 695 struct gcpro gcpro1, gcpro2, gcpro3; | |
| 696 | |
| 697 GCPRO3 (args, elt, varlist); | |
| 698 | |
| 699 varlist = Fcar (args); | |
| 485 | 700 while (!NILP (varlist)) |
| 272 | 701 { |
| 702 QUIT; | |
| 703 elt = Fcar (varlist); | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
704 if (SYMBOLP (elt)) |
| 272 | 705 specbind (elt, Qnil); |
| 604 | 706 else if (! NILP (Fcdr (Fcdr (elt)))) |
| 707 Fsignal (Qerror, | |
| 708 Fcons (build_string ("`let' bindings can have only one value-form"), | |
| 709 elt)); | |
| 272 | 710 else |
| 711 { | |
| 712 val = Feval (Fcar (Fcdr (elt))); | |
| 713 specbind (Fcar (elt), val); | |
| 714 } | |
| 715 varlist = Fcdr (varlist); | |
| 716 } | |
| 717 UNGCPRO; | |
| 718 val = Fprogn (Fcdr (args)); | |
| 719 return unbind_to (count, val); | |
| 720 } | |
| 721 | |
| 722 DEFUN ("let", Flet, Slet, 1, UNEVALLED, 0, | |
| 723 "(let VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\ | |
| 724 The value of the last form in BODY is returned.\n\ | |
| 725 Each element of VARLIST is a symbol (which is bound to nil)\n\ | |
| 726 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\ | |
| 727 All the VALUEFORMs are evalled before any symbols are bound.") | |
| 728 (args) | |
| 729 Lisp_Object args; | |
| 730 { | |
| 731 Lisp_Object *temps, tem; | |
| 732 register Lisp_Object elt, varlist; | |
| 733 int count = specpdl_ptr - specpdl; | |
| 734 register int argnum; | |
| 735 struct gcpro gcpro1, gcpro2; | |
| 736 | |
| 737 varlist = Fcar (args); | |
| 738 | |
| 739 /* Make space to hold the values to give the bound variables */ | |
| 740 elt = Flength (varlist); | |
| 741 temps = (Lisp_Object *) alloca (XFASTINT (elt) * sizeof (Lisp_Object)); | |
| 742 | |
| 743 /* Compute the values and store them in `temps' */ | |
| 744 | |
| 745 GCPRO2 (args, *temps); | |
| 746 gcpro2.nvars = 0; | |
| 747 | |
| 485 | 748 for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist)) |
| 272 | 749 { |
| 750 QUIT; | |
| 751 elt = Fcar (varlist); | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
752 if (SYMBOLP (elt)) |
| 272 | 753 temps [argnum++] = Qnil; |
| 604 | 754 else if (! NILP (Fcdr (Fcdr (elt)))) |
| 755 Fsignal (Qerror, | |
| 756 Fcons (build_string ("`let' bindings can have only one value-form"), | |
| 757 elt)); | |
| 272 | 758 else |
| 759 temps [argnum++] = Feval (Fcar (Fcdr (elt))); | |
| 760 gcpro2.nvars = argnum; | |
| 761 } | |
| 762 UNGCPRO; | |
| 763 | |
| 764 varlist = Fcar (args); | |
| 485 | 765 for (argnum = 0; !NILP (varlist); varlist = Fcdr (varlist)) |
| 272 | 766 { |
| 767 elt = Fcar (varlist); | |
| 768 tem = temps[argnum++]; | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
769 if (SYMBOLP (elt)) |
| 272 | 770 specbind (elt, tem); |
| 771 else | |
| 772 specbind (Fcar (elt), tem); | |
| 773 } | |
| 774 | |
| 775 elt = Fprogn (Fcdr (args)); | |
| 776 return unbind_to (count, elt); | |
| 777 } | |
| 778 | |
| 779 DEFUN ("while", Fwhile, Swhile, 1, UNEVALLED, 0, | |
| 780 "(while TEST BODY...): if TEST yields non-nil, eval BODY... and repeat.\n\ | |
| 781 The order of execution is thus TEST, BODY, TEST, BODY and so on\n\ | |
| 782 until TEST returns nil.") | |
| 783 (args) | |
| 784 Lisp_Object args; | |
| 785 { | |
| 786 Lisp_Object test, body, tem; | |
| 787 struct gcpro gcpro1, gcpro2; | |
| 788 | |
| 789 GCPRO2 (test, body); | |
| 790 | |
| 791 test = Fcar (args); | |
| 792 body = Fcdr (args); | |
|
4167
f037b1f51320
(Fwhile): If mocklisp, test for nonzeroness.
Richard M. Stallman <rms@gnu.org>
parents:
3973
diff
changeset
|
793 while (tem = Feval (test), |
|
f037b1f51320
(Fwhile): If mocklisp, test for nonzeroness.
Richard M. Stallman <rms@gnu.org>
parents:
3973
diff
changeset
|
794 (!EQ (Vmocklisp_arguments, Qt) ? XINT (tem) : !NILP (tem))) |
| 272 | 795 { |
| 796 QUIT; | |
| 797 Fprogn (body); | |
| 798 } | |
| 799 | |
| 800 UNGCPRO; | |
| 801 return Qnil; | |
| 802 } | |
| 803 | |
| 804 DEFUN ("macroexpand", Fmacroexpand, Smacroexpand, 1, 2, 0, | |
| 805 "Return result of expanding macros at top level of FORM.\n\ | |
| 806 If FORM is not a macro call, it is returned unchanged.\n\ | |
| 807 Otherwise, the macro is expanded and the expansion is considered\n\ | |
| 808 in place of FORM. When a non-macro-call results, it is returned.\n\n\ | |
| 809 The second optional arg ENVIRONMENT species an environment of macro\n\ | |
| 810 definitions to shadow the loaded ones for use in file byte-compilation.") | |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
811 (form, environment) |
|
16113
df832a303ce5
(Fmacroexpand): Don't declare `form' as register.
Richard M. Stallman <rms@gnu.org>
parents:
16108
diff
changeset
|
812 Lisp_Object form; |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
813 Lisp_Object environment; |
| 272 | 814 { |
| 753 | 815 /* With cleanups from Hallvard Furuseth. */ |
| 272 | 816 register Lisp_Object expander, sym, def, tem; |
| 817 | |
| 818 while (1) | |
| 819 { | |
| 820 /* Come back here each time we expand a macro call, | |
| 821 in case it expands into another macro call. */ | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
822 if (!CONSP (form)) |
| 272 | 823 break; |
| 753 | 824 /* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */ |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
825 def = sym = XCAR (form); |
| 753 | 826 tem = Qnil; |
| 272 | 827 /* Trace symbols aliases to other symbols |
| 828 until we get a symbol that is not an alias. */ | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
829 while (SYMBOLP (def)) |
| 272 | 830 { |
| 831 QUIT; | |
| 753 | 832 sym = def; |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
833 tem = Fassq (sym, environment); |
| 485 | 834 if (NILP (tem)) |
| 272 | 835 { |
| 836 def = XSYMBOL (sym)->function; | |
| 753 | 837 if (!EQ (def, Qunbound)) |
| 838 continue; | |
| 272 | 839 } |
| 753 | 840 break; |
| 272 | 841 } |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
842 /* Right now TEM is the result from SYM in ENVIRONMENT, |
| 272 | 843 and if TEM is nil then DEF is SYM's function definition. */ |
| 485 | 844 if (NILP (tem)) |
| 272 | 845 { |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
846 /* SYM is not mentioned in ENVIRONMENT. |
| 272 | 847 Look at its function definition. */ |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
848 if (EQ (def, Qunbound) || !CONSP (def)) |
| 272 | 849 /* Not defined or definition not suitable */ |
| 850 break; | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
851 if (EQ (XCAR (def), Qautoload)) |
| 272 | 852 { |
| 853 /* Autoloading function: will it be a macro when loaded? */ | |
|
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
854 tem = Fnth (make_number (4), def); |
|
5254
b38b74fe1722
(Fmacroexpand): For an autoload definition,
Richard M. Stallman <rms@gnu.org>
parents:
4782
diff
changeset
|
855 if (EQ (tem, Qt) || EQ (tem, Qmacro)) |
|
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
856 /* Yes, load it and try again. */ |
|
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
857 { |
|
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
858 struct gcpro gcpro1; |
|
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
859 GCPRO1 (form); |
|
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
860 do_autoload (def, sym); |
|
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
861 UNGCPRO; |
|
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
862 continue; |
|
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
863 } |
|
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
864 else |
| 272 | 865 break; |
| 866 } | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
867 else if (!EQ (XCAR (def), Qmacro)) |
| 272 | 868 break; |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
869 else expander = XCDR (def); |
| 272 | 870 } |
| 871 else | |
| 872 { | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
873 expander = XCDR (tem); |
| 485 | 874 if (NILP (expander)) |
| 272 | 875 break; |
| 876 } | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
877 form = apply1 (expander, XCDR (form)); |
| 272 | 878 } |
| 879 return form; | |
| 880 } | |
| 881 | |
| 882 DEFUN ("catch", Fcatch, Scatch, 1, UNEVALLED, 0, | |
| 883 "(catch TAG BODY...): eval BODY allowing nonlocal exits using `throw'.\n\ | |
| 21589 | 884 TAG is evalled to get the tag to use; it must not be nil.\n\ |
| 885 \n\ | |
| 886 Then the BODY is executed.\n\ | |
| 272 | 887 Within BODY, (throw TAG) with same tag exits BODY and exits this `catch'.\n\ |
| 888 If no throw happens, `catch' returns the value of the last BODY form.\n\ | |
| 889 If a throw happens, it specifies the value to return from `catch'.") | |
| 890 (args) | |
| 891 Lisp_Object args; | |
| 892 { | |
| 893 register Lisp_Object tag; | |
| 894 struct gcpro gcpro1; | |
| 895 | |
| 896 GCPRO1 (args); | |
| 897 tag = Feval (Fcar (args)); | |
| 898 UNGCPRO; | |
| 899 return internal_catch (tag, Fprogn, Fcdr (args)); | |
| 900 } | |
| 901 | |
| 902 /* Set up a catch, then call C function FUNC on argument ARG. | |
| 903 FUNC should return a Lisp_Object. | |
| 904 This is how catches are done from within C code. */ | |
| 905 | |
| 906 Lisp_Object | |
| 907 internal_catch (tag, func, arg) | |
| 908 Lisp_Object tag; | |
| 909 Lisp_Object (*func) (); | |
| 910 Lisp_Object arg; | |
| 911 { | |
| 912 /* This structure is made part of the chain `catchlist'. */ | |
| 913 struct catchtag c; | |
| 914 | |
| 915 /* Fill in the components of c, and put it on the list. */ | |
| 916 c.next = catchlist; | |
| 917 c.tag = tag; | |
| 918 c.val = Qnil; | |
| 919 c.backlist = backtrace_list; | |
| 920 c.handlerlist = handlerlist; | |
| 921 c.lisp_eval_depth = lisp_eval_depth; | |
| 922 c.pdlcount = specpdl_ptr - specpdl; | |
| 923 c.poll_suppress_count = poll_suppress_count; | |
| 924 c.gcpro = gcprolist; | |
| 925 catchlist = &c; | |
| 926 | |
| 927 /* Call FUNC. */ | |
| 928 if (! _setjmp (c.jmp)) | |
| 929 c.val = (*func) (arg); | |
| 930 | |
| 931 /* Throw works by a longjmp that comes right here. */ | |
| 932 catchlist = c.next; | |
| 933 return c.val; | |
| 934 } | |
| 935 | |
|
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
936 /* Unwind the specbind, catch, and handler stacks back to CATCH, and |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
937 jump to that CATCH, returning VALUE as the value of that catch. |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
938 |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
939 This is the guts Fthrow and Fsignal; they differ only in the way |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
940 they choose the catch tag to throw to. A catch tag for a |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
941 condition-case form has a TAG of Qnil. |
| 272 | 942 |
|
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
943 Before each catch is discarded, unbind all special bindings and |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
944 execute all unwind-protect clauses made above that catch. Unwind |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
945 the handler stack as we go, so that the proper handlers are in |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
946 effect for each unwind-protect clause we run. At the end, restore |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
947 some static info saved in CATCH, and longjmp to the location |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
948 specified in the |
| 272 | 949 |
|
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
950 This is used for correct unwinding in Fthrow and Fsignal. */ |
| 272 | 951 |
| 952 static void | |
|
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
953 unwind_to_catch (catch, value) |
| 272 | 954 struct catchtag *catch; |
|
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
955 Lisp_Object value; |
| 272 | 956 { |
| 957 register int last_time; | |
| 958 | |
|
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
959 /* Save the value in the tag. */ |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
960 catch->val = value; |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
961 |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
962 /* Restore the polling-suppression count. */ |
|
4474
23d5b09bd218
(unwind_to_catch): Call set_poll_suppress_count.
Richard M. Stallman <rms@gnu.org>
parents:
4462
diff
changeset
|
963 set_poll_suppress_count (catch->poll_suppress_count); |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
964 |
| 272 | 965 do |
| 966 { | |
| 967 last_time = catchlist == catch; | |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
968 |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
969 /* Unwind the specpdl stack, and then restore the proper set of |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
970 handlers. */ |
| 272 | 971 unbind_to (catchlist->pdlcount, Qnil); |
| 972 handlerlist = catchlist->handlerlist; | |
| 973 catchlist = catchlist->next; | |
| 974 } | |
| 975 while (! last_time); | |
| 976 | |
| 977 gcprolist = catch->gcpro; | |
|
26297
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
978 #ifdef DEBUG_GCPRO |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
979 if (gcprolist != 0) |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
980 gcpro_level = gcprolist->level + 1; |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
981 else |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
982 gcpro_level = 0; |
|
4d1e267efd41
[DEBUG_GCPRO] (gcpro_level): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
26088
diff
changeset
|
983 #endif |
| 272 | 984 backtrace_list = catch->backlist; |
| 985 lisp_eval_depth = catch->lisp_eval_depth; | |
|
1199
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
986 |
|
ab2d88e2505b
* eval.c (unbind_catch): Do the long-jump here. Take a VALUE
Jim Blandy <jimb@redhat.com>
parents:
1196
diff
changeset
|
987 _longjmp (catch->jmp, 1); |
| 272 | 988 } |
| 989 | |
| 990 DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, | |
| 991 "(throw TAG VALUE): throw to the catch for TAG and return VALUE from it.\n\ | |
| 992 Both TAG and VALUE are evalled.") | |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
993 (tag, value) |
|
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
994 register Lisp_Object tag, value; |
| 272 | 995 { |
| 996 register struct catchtag *c; | |
| 997 | |
| 998 while (1) | |
| 999 { | |
| 485 | 1000 if (!NILP (tag)) |
| 272 | 1001 for (c = catchlist; c; c = c->next) |
| 1002 { | |
| 1003 if (EQ (c->tag, tag)) | |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
1004 unwind_to_catch (c, value); |
| 272 | 1005 } |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
1006 tag = Fsignal (Qno_catch, Fcons (tag, Fcons (value, Qnil))); |
| 272 | 1007 } |
| 1008 } | |
| 1009 | |
| 1010 | |
| 1011 DEFUN ("unwind-protect", Funwind_protect, Sunwind_protect, 1, UNEVALLED, 0, | |
| 1012 "Do BODYFORM, protecting with UNWINDFORMS.\n\ | |
| 1013 Usage looks like (unwind-protect BODYFORM UNWINDFORMS...).\n\ | |
| 1014 If BODYFORM completes normally, its value is returned\n\ | |
| 1015 after executing the UNWINDFORMS.\n\ | |
| 1016 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.") | |
| 1017 (args) | |
| 1018 Lisp_Object args; | |
| 1019 { | |
| 1020 Lisp_Object val; | |
| 1021 int count = specpdl_ptr - specpdl; | |
| 1022 | |
| 1023 record_unwind_protect (0, Fcdr (args)); | |
| 1024 val = Feval (Fcar (args)); | |
| 1025 return unbind_to (count, val); | |
| 1026 } | |
| 1027 | |
| 1028 /* Chain of condition handlers currently in effect. | |
| 1029 The elements of this chain are contained in the stack frames | |
| 1030 of Fcondition_case and internal_condition_case. | |
| 1031 When an error is signaled (by calling Fsignal, below), | |
| 1032 this chain is searched for an element that applies. */ | |
| 1033 | |
| 1034 struct handler *handlerlist; | |
| 1035 | |
| 1036 DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0, | |
| 1037 "Regain control when an error is signaled.\n\ | |
| 1038 Usage looks like (condition-case VAR BODYFORM HANDLERS...).\n\ | |
| 1039 executes BODYFORM and returns its value if no error happens.\n\ | |
| 1040 Each element of HANDLERS looks like (CONDITION-NAME BODY...)\n\ | |
| 1041 where the BODY is made of Lisp expressions.\n\n\ | |
| 1042 A handler is applicable to an error\n\ | |
| 1043 if CONDITION-NAME is one of the error's condition names.\n\ | |
| 1044 If an error happens, the first applicable handler is run.\n\ | |
| 1045 \n\ | |
|
5567
c61f49e4283a
(Fcondition_case): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5566
diff
changeset
|
1046 The car of a handler may be a list of condition names\n\ |
|
c61f49e4283a
(Fcondition_case): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5566
diff
changeset
|
1047 instead of a single condition name.\n\ |
|
c61f49e4283a
(Fcondition_case): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5566
diff
changeset
|
1048 \n\ |
| 272 | 1049 When a handler handles an error,\n\ |
| 1050 control returns to the condition-case and the handler BODY... is executed\n\ | |
| 1051 with VAR bound to (SIGNALED-CONDITIONS . SIGNAL-DATA).\n\ | |
| 1052 VAR may be nil; then you do not get access to the signal information.\n\ | |
| 1053 \n\ | |
| 1054 The value of the last BODY form is returned from the condition-case.\n\ | |
| 1055 See also the function `signal' for more info.") | |
| 1056 (args) | |
| 1057 Lisp_Object args; | |
| 1058 { | |
| 1059 Lisp_Object val; | |
| 1060 struct catchtag c; | |
| 1061 struct handler h; | |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1062 register Lisp_Object var, bodyform, handlers; |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1063 |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1064 var = Fcar (args); |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1065 bodyform = Fcar (Fcdr (args)); |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1066 handlers = Fcdr (Fcdr (args)); |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1067 CHECK_SYMBOL (var, 0); |
| 272 | 1068 |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1069 for (val = handlers; ! NILP (val); val = Fcdr (val)) |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1070 { |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1071 Lisp_Object tem; |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1072 tem = Fcar (val); |
|
5563
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1073 if (! (NILP (tem) |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1074 || (CONSP (tem) |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1075 && (SYMBOLP (XCAR (tem)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1076 || CONSP (XCAR (tem)))))) |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1077 error ("Invalid condition handler", tem); |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1078 } |
| 272 | 1079 |
| 1080 c.tag = Qnil; | |
| 1081 c.val = Qnil; | |
| 1082 c.backlist = backtrace_list; | |
| 1083 c.handlerlist = handlerlist; | |
| 1084 c.lisp_eval_depth = lisp_eval_depth; | |
| 1085 c.pdlcount = specpdl_ptr - specpdl; | |
| 1086 c.poll_suppress_count = poll_suppress_count; | |
| 1087 c.gcpro = gcprolist; | |
| 1088 if (_setjmp (c.jmp)) | |
| 1089 { | |
| 485 | 1090 if (!NILP (h.var)) |
|
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1091 specbind (h.var, c.val); |
|
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1092 val = Fprogn (Fcdr (h.chosen_clause)); |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1093 |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1094 /* Note that this just undoes the binding of h.var; whoever |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1095 longjumped to us unwound the stack to c.pdlcount before |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1096 throwing. */ |
| 272 | 1097 unbind_to (c.pdlcount, Qnil); |
| 1098 return val; | |
| 1099 } | |
| 1100 c.next = catchlist; | |
| 1101 catchlist = &c; | |
| 1102 | |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1103 h.var = var; |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1104 h.handler = handlers; |
| 272 | 1105 h.next = handlerlist; |
| 1106 h.tag = &c; | |
| 1107 handlerlist = &h; | |
| 1108 | |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1109 val = Feval (bodyform); |
| 272 | 1110 catchlist = c.next; |
| 1111 handlerlist = h.next; | |
| 1112 return val; | |
| 1113 } | |
| 1114 | |
|
14218
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1115 /* Call the function BFUN with no arguments, catching errors within it |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1116 according to HANDLERS. If there is an error, call HFUN with |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1117 one argument which is the data that describes the error: |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1118 (SIGNALNAME . DATA) |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1119 |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1120 HANDLERS can be a list of conditions to catch. |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1121 If HANDLERS is Qt, catch all errors. |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1122 If HANDLERS is Qerror, catch all errors |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1123 but allow the debugger to run if that is enabled. */ |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1124 |
| 272 | 1125 Lisp_Object |
| 1126 internal_condition_case (bfun, handlers, hfun) | |
| 1127 Lisp_Object (*bfun) (); | |
| 1128 Lisp_Object handlers; | |
| 1129 Lisp_Object (*hfun) (); | |
| 1130 { | |
| 1131 Lisp_Object val; | |
| 1132 struct catchtag c; | |
| 1133 struct handler h; | |
| 1134 | |
|
11365
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1135 /* Since Fsignal resets this to 0, it had better be 0 now |
|
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1136 or else we have a potential bug. */ |
|
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1137 if (interrupt_input_blocked != 0) |
|
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1138 abort (); |
|
1e2290c04cce
(internal_condition_case): Abort if interrupt_input_blocked>0.
Richard M. Stallman <rms@gnu.org>
parents:
11251
diff
changeset
|
1139 |
| 272 | 1140 c.tag = Qnil; |
| 1141 c.val = Qnil; | |
| 1142 c.backlist = backtrace_list; | |
| 1143 c.handlerlist = handlerlist; | |
| 1144 c.lisp_eval_depth = lisp_eval_depth; | |
| 1145 c.pdlcount = specpdl_ptr - specpdl; | |
| 1146 c.poll_suppress_count = poll_suppress_count; | |
| 1147 c.gcpro = gcprolist; | |
| 1148 if (_setjmp (c.jmp)) | |
| 1149 { | |
|
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1150 return (*hfun) (c.val); |
| 272 | 1151 } |
| 1152 c.next = catchlist; | |
| 1153 catchlist = &c; | |
| 1154 h.handler = handlers; | |
| 1155 h.var = Qnil; | |
| 1156 h.next = handlerlist; | |
| 1157 h.tag = &c; | |
| 1158 handlerlist = &h; | |
| 1159 | |
| 1160 val = (*bfun) (); | |
| 1161 catchlist = c.next; | |
| 1162 handlerlist = h.next; | |
| 1163 return val; | |
| 1164 } | |
| 1165 | |
|
14218
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1166 /* Like internal_condition_case but call HFUN with ARG as its argument. */ |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
1167 |
|
5807
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1168 Lisp_Object |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1169 internal_condition_case_1 (bfun, arg, handlers, hfun) |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1170 Lisp_Object (*bfun) (); |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1171 Lisp_Object arg; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1172 Lisp_Object handlers; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1173 Lisp_Object (*hfun) (); |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1174 { |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1175 Lisp_Object val; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1176 struct catchtag c; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1177 struct handler h; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1178 |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1179 c.tag = Qnil; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1180 c.val = Qnil; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1181 c.backlist = backtrace_list; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1182 c.handlerlist = handlerlist; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1183 c.lisp_eval_depth = lisp_eval_depth; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1184 c.pdlcount = specpdl_ptr - specpdl; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1185 c.poll_suppress_count = poll_suppress_count; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1186 c.gcpro = gcprolist; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1187 if (_setjmp (c.jmp)) |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1188 { |
|
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1189 return (*hfun) (c.val); |
|
5807
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1190 } |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1191 c.next = catchlist; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1192 catchlist = &c; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1193 h.handler = handlers; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1194 h.var = Qnil; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1195 h.next = handlerlist; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1196 h.tag = &c; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1197 handlerlist = &h; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1198 |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1199 val = (*bfun) (arg); |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1200 catchlist = c.next; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1201 handlerlist = h.next; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1202 return val; |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1203 } |
|
cc9d9ab24008
(internal_condition_case_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5567
diff
changeset
|
1204 |
| 272 | 1205 static Lisp_Object find_handler_clause (); |
| 1206 | |
| 1207 DEFUN ("signal", Fsignal, Ssignal, 2, 2, 0, | |
|
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1208 "Signal an error. Args are ERROR-SYMBOL and associated DATA.\n\ |
| 272 | 1209 This function does not return.\n\n\ |
|
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1210 An error symbol is a symbol with an `error-conditions' property\n\ |
| 272 | 1211 that is a list of condition names.\n\ |
| 1212 A handler for any of those names will get to handle this signal.\n\ | |
| 1213 The symbol `error' should normally be one of them.\n\ | |
| 1214 \n\ | |
| 1215 DATA should be a list. Its elements are printed as part of the error message.\n\ | |
| 1216 If the signal is handled, DATA is made available to the handler.\n\ | |
| 1217 See also the function `condition-case'.") | |
|
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1218 (error_symbol, data) |
|
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1219 Lisp_Object error_symbol, data; |
| 272 | 1220 { |
|
24171
44241f56675a
(Fsignal): Move comment to avoid confusing make-docfile.
Andreas Schwab <schwab@suse.de>
parents:
24054
diff
changeset
|
1221 /* When memory is full, ERROR-SYMBOL is nil, |
|
44241f56675a
(Fsignal): Move comment to avoid confusing make-docfile.
Andreas Schwab <schwab@suse.de>
parents:
24054
diff
changeset
|
1222 and DATA is (REAL-ERROR-SYMBOL . REAL-DATA). */ |
| 272 | 1223 register struct handler *allhandlers = handlerlist; |
| 1224 Lisp_Object conditions; | |
| 1225 extern int gc_in_progress; | |
| 1226 extern int waiting_for_input; | |
| 1227 Lisp_Object debugger_value; | |
|
16895
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1228 Lisp_Object string; |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1229 Lisp_Object real_error_symbol; |
|
25008
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1230 extern int display_busy_cursor_p; |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1231 |
| 272 | 1232 immediate_quit = 0; |
| 1233 if (gc_in_progress || waiting_for_input) | |
| 1234 abort (); | |
| 1235 | |
| 1236 TOTALLY_UNBLOCK_INPUT; | |
| 1237 | |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1238 if (NILP (error_symbol)) |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1239 real_error_symbol = Fcar (data); |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1240 else |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1241 real_error_symbol = error_symbol; |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1242 |
|
25008
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1243 #ifdef HAVE_X_WINDOWS |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1244 if (display_busy_cursor_p) |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1245 Fx_hide_busy_cursor (Qt); |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1246 #endif |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1247 |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1248 /* This hook is used by edebug. */ |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1249 if (! NILP (Vsignal_hook_function)) |
|
18018
2a11f1e4bd6b
(Fsignal): Use call2 to call Vsignal_hook_function.
Richard M. Stallman <rms@gnu.org>
parents:
17872
diff
changeset
|
1250 call2 (Vsignal_hook_function, error_symbol, data); |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1251 |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1252 conditions = Fget (real_error_symbol, Qerror_conditions); |
| 272 | 1253 |
| 1254 for (; handlerlist; handlerlist = handlerlist->next) | |
| 1255 { | |
| 1256 register Lisp_Object clause; | |
| 1257 clause = find_handler_clause (handlerlist->handler, conditions, | |
|
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1258 error_symbol, data, &debugger_value); |
| 272 | 1259 |
| 1260 #if 0 /* Most callers are not prepared to handle gc if this returns. | |
| 1261 So, since this feature is not very useful, take it out. */ | |
| 1262 /* If have called debugger and user wants to continue, | |
| 1263 just return nil. */ | |
| 1264 if (EQ (clause, Qlambda)) | |
| 1265 return debugger_value; | |
| 1266 #else | |
| 1267 if (EQ (clause, Qlambda)) | |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1268 { |
|
13945
6a653c300631
(syms_of_eval): Doc fix for inhibit-quit.
Karl Heuer <kwzh@gnu.org>
parents:
13768
diff
changeset
|
1269 /* We can't return values to code which signaled an error, but we |
|
6a653c300631
(syms_of_eval): Doc fix for inhibit-quit.
Karl Heuer <kwzh@gnu.org>
parents:
13768
diff
changeset
|
1270 can continue code which has signaled a quit. */ |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1271 if (EQ (real_error_symbol, Qquit)) |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1272 return Qnil; |
|
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1273 else |
|
3973
ab06b106c490
(Fsignal): Clarify error message.
Richard M. Stallman <rms@gnu.org>
parents:
3703
diff
changeset
|
1274 error ("Cannot return from the debugger in an error"); |
|
1196
65e2edefe748
* eval.c (Fcondition_case): Rearranged for clarity. Don't worry
Jim Blandy <jimb@redhat.com>
parents:
940
diff
changeset
|
1275 } |
| 272 | 1276 #endif |
| 1277 | |
| 485 | 1278 if (!NILP (clause)) |
| 272 | 1279 { |
|
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1280 Lisp_Object unwind_data; |
| 272 | 1281 struct handler *h = handlerlist; |
|
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1282 |
| 272 | 1283 handlerlist = allhandlers; |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1284 |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1285 if (NILP (error_symbol)) |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1286 unwind_data = data; |
|
6132
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1287 else |
|
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1288 unwind_data = Fcons (error_symbol, data); |
|
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1289 h->chosen_clause = clause; |
|
ddf57829cf03
(Fsignal): If DATA is memory_signal_data, don't add to it.
Richard M. Stallman <rms@gnu.org>
parents:
5807
diff
changeset
|
1290 unwind_to_catch (h->tag, unwind_data); |
| 272 | 1291 } |
| 1292 } | |
| 1293 | |
| 1294 handlerlist = allhandlers; | |
| 1295 /* If no handler is present now, try to run the debugger, | |
| 1296 and if that fails, throw to top level. */ | |
|
5566
e2925466c923
(Fsignal): Rename 1st arg to error_symbol.
Richard M. Stallman <rms@gnu.org>
parents:
5563
diff
changeset
|
1297 find_handler_clause (Qerror, conditions, error_symbol, data, &debugger_value); |
|
16895
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1298 if (catchlist != 0) |
|
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1299 Fthrow (Qtop_level, Qt); |
|
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1300 |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1301 if (! NILP (error_symbol)) |
|
16895
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1302 data = Fcons (error_symbol, data); |
|
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1303 |
|
32945f27ed20
(Fsignal): Call fatal if no error handlers and no catch.
Richard M. Stallman <rms@gnu.org>
parents:
16485
diff
changeset
|
1304 string = Ferror_message_string (data); |
|
23578
a4b29402f761
(Fsignal): Use a separate format string when passing
Andreas Schwab <schwab@suse.de>
parents:
23206
diff
changeset
|
1305 fatal ("%s", XSTRING (string)->data, 0); |
| 272 | 1306 } |
| 1307 | |
| 684 | 1308 /* Return nonzero iff LIST is a non-nil atom or |
| 1309 a list containing one of CONDITIONS. */ | |
| 1310 | |
| 1311 static int | |
| 1312 wants_debugger (list, conditions) | |
| 1313 Lisp_Object list, conditions; | |
| 1314 { | |
|
706
86cb5db0b6c3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
1315 if (NILP (list)) |
| 684 | 1316 return 0; |
| 1317 if (! CONSP (list)) | |
| 1318 return 1; | |
| 1319 | |
|
878
5b1c5b4286e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
863
diff
changeset
|
1320 while (CONSP (conditions)) |
| 684 | 1321 { |
|
878
5b1c5b4286e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
863
diff
changeset
|
1322 Lisp_Object this, tail; |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1323 this = XCAR (conditions); |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1324 for (tail = list; CONSP (tail); tail = XCDR (tail)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1325 if (EQ (XCAR (tail), this)) |
| 684 | 1326 return 1; |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1327 conditions = XCDR (conditions); |
| 684 | 1328 } |
|
878
5b1c5b4286e7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
863
diff
changeset
|
1329 return 0; |
| 684 | 1330 } |
| 1331 | |
| 13768 | 1332 /* Return 1 if an error with condition-symbols CONDITIONS, |
| 1333 and described by SIGNAL-DATA, should skip the debugger | |
| 1334 according to debugger-ignore-errors. */ | |
| 1335 | |
| 1336 static int | |
| 1337 skip_debugger (conditions, data) | |
| 1338 Lisp_Object conditions, data; | |
| 1339 { | |
| 1340 Lisp_Object tail; | |
| 1341 int first_string = 1; | |
| 1342 Lisp_Object error_message; | |
| 1343 | |
| 1344 for (tail = Vdebug_ignored_errors; CONSP (tail); | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1345 tail = XCDR (tail)) |
| 13768 | 1346 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1347 if (STRINGP (XCAR (tail))) |
| 13768 | 1348 { |
| 1349 if (first_string) | |
| 1350 { | |
| 1351 error_message = Ferror_message_string (data); | |
| 1352 first_string = 0; | |
| 1353 } | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1354 if (fast_string_match (XCAR (tail), error_message) >= 0) |
| 13768 | 1355 return 1; |
| 1356 } | |
| 1357 else | |
| 1358 { | |
| 1359 Lisp_Object contail; | |
| 1360 | |
| 1361 for (contail = conditions; CONSP (contail); | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1362 contail = XCDR (contail)) |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1363 if (EQ (XCAR (tail), XCAR (contail))) |
| 13768 | 1364 return 1; |
| 1365 } | |
| 1366 } | |
| 1367 | |
| 1368 return 0; | |
| 1369 } | |
| 1370 | |
| 684 | 1371 /* Value of Qlambda means we have called debugger and user has continued. |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1372 There are two ways to pass SIG and DATA: |
|
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1373 = SIG is the error symbol, and DATA is the rest of the data. |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1374 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). |
|
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1375 This is for memory-full errors only. |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1376 |
| 684 | 1377 Store value returned from debugger into *DEBUGGER_VALUE_PTR. */ |
| 272 | 1378 |
| 1379 static Lisp_Object | |
| 1380 find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr) | |
| 1381 Lisp_Object handlers, conditions, sig, data; | |
| 1382 Lisp_Object *debugger_value_ptr; | |
| 1383 { | |
| 1384 register Lisp_Object h; | |
| 1385 register Lisp_Object tem; | |
| 1386 | |
| 1387 if (EQ (handlers, Qt)) /* t is used by handlers for all conditions, set up by C code. */ | |
| 1388 return Qt; | |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1389 /* error is used similarly, but means print an error message |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1390 and run the debugger if that is enabled. */ |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1391 if (EQ (handlers, Qerror) |
|
16443
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
1392 || !NILP (Vdebug_on_signal)) /* This says call debugger even if |
|
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
1393 there is a handler. */ |
| 272 | 1394 { |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1395 int count = specpdl_ptr - specpdl; |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1396 int debugger_called = 0; |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1397 Lisp_Object sig_symbol, combined_data; |
|
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1398 /* This is set to 1 if we are handling a memory-full error, |
|
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1399 because these must not run the debugger. |
|
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1400 (There is no room in memory to do that!) */ |
|
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1401 int no_debugger = 0; |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1402 |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1403 if (NILP (sig)) |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1404 { |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1405 combined_data = data; |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1406 sig_symbol = Fcar (data); |
|
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1407 no_debugger = 1; |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1408 } |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1409 else |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1410 { |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1411 combined_data = Fcons (sig, data); |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1412 sig_symbol = sig; |
|
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1413 } |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1414 |
| 684 | 1415 if (wants_debugger (Vstack_trace_on_error, conditions)) |
|
21853
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1416 { |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1417 #ifdef __STDC__ |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1418 internal_with_output_to_temp_buffer ("*Backtrace*", |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1419 (Lisp_Object (*) (Lisp_Object)) Fbacktrace, |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1420 Qnil); |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1421 #else |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1422 internal_with_output_to_temp_buffer ("*Backtrace*", |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1423 Fbacktrace, Qnil); |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1424 #endif |
|
6e93713b7d30
(find_handler_clause): Cast Fbacktrace to proper type.
Richard M. Stallman <rms@gnu.org>
parents:
21699
diff
changeset
|
1425 } |
|
24054
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1426 if (! no_debugger |
|
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1427 && (EQ (sig_symbol, Qquit) |
|
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1428 ? debug_on_quit |
|
19ff7845d5f7
(find_handler_clause): If SIG is nil (memory full error),
Richard M. Stallman <rms@gnu.org>
parents:
23578
diff
changeset
|
1429 : wants_debugger (Vdebug_on_error, conditions)) |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1430 && ! skip_debugger (conditions, combined_data) |
|
17872
31b2c6763574
(num_nonmacro_input_events):
Richard M. Stallman <rms@gnu.org>
parents:
17275
diff
changeset
|
1431 && when_entered_debugger < num_nonmacro_input_events) |
| 272 | 1432 { |
| 1433 specbind (Qdebug_on_error, Qnil); | |
| 13768 | 1434 *debugger_value_ptr |
| 1435 = call_debugger (Fcons (Qerror, | |
|
18636
b3f3cd32fa70
(Fsignal, find_handler_clause): If ERROR_SYMBOL
Richard M. Stallman <rms@gnu.org>
parents:
18018
diff
changeset
|
1436 Fcons (combined_data, Qnil))); |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1437 debugger_called = 1; |
| 272 | 1438 } |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1439 /* If there is no handler, return saying whether we ran the debugger. */ |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1440 if (EQ (handlers, Qerror)) |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1441 { |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1442 if (debugger_called) |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1443 return unbind_to (count, Qlambda); |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1444 return Qt; |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
1445 } |
| 272 | 1446 } |
| 1447 for (h = handlers; CONSP (h); h = Fcdr (h)) | |
| 1448 { | |
|
5563
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1449 Lisp_Object handler, condit; |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1450 |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1451 handler = Fcar (h); |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1452 if (!CONSP (handler)) |
| 272 | 1453 continue; |
|
5563
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1454 condit = Fcar (handler); |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1455 /* Handle a single condition name in handler HANDLER. */ |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1456 if (SYMBOLP (condit)) |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1457 { |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1458 tem = Fmemq (Fcar (handler), conditions); |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1459 if (!NILP (tem)) |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1460 return handler; |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1461 } |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1462 /* Handle a list of condition names in handler HANDLER. */ |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1463 else if (CONSP (condit)) |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1464 { |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1465 while (CONSP (condit)) |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1466 { |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1467 tem = Fmemq (Fcar (condit), conditions); |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1468 if (!NILP (tem)) |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1469 return handler; |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1470 condit = XCDR (condit); |
|
5563
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1471 } |
|
50ada322de3e
(Fcondition_case): Allow a list of condition names in a handler.
Richard M. Stallman <rms@gnu.org>
parents:
5254
diff
changeset
|
1472 } |
| 272 | 1473 } |
| 1474 return Qnil; | |
| 1475 } | |
| 1476 | |
| 1477 /* dump an error message; called like printf */ | |
| 1478 | |
| 1479 /* VARARGS 1 */ | |
| 1480 void | |
| 1481 error (m, a1, a2, a3) | |
| 1482 char *m; | |
|
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1483 char *a1, *a2, *a3; |
| 272 | 1484 { |
| 1485 char buf[200]; | |
|
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1486 int size = 200; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1487 int mlen; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1488 char *buffer = buf; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1489 char *args[3]; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1490 int allocated = 0; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1491 Lisp_Object string; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1492 |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1493 args[0] = a1; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1494 args[1] = a2; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1495 args[2] = a3; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1496 |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1497 mlen = strlen (m); |
| 272 | 1498 |
| 1499 while (1) | |
|
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1500 { |
|
23206
a9090a71e969
(error): After enlarging buffer, write to it, not to buf.
Karl Heuer <kwzh@gnu.org>
parents:
21853
diff
changeset
|
1501 int used = doprnt (buffer, size, m, m + mlen, 3, args); |
|
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1502 if (used < size) |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1503 break; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1504 size *= 2; |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1505 if (allocated) |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1506 buffer = (char *) xrealloc (buffer, size); |
|
7353
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1507 else |
|
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1508 { |
|
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1509 buffer = (char *) xmalloc (size); |
|
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1510 allocated = 1; |
|
334cececa42d
(error): Fix logic in call to xmalloc/xrealloc.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1511 } |
|
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1512 } |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1513 |
|
23206
a9090a71e969
(error): After enlarging buffer, write to it, not to buf.
Karl Heuer <kwzh@gnu.org>
parents:
21853
diff
changeset
|
1514 string = build_string (buffer); |
|
6225
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1515 if (allocated) |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1516 free (buffer); |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1517 |
|
8f92cf89ed7c
(error): Use doprnt. Make buffer larger as necessary.
Richard M. Stallman <rms@gnu.org>
parents:
6132
diff
changeset
|
1518 Fsignal (Qerror, Fcons (string, Qnil)); |
| 272 | 1519 } |
| 1520 | |
| 1521 DEFUN ("commandp", Fcommandp, Scommandp, 1, 1, 0, | |
| 1522 "T if FUNCTION makes provisions for interactive calling.\n\ | |
| 1523 This means it contains a description for how to read arguments to give it.\n\ | |
| 1524 The value is nil for an invalid function or a symbol with no function\n\ | |
| 1525 definition.\n\ | |
| 1526 \n\ | |
| 1527 Interactively callable functions include strings and vectors (treated\n\ | |
| 1528 as keyboard macros), lambda-expressions that contain a top-level call\n\ | |
| 1529 to `interactive', autoload definitions made by `autoload' with non-nil\n\ | |
| 1530 fourth argument, and some of the built-in functions of Lisp.\n\ | |
| 1531 \n\ | |
| 1532 Also, a symbol satisfies `commandp' if its function definition does so.") | |
| 1533 (function) | |
| 1534 Lisp_Object function; | |
| 1535 { | |
| 1536 register Lisp_Object fun; | |
| 1537 register Lisp_Object funcar; | |
| 1538 | |
| 1539 fun = function; | |
| 1540 | |
| 648 | 1541 fun = indirect_function (fun); |
| 1542 if (EQ (fun, Qunbound)) | |
| 1543 return Qnil; | |
| 272 | 1544 |
| 1545 /* Emacs primitives are interactive if their DEFUN specifies an | |
| 1546 interactive spec. */ | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1547 if (SUBRP (fun)) |
| 272 | 1548 { |
| 1549 if (XSUBR (fun)->prompt) | |
| 1550 return Qt; | |
| 1551 else | |
| 1552 return Qnil; | |
| 1553 } | |
| 1554 | |
| 1555 /* Bytecode objects are interactive if they are long enough to | |
| 1556 have an element whose index is COMPILED_INTERACTIVE, which is | |
| 1557 where the interactive spec is stored. */ | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1558 else if (COMPILEDP (fun)) |
| 10345 | 1559 return ((XVECTOR (fun)->size & PSEUDOVECTOR_SIZE_MASK) > COMPILED_INTERACTIVE |
| 272 | 1560 ? Qt : Qnil); |
| 1561 | |
| 1562 /* Strings and vectors are keyboard macros. */ | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1563 if (STRINGP (fun) || VECTORP (fun)) |
| 272 | 1564 return Qt; |
| 1565 | |
| 1566 /* Lists may represent commands. */ | |
| 1567 if (!CONSP (fun)) | |
| 1568 return Qnil; | |
| 1569 funcar = Fcar (fun); | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1570 if (!SYMBOLP (funcar)) |
| 272 | 1571 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
| 1572 if (EQ (funcar, Qlambda)) | |
| 1573 return Fassq (Qinteractive, Fcdr (Fcdr (fun))); | |
| 1574 if (EQ (funcar, Qmocklisp)) | |
| 1575 return Qt; /* All mocklisp functions can be called interactively */ | |
| 1576 if (EQ (funcar, Qautoload)) | |
| 1577 return Fcar (Fcdr (Fcdr (Fcdr (fun)))); | |
| 1578 else | |
| 1579 return Qnil; | |
| 1580 } | |
| 1581 | |
| 1582 /* ARGSUSED */ | |
| 1583 DEFUN ("autoload", Fautoload, Sautoload, 2, 5, 0, | |
| 1584 "Define FUNCTION to autoload from FILE.\n\ | |
| 1585 FUNCTION is a symbol; FILE is a file name string to pass to `load'.\n\ | |
| 1586 Third arg DOCSTRING is documentation for the function.\n\ | |
| 1587 Fourth arg INTERACTIVE if non-nil says function can be called interactively.\n\ | |
|
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1588 Fifth arg TYPE indicates the type of the object:\n\ |
|
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1589 nil or omitted says FUNCTION is a function,\n\ |
|
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1590 `keymap' says FUNCTION is really a keymap, and\n\ |
|
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1591 `macro' or t says FUNCTION is really a macro.\n\ |
| 272 | 1592 Third through fifth args give info about the real definition.\n\ |
| 1593 They default to nil.\n\ | |
| 1594 If FUNCTION is already defined other than as an autoload,\n\ | |
| 1595 this does nothing and returns nil.") | |
|
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1596 (function, file, docstring, interactive, type) |
|
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1597 Lisp_Object function, file, docstring, interactive, type; |
| 272 | 1598 { |
| 1599 #ifdef NO_ARG_ARRAY | |
| 1600 Lisp_Object args[4]; | |
| 1601 #endif | |
| 1602 | |
| 1603 CHECK_SYMBOL (function, 0); | |
| 1604 CHECK_STRING (file, 1); | |
| 1605 | |
| 1606 /* If function is defined and not as an autoload, don't override */ | |
| 1607 if (!EQ (XSYMBOL (function)->function, Qunbound) | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1608 && !(CONSP (XSYMBOL (function)->function) |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1609 && EQ (XCAR (XSYMBOL (function)->function), Qautoload))) |
| 272 | 1610 return Qnil; |
| 1611 | |
| 1612 #ifdef NO_ARG_ARRAY | |
| 1613 args[0] = file; | |
| 1614 args[1] = docstring; | |
| 1615 args[2] = interactive; | |
|
1564
b327816041d1
* eval.c (Fautoload): Renamed fifth argument TYPE. Document the
Jim Blandy <jimb@redhat.com>
parents:
1452
diff
changeset
|
1616 args[3] = type; |
| 272 | 1617 |
| 1618 return Ffset (function, Fcons (Qautoload, Flist (4, &args[0]))); | |
| 1619 #else /* NO_ARG_ARRAY */ | |
| 1620 return Ffset (function, Fcons (Qautoload, Flist (4, &file))); | |
| 1621 #endif /* not NO_ARG_ARRAY */ | |
| 1622 } | |
| 1623 | |
| 1624 Lisp_Object | |
| 1625 un_autoload (oldqueue) | |
| 1626 Lisp_Object oldqueue; | |
| 1627 { | |
| 1628 register Lisp_Object queue, first, second; | |
| 1629 | |
| 1630 /* Queue to unwind is current value of Vautoload_queue. | |
| 1631 oldqueue is the shadowed value to leave in Vautoload_queue. */ | |
| 1632 queue = Vautoload_queue; | |
| 1633 Vautoload_queue = oldqueue; | |
| 1634 while (CONSP (queue)) | |
| 1635 { | |
| 1636 first = Fcar (queue); | |
| 1637 second = Fcdr (first); | |
| 1638 first = Fcar (first); | |
| 1639 if (EQ (second, Qnil)) | |
| 1640 Vfeatures = first; | |
| 1641 else | |
| 1642 Ffset (first, second); | |
| 1643 queue = Fcdr (queue); | |
| 1644 } | |
| 1645 return Qnil; | |
| 1646 } | |
| 1647 | |
|
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1648 /* Load an autoloaded function. |
|
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1649 FUNNAME is the symbol which is the function's name. |
|
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1650 FUNDEF is the autoload definition (a list). */ |
|
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1651 |
|
20378
cf1b52f5c34a
(do_autoload): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20312
diff
changeset
|
1652 void |
| 272 | 1653 do_autoload (fundef, funname) |
| 1654 Lisp_Object fundef, funname; | |
| 1655 { | |
| 1656 int count = specpdl_ptr - specpdl; | |
|
25783
17eb5827f07b
(Fsignal): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25662
diff
changeset
|
1657 Lisp_Object fun, queue, first, second; |
|
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1658 struct gcpro gcpro1, gcpro2, gcpro3; |
| 272 | 1659 |
| 1660 fun = funname; | |
| 1661 CHECK_SYMBOL (funname, 0); | |
|
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1662 GCPRO3 (fun, funname, fundef); |
| 272 | 1663 |
|
24605
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1664 /* Preserve the match data. */ |
|
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1665 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); |
|
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1666 |
|
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1667 /* Value saved here is to be restored into Vautoload_queue. */ |
| 272 | 1668 record_unwind_protect (un_autoload, Vautoload_queue); |
| 1669 Vautoload_queue = Qt; | |
|
19237
42cc2b7bc6c6
(do_autoload): Require a suffix for the file.
Richard M. Stallman <rms@gnu.org>
parents:
19116
diff
changeset
|
1670 Fload (Fcar (Fcdr (fundef)), Qnil, noninteractive ? Qt : Qnil, Qnil, Qt); |
|
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1671 |
|
24605
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1672 /* Save the old autoloads, in case we ever do an unload. */ |
|
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1673 queue = Vautoload_queue; |
|
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1674 while (CONSP (queue)) |
|
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1675 { |
|
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1676 first = Fcar (queue); |
|
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1677 second = Fcdr (first); |
|
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1678 first = Fcar (first); |
|
2599
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1679 |
|
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1680 /* Note: This test is subtle. The cdr of an autoload-queue entry |
|
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1681 may be an atom if the autoload entry was generated by a defalias |
|
24605
f378efa4aa8a
(do_autoload): Preserve match data.
Richard M. Stallman <rms@gnu.org>
parents:
24427
diff
changeset
|
1682 or fset. */ |
|
2599
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1683 if (CONSP (second)) |
| 4782 | 1684 Fput (first, Qautoload, (Fcdr (second))); |
|
2599
5122736c0a03
(do_autoload): Fixed the bug in the autoload-saving code.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2596
diff
changeset
|
1685 |
|
2547
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1686 queue = Fcdr (queue); |
|
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1687 } |
|
c73c68a87cd5
(defun, defmacro, defvar, defconst):
Richard M. Stallman <rms@gnu.org>
parents:
2439
diff
changeset
|
1688 |
| 272 | 1689 /* Once loading finishes, don't undo it. */ |
| 1690 Vautoload_queue = Qt; | |
| 1691 unbind_to (count, Qnil); | |
| 1692 | |
| 648 | 1693 fun = Findirect_function (fun); |
| 1694 | |
|
4462
9fbc6c74cab5
(do_autoload): Don't report autoload failure
Richard M. Stallman <rms@gnu.org>
parents:
4167
diff
changeset
|
1695 if (!NILP (Fequal (fun, fundef))) |
| 272 | 1696 error ("Autoloading failed to define function %s", |
| 1697 XSYMBOL (funname)->name->data); | |
|
16108
2c9c0c867e00
(Fmacroexpand): gcpro form while calling do_autoload.
Richard M. Stallman <rms@gnu.org>
parents:
15275
diff
changeset
|
1698 UNGCPRO; |
| 272 | 1699 } |
| 1700 | |
| 1701 DEFUN ("eval", Feval, Seval, 1, 1, 0, | |
| 1702 "Evaluate FORM and return its value.") | |
| 1703 (form) | |
| 1704 Lisp_Object form; | |
| 1705 { | |
| 1706 Lisp_Object fun, val, original_fun, original_args; | |
| 1707 Lisp_Object funcar; | |
| 1708 struct backtrace backtrace; | |
| 1709 struct gcpro gcpro1, gcpro2, gcpro3; | |
| 1710 | |
|
25008
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1711 /* Since Fsignal resets this to 0, it had better be 0 now |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1712 or else we have a potential bug. */ |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1713 if (interrupt_input_blocked != 0) |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1714 abort (); |
|
39dd5c98a114
(Fsignal): Reset redisplaying_p to zero.
Gerd Moellmann <gerd@gnu.org>
parents:
24605
diff
changeset
|
1715 |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1716 if (SYMBOLP (form)) |
| 272 | 1717 { |
| 1718 if (EQ (Vmocklisp_arguments, Qt)) | |
| 1719 return Fsymbol_value (form); | |
| 1720 val = Fsymbol_value (form); | |
| 485 | 1721 if (NILP (val)) |
|
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
1722 XSETFASTINT (val, 0); |
| 272 | 1723 else if (EQ (val, Qt)) |
|
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
1724 XSETFASTINT (val, 1); |
| 272 | 1725 return val; |
| 1726 } | |
| 1727 if (!CONSP (form)) | |
| 1728 return form; | |
| 1729 | |
| 1730 QUIT; | |
| 1731 if (consing_since_gc > gc_cons_threshold) | |
| 1732 { | |
| 1733 GCPRO1 (form); | |
| 1734 Fgarbage_collect (); | |
| 1735 UNGCPRO; | |
| 1736 } | |
| 1737 | |
| 1738 if (++lisp_eval_depth > max_lisp_eval_depth) | |
| 1739 { | |
| 1740 if (max_lisp_eval_depth < 100) | |
| 1741 max_lisp_eval_depth = 100; | |
| 1742 if (lisp_eval_depth > max_lisp_eval_depth) | |
| 1743 error ("Lisp nesting exceeds max-lisp-eval-depth"); | |
| 1744 } | |
| 1745 | |
| 1746 original_fun = Fcar (form); | |
| 1747 original_args = Fcdr (form); | |
| 1748 | |
| 1749 backtrace.next = backtrace_list; | |
| 1750 backtrace_list = &backtrace; | |
| 1751 backtrace.function = &original_fun; /* This also protects them from gc */ | |
| 1752 backtrace.args = &original_args; | |
| 1753 backtrace.nargs = UNEVALLED; | |
| 1754 backtrace.evalargs = 1; | |
| 1755 backtrace.debug_on_exit = 0; | |
| 1756 | |
| 1757 if (debug_on_next_call) | |
| 1758 do_debug_on_call (Qt); | |
| 1759 | |
| 1760 /* At this point, only original_fun and original_args | |
| 1761 have values that will be used below */ | |
| 1762 retry: | |
| 648 | 1763 fun = Findirect_function (original_fun); |
| 272 | 1764 |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1765 if (SUBRP (fun)) |
| 272 | 1766 { |
| 1767 Lisp_Object numargs; | |
|
19544
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1768 Lisp_Object argvals[8]; |
| 272 | 1769 Lisp_Object args_left; |
| 1770 register int i, maxargs; | |
| 1771 | |
| 1772 args_left = original_args; | |
| 1773 numargs = Flength (args_left); | |
| 1774 | |
| 1775 if (XINT (numargs) < XSUBR (fun)->min_args || | |
| 1776 (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < XINT (numargs))) | |
| 1777 return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (numargs, Qnil))); | |
| 1778 | |
| 1779 if (XSUBR (fun)->max_args == UNEVALLED) | |
| 1780 { | |
| 1781 backtrace.evalargs = 0; | |
| 1782 val = (*XSUBR (fun)->function) (args_left); | |
| 1783 goto done; | |
| 1784 } | |
| 1785 | |
| 1786 if (XSUBR (fun)->max_args == MANY) | |
| 1787 { | |
| 1788 /* Pass a vector of evaluated arguments */ | |
| 1789 Lisp_Object *vals; | |
| 1790 register int argnum = 0; | |
| 1791 | |
| 1792 vals = (Lisp_Object *) alloca (XINT (numargs) * sizeof (Lisp_Object)); | |
| 1793 | |
| 1794 GCPRO3 (args_left, fun, fun); | |
| 1795 gcpro3.var = vals; | |
| 1796 gcpro3.nvars = 0; | |
| 1797 | |
| 485 | 1798 while (!NILP (args_left)) |
| 272 | 1799 { |
| 1800 vals[argnum++] = Feval (Fcar (args_left)); | |
| 1801 args_left = Fcdr (args_left); | |
| 1802 gcpro3.nvars = argnum; | |
| 1803 } | |
| 1804 | |
| 1805 backtrace.args = vals; | |
| 1806 backtrace.nargs = XINT (numargs); | |
| 1807 | |
| 1808 val = (*XSUBR (fun)->function) (XINT (numargs), vals); | |
| 323 | 1809 UNGCPRO; |
| 272 | 1810 goto done; |
| 1811 } | |
| 1812 | |
| 1813 GCPRO3 (args_left, fun, fun); | |
| 1814 gcpro3.var = argvals; | |
| 1815 gcpro3.nvars = 0; | |
| 1816 | |
| 1817 maxargs = XSUBR (fun)->max_args; | |
| 1818 for (i = 0; i < maxargs; args_left = Fcdr (args_left)) | |
| 1819 { | |
| 1820 argvals[i] = Feval (Fcar (args_left)); | |
| 1821 gcpro3.nvars = ++i; | |
| 1822 } | |
| 1823 | |
| 1824 UNGCPRO; | |
| 1825 | |
| 1826 backtrace.args = argvals; | |
| 1827 backtrace.nargs = XINT (numargs); | |
| 1828 | |
| 1829 switch (i) | |
| 1830 { | |
| 1831 case 0: | |
| 1832 val = (*XSUBR (fun)->function) (); | |
| 1833 goto done; | |
| 1834 case 1: | |
| 1835 val = (*XSUBR (fun)->function) (argvals[0]); | |
| 1836 goto done; | |
| 1837 case 2: | |
| 1838 val = (*XSUBR (fun)->function) (argvals[0], argvals[1]); | |
| 1839 goto done; | |
| 1840 case 3: | |
| 1841 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], | |
| 1842 argvals[2]); | |
| 1843 goto done; | |
| 1844 case 4: | |
| 1845 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], | |
| 1846 argvals[2], argvals[3]); | |
| 1847 goto done; | |
| 1848 case 5: | |
| 1849 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], | |
| 1850 argvals[3], argvals[4]); | |
| 1851 goto done; | |
| 1852 case 6: | |
| 1853 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], | |
| 1854 argvals[3], argvals[4], argvals[5]); | |
| 1855 goto done; | |
|
863
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1856 case 7: |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1857 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1858 argvals[3], argvals[4], argvals[5], |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1859 argvals[6]); |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
1860 goto done; |
| 272 | 1861 |
|
19544
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1862 case 8: |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1863 val = (*XSUBR (fun)->function) (argvals[0], argvals[1], argvals[2], |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1864 argvals[3], argvals[4], argvals[5], |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1865 argvals[6], argvals[7]); |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1866 goto done; |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
1867 |
| 272 | 1868 default: |
| 604 | 1869 /* Someone has created a subr that takes more arguments than |
| 1870 is supported by this code. We need to either rewrite the | |
| 1871 subr to use a different argument protocol, or add more | |
| 1872 cases to this switch. */ | |
| 1873 abort (); | |
| 272 | 1874 } |
| 1875 } | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1876 if (COMPILEDP (fun)) |
| 272 | 1877 val = apply_lambda (fun, original_args, 1); |
| 1878 else | |
| 1879 { | |
| 1880 if (!CONSP (fun)) | |
| 1881 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
| 1882 funcar = Fcar (fun); | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1883 if (!SYMBOLP (funcar)) |
| 272 | 1884 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
| 1885 if (EQ (funcar, Qautoload)) | |
| 1886 { | |
| 1887 do_autoload (fun, original_fun); | |
| 1888 goto retry; | |
| 1889 } | |
| 1890 if (EQ (funcar, Qmacro)) | |
| 1891 val = Feval (apply1 (Fcdr (fun), original_args)); | |
| 1892 else if (EQ (funcar, Qlambda)) | |
| 1893 val = apply_lambda (fun, original_args, 1); | |
| 1894 else if (EQ (funcar, Qmocklisp)) | |
| 1895 val = ml_apply (fun, original_args); | |
| 1896 else | |
| 1897 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
| 1898 } | |
| 1899 done: | |
| 1900 if (!EQ (Vmocklisp_arguments, Qt)) | |
| 1901 { | |
| 485 | 1902 if (NILP (val)) |
|
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
1903 XSETFASTINT (val, 0); |
| 272 | 1904 else if (EQ (val, Qt)) |
|
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
1905 XSETFASTINT (val, 1); |
| 272 | 1906 } |
| 1907 lisp_eval_depth--; | |
| 1908 if (backtrace.debug_on_exit) | |
| 1909 val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); | |
| 1910 backtrace_list = backtrace.next; | |
| 1911 return val; | |
| 1912 } | |
| 1913 | |
| 1914 DEFUN ("apply", Fapply, Sapply, 2, MANY, 0, | |
| 1915 "Call FUNCTION with our remaining args, using our last arg as list of args.\n\ | |
|
12583
73ac42b9be24
(Ffuncall, Fapply): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11481
diff
changeset
|
1916 Then return the value FUNCTION returns.\n\ |
| 272 | 1917 Thus, (apply '+ 1 2 '(3 4)) returns 10.") |
| 1918 (nargs, args) | |
| 1919 int nargs; | |
| 1920 Lisp_Object *args; | |
| 1921 { | |
| 1922 register int i, numargs; | |
| 1923 register Lisp_Object spread_arg; | |
| 1924 register Lisp_Object *funcall_args; | |
| 1925 Lisp_Object fun; | |
| 323 | 1926 struct gcpro gcpro1; |
| 272 | 1927 |
| 1928 fun = args [0]; | |
| 1929 funcall_args = 0; | |
| 1930 spread_arg = args [nargs - 1]; | |
| 1931 CHECK_LIST (spread_arg, nargs); | |
| 1932 | |
| 1933 numargs = XINT (Flength (spread_arg)); | |
| 1934 | |
| 1935 if (numargs == 0) | |
| 1936 return Ffuncall (nargs - 1, args); | |
| 1937 else if (numargs == 1) | |
| 1938 { | |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1939 args [nargs - 1] = XCAR (spread_arg); |
| 272 | 1940 return Ffuncall (nargs, args); |
| 1941 } | |
| 1942 | |
| 323 | 1943 numargs += nargs - 2; |
| 272 | 1944 |
| 648 | 1945 fun = indirect_function (fun); |
| 1946 if (EQ (fun, Qunbound)) | |
| 272 | 1947 { |
| 648 | 1948 /* Let funcall get the error */ |
| 1949 fun = args[0]; | |
| 1950 goto funcall; | |
| 272 | 1951 } |
| 1952 | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
1953 if (SUBRP (fun)) |
| 272 | 1954 { |
| 1955 if (numargs < XSUBR (fun)->min_args | |
| 1956 || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) | |
| 1957 goto funcall; /* Let funcall get the error */ | |
| 1958 else if (XSUBR (fun)->max_args > numargs) | |
| 1959 { | |
| 1960 /* Avoid making funcall cons up a yet another new vector of arguments | |
| 1961 by explicitly supplying nil's for optional values */ | |
| 1962 funcall_args = (Lisp_Object *) alloca ((1 + XSUBR (fun)->max_args) | |
| 1963 * sizeof (Lisp_Object)); | |
| 1964 for (i = numargs; i < XSUBR (fun)->max_args;) | |
| 1965 funcall_args[++i] = Qnil; | |
| 323 | 1966 GCPRO1 (*funcall_args); |
| 1967 gcpro1.nvars = 1 + XSUBR (fun)->max_args; | |
| 272 | 1968 } |
| 1969 } | |
| 1970 funcall: | |
| 1971 /* We add 1 to numargs because funcall_args includes the | |
| 1972 function itself as well as its arguments. */ | |
| 1973 if (!funcall_args) | |
| 323 | 1974 { |
| 1975 funcall_args = (Lisp_Object *) alloca ((1 + numargs) | |
| 1976 * sizeof (Lisp_Object)); | |
| 1977 GCPRO1 (*funcall_args); | |
| 1978 gcpro1.nvars = 1 + numargs; | |
| 1979 } | |
| 1980 | |
| 272 | 1981 bcopy (args, funcall_args, nargs * sizeof (Lisp_Object)); |
| 1982 /* Spread the last arg we got. Its first element goes in | |
| 1983 the slot that it used to occupy, hence this value of I. */ | |
| 1984 i = nargs - 1; | |
| 485 | 1985 while (!NILP (spread_arg)) |
| 272 | 1986 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1987 funcall_args [i++] = XCAR (spread_arg); |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
1988 spread_arg = XCDR (spread_arg); |
| 272 | 1989 } |
| 323 | 1990 |
| 1991 RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args)); | |
| 272 | 1992 } |
| 1993 | |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1994 /* Run hook variables in various ways. */ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1995 |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1996 enum run_hooks_condition {to_completion, until_success, until_failure}; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1997 |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1998 DEFUN ("run-hooks", Frun_hooks, Srun_hooks, 1, MANY, 0, |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
1999 "Run each hook in HOOKS. Major mode functions use this.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2000 Each argument should be a symbol, a hook variable.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2001 These symbols are processed in the order specified.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2002 If a hook symbol has a non-nil value, that value may be a function\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2003 or a list of functions to be called to run the hook.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2004 If the value is a function, it is called with no arguments.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2005 If it is a list, the elements are called, in order, with no arguments.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2006 \n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2007 To make a hook variable buffer-local, use `make-local-hook',\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2008 not `make-local-variable'.") |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2009 (nargs, args) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2010 int nargs; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2011 Lisp_Object *args; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2012 { |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2013 Lisp_Object hook[1]; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2014 register int i; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2015 |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2016 for (i = 0; i < nargs; i++) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2017 { |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2018 hook[0] = args[i]; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2019 run_hook_with_args (1, hook, to_completion); |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2020 } |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2021 |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2022 return Qnil; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2023 } |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2024 |
|
16485
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2025 DEFUN ("run-hook-with-args", Frun_hook_with_args, |
|
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2026 Srun_hook_with_args, 1, MANY, 0, |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2027 "Run HOOK with the specified arguments ARGS.\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2028 HOOK should be a symbol, a hook variable. If HOOK has a non-nil\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2029 value, that value may be a function or a list of functions to be\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2030 called to run the hook. If the value is a function, it is called with\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2031 the given arguments and its return value is returned. If it is a list\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2032 of functions, those functions are called, in order,\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2033 with the given arguments ARGS.\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2034 It is best not to depend on the value return by `run-hook-with-args',\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2035 as that may change.\n\ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2036 \n\ |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2037 To make a hook variable buffer-local, use `make-local-hook',\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2038 not `make-local-variable'.") |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2039 (nargs, args) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2040 int nargs; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2041 Lisp_Object *args; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2042 { |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2043 return run_hook_with_args (nargs, args, to_completion); |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2044 } |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2045 |
|
16485
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2046 DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success, |
|
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2047 Srun_hook_with_args_until_success, 1, MANY, 0, |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2048 "Run HOOK with the specified arguments ARGS.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2049 HOOK should be a symbol, a hook variable. Its value should\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2050 be a list of functions. We call those functions, one by one,\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2051 passing arguments ARGS to each of them, until one of them\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2052 returns a non-nil value. Then we return that value.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2053 If all the functions return nil, we return nil.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2054 \n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2055 To make a hook variable buffer-local, use `make-local-hook',\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2056 not `make-local-variable'.") |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2057 (nargs, args) |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2058 int nargs; |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2059 Lisp_Object *args; |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2060 { |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2061 return run_hook_with_args (nargs, args, until_success); |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2062 } |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2063 |
|
16485
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2064 DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, |
|
9b919c5464a4
Reorganize function definitions so etags finds them.
Erik Naggum <erik@naggum.no>
parents:
16443
diff
changeset
|
2065 Srun_hook_with_args_until_failure, 1, MANY, 0, |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2066 "Run HOOK with the specified arguments ARGS.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2067 HOOK should be a symbol, a hook variable. Its value should\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2068 be a list of functions. We call those functions, one by one,\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2069 passing arguments ARGS to each of them, until one of them\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2070 returns nil. Then we return nil.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2071 If all the functions return non-nil, we return non-nil.\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2072 \n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2073 To make a hook variable buffer-local, use `make-local-hook',\n\ |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2074 not `make-local-variable'.") |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2075 (nargs, args) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2076 int nargs; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2077 Lisp_Object *args; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2078 { |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2079 return run_hook_with_args (nargs, args, until_failure); |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2080 } |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2081 |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2082 /* ARGS[0] should be a hook symbol. |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2083 Call each of the functions in the hook value, passing each of them |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2084 as arguments all the rest of ARGS (all NARGS - 1 elements). |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2085 COND specifies a condition to test after each call |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2086 to decide whether to stop. |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2087 The caller (or its caller, etc) must gcpro all of ARGS, |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2088 except that it isn't necessary to gcpro ARGS[0]. */ |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2089 |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2090 Lisp_Object |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2091 run_hook_with_args (nargs, args, cond) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2092 int nargs; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2093 Lisp_Object *args; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2094 enum run_hooks_condition cond; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2095 { |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2096 Lisp_Object sym, val, ret; |
|
25257
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2097 Lisp_Object globals; |
|
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2098 struct gcpro gcpro1, gcpro2, gcpro3; |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2099 |
|
14218
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2100 /* If we are dying or still initializing, |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2101 don't do anything--it would probably crash if we tried. */ |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2102 if (NILP (Vrun_hooks)) |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2103 return; |
|
346d4cf758f5
(run_hook_with_args): Do nothing if Vrun_hooks is nil.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
2104 |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2105 sym = args[0]; |
|
12663
14d407b83eb3
(run-hook-with-args): Fix previous code.
Karl Heuer <kwzh@gnu.org>
parents:
12654
diff
changeset
|
2106 val = find_symbol_value (sym); |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2107 ret = (cond == until_failure ? Qt : Qnil); |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2108 |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2109 if (EQ (val, Qunbound) || NILP (val)) |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2110 return ret; |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2111 else if (!CONSP (val) || EQ (XCAR (val), Qlambda)) |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2112 { |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2113 args[0] = val; |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2114 return Ffuncall (nargs, args); |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2115 } |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2116 else |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2117 { |
|
25257
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2118 globals = Qnil; |
|
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2119 GCPRO3 (sym, val, globals); |
|
12788
eceb3f25e115
(run_hook_with_args): Move the GCPRO2; add UNGCPRO.
Richard M. Stallman <rms@gnu.org>
parents:
12781
diff
changeset
|
2120 |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2121 for (; |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2122 CONSP (val) && ((cond == to_completion) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2123 || (cond == until_success ? NILP (ret) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2124 : !NILP (ret))); |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2125 val = XCDR (val)) |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2126 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2127 if (EQ (XCAR (val), Qt)) |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2128 { |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2129 /* t indicates this hook has a local binding; |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2130 it means to run the global binding too. */ |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2131 |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2132 for (globals = Fdefault_value (sym); |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2133 CONSP (globals) && ((cond == to_completion) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2134 || (cond == until_success ? NILP (ret) |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2135 : !NILP (ret))); |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2136 globals = XCDR (globals)) |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2137 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2138 args[0] = XCAR (globals); |
|
13444
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2139 /* In a global value, t should not occur. If it does, we |
|
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2140 must ignore it to avoid an endless loop. */ |
|
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2141 if (!EQ (args[0], Qt)) |
|
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2142 ret = Ffuncall (nargs, args); |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2143 } |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2144 } |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2145 else |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2146 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2147 args[0] = XCAR (val); |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2148 ret = Ffuncall (nargs, args); |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2149 } |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2150 } |
|
12788
eceb3f25e115
(run_hook_with_args): Move the GCPRO2; add UNGCPRO.
Richard M. Stallman <rms@gnu.org>
parents:
12781
diff
changeset
|
2151 |
|
eceb3f25e115
(run_hook_with_args): Move the GCPRO2; add UNGCPRO.
Richard M. Stallman <rms@gnu.org>
parents:
12781
diff
changeset
|
2152 UNGCPRO; |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2153 return ret; |
|
12654
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2154 } |
|
14721fd8dcc1
(Frun_hook_with_args): New C function, formerly in subr.el.
Karl Heuer <kwzh@gnu.org>
parents:
12583
diff
changeset
|
2155 } |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2156 |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2157 /* Run a hook symbol ARGS[0], but use FUNLIST instead of the actual |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2158 present value of that symbol. |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2159 Call each element of FUNLIST, |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2160 passing each of them the rest of ARGS. |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2161 The caller (or its caller, etc) must gcpro all of ARGS, |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2162 except that it isn't necessary to gcpro ARGS[0]. */ |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2163 |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2164 Lisp_Object |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2165 run_hook_list_with_args (funlist, nargs, args) |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2166 Lisp_Object funlist; |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2167 int nargs; |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2168 Lisp_Object *args; |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2169 { |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2170 Lisp_Object sym; |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2171 Lisp_Object val; |
|
25257
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2172 Lisp_Object globals; |
|
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2173 struct gcpro gcpro1, gcpro2, gcpro3; |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2174 |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2175 sym = args[0]; |
|
25257
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2176 globals = Qnil; |
|
0be923a80096
(run_hook_list_with_args): Gcpro `globals'.
Karl Heuer <kwzh@gnu.org>
parents:
25008
diff
changeset
|
2177 GCPRO3 (sym, val, globals); |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2178 |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2179 for (val = funlist; CONSP (val); val = XCDR (val)) |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2180 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2181 if (EQ (XCAR (val), Qt)) |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2182 { |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2183 /* t indicates this hook has a local binding; |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2184 it means to run the global binding too. */ |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2185 |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2186 for (globals = Fdefault_value (sym); |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2187 CONSP (globals); |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2188 globals = XCDR (globals)) |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2189 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2190 args[0] = XCAR (globals); |
|
13444
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2191 /* In a global value, t should not occur. If it does, we |
|
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2192 must ignore it to avoid an endless loop. */ |
|
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2193 if (!EQ (args[0], Qt)) |
|
17f3f1c1bdf8
(run-hook-with-args, run-hook-list-with-args): Safeguard
Richard M. Stallman <rms@gnu.org>
parents:
13314
diff
changeset
|
2194 Ffuncall (nargs, args); |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2195 } |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2196 } |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2197 else |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2198 { |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2199 args[0] = XCAR (val); |
|
12781
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2200 Ffuncall (nargs, args); |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2201 } |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2202 } |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2203 UNGCPRO; |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2204 return Qnil; |
|
2a8036f0b585
(run_hook_with_args): Add gcpros.
Richard M. Stallman <rms@gnu.org>
parents:
12732
diff
changeset
|
2205 } |
|
13103
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2206 |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2207 /* Run the hook HOOK, giving each function the two args ARG1 and ARG2. */ |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2208 |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2209 void |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2210 run_hook_with_args_2 (hook, arg1, arg2) |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2211 Lisp_Object hook, arg1, arg2; |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2212 { |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2213 Lisp_Object temp[3]; |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2214 temp[0] = hook; |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2215 temp[1] = arg1; |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2216 temp[2] = arg2; |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2217 |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2218 Frun_hook_with_args (3, temp); |
|
a537b52d6668
(run_hook_with_args_2): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12788
diff
changeset
|
2219 } |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
2220 |
| 272 | 2221 /* Apply fn to arg */ |
| 2222 Lisp_Object | |
| 2223 apply1 (fn, arg) | |
| 2224 Lisp_Object fn, arg; | |
| 2225 { | |
| 323 | 2226 struct gcpro gcpro1; |
| 2227 | |
| 2228 GCPRO1 (fn); | |
| 485 | 2229 if (NILP (arg)) |
| 323 | 2230 RETURN_UNGCPRO (Ffuncall (1, &fn)); |
| 2231 gcpro1.nvars = 2; | |
| 272 | 2232 #ifdef NO_ARG_ARRAY |
| 2233 { | |
| 2234 Lisp_Object args[2]; | |
| 2235 args[0] = fn; | |
| 2236 args[1] = arg; | |
| 323 | 2237 gcpro1.var = args; |
| 2238 RETURN_UNGCPRO (Fapply (2, args)); | |
| 272 | 2239 } |
| 2240 #else /* not NO_ARG_ARRAY */ | |
| 323 | 2241 RETURN_UNGCPRO (Fapply (2, &fn)); |
| 272 | 2242 #endif /* not NO_ARG_ARRAY */ |
| 2243 } | |
| 2244 | |
| 2245 /* Call function fn on no arguments */ | |
| 2246 Lisp_Object | |
| 2247 call0 (fn) | |
| 2248 Lisp_Object fn; | |
| 2249 { | |
| 323 | 2250 struct gcpro gcpro1; |
| 2251 | |
| 2252 GCPRO1 (fn); | |
| 2253 RETURN_UNGCPRO (Ffuncall (1, &fn)); | |
| 272 | 2254 } |
| 2255 | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2256 /* Call function fn with 1 argument arg1 */ |
| 272 | 2257 /* ARGSUSED */ |
| 2258 Lisp_Object | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2259 call1 (fn, arg1) |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2260 Lisp_Object fn, arg1; |
| 272 | 2261 { |
| 323 | 2262 struct gcpro gcpro1; |
| 272 | 2263 #ifdef NO_ARG_ARRAY |
| 323 | 2264 Lisp_Object args[2]; |
| 2265 | |
| 272 | 2266 args[0] = fn; |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2267 args[1] = arg1; |
| 323 | 2268 GCPRO1 (args[0]); |
| 2269 gcpro1.nvars = 2; | |
| 2270 RETURN_UNGCPRO (Ffuncall (2, args)); | |
| 272 | 2271 #else /* not NO_ARG_ARRAY */ |
| 323 | 2272 GCPRO1 (fn); |
| 2273 gcpro1.nvars = 2; | |
| 2274 RETURN_UNGCPRO (Ffuncall (2, &fn)); | |
| 272 | 2275 #endif /* not NO_ARG_ARRAY */ |
| 2276 } | |
| 2277 | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2278 /* Call function fn with 2 arguments arg1, arg2 */ |
| 272 | 2279 /* ARGSUSED */ |
| 2280 Lisp_Object | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2281 call2 (fn, arg1, arg2) |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2282 Lisp_Object fn, arg1, arg2; |
| 272 | 2283 { |
| 323 | 2284 struct gcpro gcpro1; |
| 272 | 2285 #ifdef NO_ARG_ARRAY |
| 2286 Lisp_Object args[3]; | |
| 2287 args[0] = fn; | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2288 args[1] = arg1; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2289 args[2] = arg2; |
| 323 | 2290 GCPRO1 (args[0]); |
| 2291 gcpro1.nvars = 3; | |
| 2292 RETURN_UNGCPRO (Ffuncall (3, args)); | |
| 272 | 2293 #else /* not NO_ARG_ARRAY */ |
| 323 | 2294 GCPRO1 (fn); |
| 2295 gcpro1.nvars = 3; | |
| 2296 RETURN_UNGCPRO (Ffuncall (3, &fn)); | |
| 272 | 2297 #endif /* not NO_ARG_ARRAY */ |
| 2298 } | |
| 2299 | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2300 /* Call function fn with 3 arguments arg1, arg2, arg3 */ |
| 272 | 2301 /* ARGSUSED */ |
| 2302 Lisp_Object | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2303 call3 (fn, arg1, arg2, arg3) |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2304 Lisp_Object fn, arg1, arg2, arg3; |
| 272 | 2305 { |
| 323 | 2306 struct gcpro gcpro1; |
| 272 | 2307 #ifdef NO_ARG_ARRAY |
| 2308 Lisp_Object args[4]; | |
| 2309 args[0] = fn; | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2310 args[1] = arg1; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2311 args[2] = arg2; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2312 args[3] = arg3; |
| 323 | 2313 GCPRO1 (args[0]); |
| 2314 gcpro1.nvars = 4; | |
| 2315 RETURN_UNGCPRO (Ffuncall (4, args)); | |
| 272 | 2316 #else /* not NO_ARG_ARRAY */ |
| 323 | 2317 GCPRO1 (fn); |
| 2318 gcpro1.nvars = 4; | |
| 2319 RETURN_UNGCPRO (Ffuncall (4, &fn)); | |
| 272 | 2320 #endif /* not NO_ARG_ARRAY */ |
| 2321 } | |
| 2322 | |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2323 /* Call function fn with 4 arguments arg1, arg2, arg3, arg4 */ |
|
3598
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2324 /* ARGSUSED */ |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2325 Lisp_Object |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2326 call4 (fn, arg1, arg2, arg3, arg4) |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2327 Lisp_Object fn, arg1, arg2, arg3, arg4; |
|
3598
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2328 { |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2329 struct gcpro gcpro1; |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2330 #ifdef NO_ARG_ARRAY |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2331 Lisp_Object args[5]; |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2332 args[0] = fn; |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2333 args[1] = arg1; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2334 args[2] = arg2; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2335 args[3] = arg3; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2336 args[4] = arg4; |
|
3598
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2337 GCPRO1 (args[0]); |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2338 gcpro1.nvars = 5; |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2339 RETURN_UNGCPRO (Ffuncall (5, args)); |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2340 #else /* not NO_ARG_ARRAY */ |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2341 GCPRO1 (fn); |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2342 gcpro1.nvars = 5; |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2343 RETURN_UNGCPRO (Ffuncall (5, &fn)); |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2344 #endif /* not NO_ARG_ARRAY */ |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2345 } |
|
3c4b5489d2b4
* fileio.c (Frename_file): Pass all arguments to the file name handler.
Jim Blandy <jimb@redhat.com>
parents:
2961
diff
changeset
|
2346 |
|
3703
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2347 /* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5 */ |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2348 /* ARGSUSED */ |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2349 Lisp_Object |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2350 call5 (fn, arg1, arg2, arg3, arg4, arg5) |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2351 Lisp_Object fn, arg1, arg2, arg3, arg4, arg5; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2352 { |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2353 struct gcpro gcpro1; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2354 #ifdef NO_ARG_ARRAY |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2355 Lisp_Object args[6]; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2356 args[0] = fn; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2357 args[1] = arg1; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2358 args[2] = arg2; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2359 args[3] = arg3; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2360 args[4] = arg4; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2361 args[5] = arg5; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2362 GCPRO1 (args[0]); |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2363 gcpro1.nvars = 6; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2364 RETURN_UNGCPRO (Ffuncall (6, args)); |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2365 #else /* not NO_ARG_ARRAY */ |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2366 GCPRO1 (fn); |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2367 gcpro1.nvars = 6; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2368 RETURN_UNGCPRO (Ffuncall (6, &fn)); |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2369 #endif /* not NO_ARG_ARRAY */ |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2370 } |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2371 |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2372 /* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6 */ |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2373 /* ARGSUSED */ |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2374 Lisp_Object |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2375 call6 (fn, arg1, arg2, arg3, arg4, arg5, arg6) |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2376 Lisp_Object fn, arg1, arg2, arg3, arg4, arg5, arg6; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2377 { |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2378 struct gcpro gcpro1; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2379 #ifdef NO_ARG_ARRAY |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2380 Lisp_Object args[7]; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2381 args[0] = fn; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2382 args[1] = arg1; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2383 args[2] = arg2; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2384 args[3] = arg3; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2385 args[4] = arg4; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2386 args[5] = arg5; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2387 args[6] = arg6; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2388 GCPRO1 (args[0]); |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2389 gcpro1.nvars = 7; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2390 RETURN_UNGCPRO (Ffuncall (7, args)); |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2391 #else /* not NO_ARG_ARRAY */ |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2392 GCPRO1 (fn); |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2393 gcpro1.nvars = 7; |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2394 RETURN_UNGCPRO (Ffuncall (7, &fn)); |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2395 #endif /* not NO_ARG_ARRAY */ |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2396 } |
|
6930e8f81c88
(call5, call6): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
3598
diff
changeset
|
2397 |
| 272 | 2398 DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, |
| 2399 "Call first argument as a function, passing remaining arguments to it.\n\ | |
|
12583
73ac42b9be24
(Ffuncall, Fapply): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11481
diff
changeset
|
2400 Return the value that function returns.\n\ |
| 272 | 2401 Thus, (funcall 'cons 'x 'y) returns (x . y).") |
| 2402 (nargs, args) | |
| 2403 int nargs; | |
| 2404 Lisp_Object *args; | |
| 2405 { | |
| 2406 Lisp_Object fun; | |
| 2407 Lisp_Object funcar; | |
| 2408 int numargs = nargs - 1; | |
| 2409 Lisp_Object lisp_numargs; | |
| 2410 Lisp_Object val; | |
| 2411 struct backtrace backtrace; | |
| 2412 register Lisp_Object *internal_args; | |
| 2413 register int i; | |
| 2414 | |
| 2415 QUIT; | |
| 2416 if (consing_since_gc > gc_cons_threshold) | |
| 323 | 2417 Fgarbage_collect (); |
| 272 | 2418 |
| 2419 if (++lisp_eval_depth > max_lisp_eval_depth) | |
| 2420 { | |
| 2421 if (max_lisp_eval_depth < 100) | |
| 2422 max_lisp_eval_depth = 100; | |
| 2423 if (lisp_eval_depth > max_lisp_eval_depth) | |
| 2424 error ("Lisp nesting exceeds max-lisp-eval-depth"); | |
| 2425 } | |
| 2426 | |
| 2427 backtrace.next = backtrace_list; | |
| 2428 backtrace_list = &backtrace; | |
| 2429 backtrace.function = &args[0]; | |
| 2430 backtrace.args = &args[1]; | |
| 2431 backtrace.nargs = nargs - 1; | |
| 2432 backtrace.evalargs = 0; | |
| 2433 backtrace.debug_on_exit = 0; | |
| 2434 | |
| 2435 if (debug_on_next_call) | |
| 2436 do_debug_on_call (Qlambda); | |
| 2437 | |
| 2438 retry: | |
| 2439 | |
| 2440 fun = args[0]; | |
| 648 | 2441 |
| 2442 fun = Findirect_function (fun); | |
| 272 | 2443 |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2444 if (SUBRP (fun)) |
| 272 | 2445 { |
| 2446 if (numargs < XSUBR (fun)->min_args | |
| 2447 || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) | |
| 2448 { | |
|
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
2449 XSETFASTINT (lisp_numargs, numargs); |
| 272 | 2450 return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (lisp_numargs, Qnil))); |
| 2451 } | |
| 2452 | |
| 2453 if (XSUBR (fun)->max_args == UNEVALLED) | |
| 2454 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
| 2455 | |
| 2456 if (XSUBR (fun)->max_args == MANY) | |
| 2457 { | |
| 2458 val = (*XSUBR (fun)->function) (numargs, args + 1); | |
| 2459 goto done; | |
| 2460 } | |
| 2461 | |
| 2462 if (XSUBR (fun)->max_args > numargs) | |
| 2463 { | |
| 2464 internal_args = (Lisp_Object *) alloca (XSUBR (fun)->max_args * sizeof (Lisp_Object)); | |
| 2465 bcopy (args + 1, internal_args, numargs * sizeof (Lisp_Object)); | |
| 2466 for (i = numargs; i < XSUBR (fun)->max_args; i++) | |
| 2467 internal_args[i] = Qnil; | |
| 2468 } | |
| 2469 else | |
| 2470 internal_args = args + 1; | |
| 2471 switch (XSUBR (fun)->max_args) | |
| 2472 { | |
| 2473 case 0: | |
| 2474 val = (*XSUBR (fun)->function) (); | |
| 2475 goto done; | |
| 2476 case 1: | |
| 2477 val = (*XSUBR (fun)->function) (internal_args[0]); | |
| 2478 goto done; | |
| 2479 case 2: | |
| 2480 val = (*XSUBR (fun)->function) (internal_args[0], | |
| 2481 internal_args[1]); | |
| 2482 goto done; | |
| 2483 case 3: | |
| 2484 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], | |
| 2485 internal_args[2]); | |
| 2486 goto done; | |
| 2487 case 4: | |
| 2488 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], | |
| 2489 internal_args[2], | |
| 2490 internal_args[3]); | |
| 2491 goto done; | |
| 2492 case 5: | |
| 2493 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], | |
| 2494 internal_args[2], internal_args[3], | |
| 2495 internal_args[4]); | |
| 2496 goto done; | |
| 2497 case 6: | |
| 2498 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], | |
| 2499 internal_args[2], internal_args[3], | |
| 2500 internal_args[4], internal_args[5]); | |
| 2501 goto done; | |
|
863
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2502 case 7: |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2503 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2504 internal_args[2], internal_args[3], |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2505 internal_args[4], internal_args[5], |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2506 internal_args[6]); |
|
427299469901
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
753
diff
changeset
|
2507 goto done; |
| 272 | 2508 |
|
19544
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2509 case 8: |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2510 val = (*XSUBR (fun)->function) (internal_args[0], internal_args[1], |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2511 internal_args[2], internal_args[3], |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2512 internal_args[4], internal_args[5], |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2513 internal_args[6], internal_args[7]); |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2514 goto done; |
|
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2515 |
| 272 | 2516 default: |
| 573 | 2517 |
|
19544
fc0bb24597ba
(Feval): Handle a subr which takes 8 arguments.
Kenichi Handa <handa@m17n.org>
parents:
19237
diff
changeset
|
2518 /* If a subr takes more than 8 arguments without using MANY |
| 573 | 2519 or UNEVALLED, we need to extend this function to support it. |
| 2520 Until this is done, there is no way to call the function. */ | |
| 2521 abort (); | |
| 272 | 2522 } |
| 2523 } | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2524 if (COMPILEDP (fun)) |
| 272 | 2525 val = funcall_lambda (fun, numargs, args + 1); |
| 2526 else | |
| 2527 { | |
| 2528 if (!CONSP (fun)) | |
| 2529 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
| 2530 funcar = Fcar (fun); | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2531 if (!SYMBOLP (funcar)) |
| 272 | 2532 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
| 2533 if (EQ (funcar, Qlambda)) | |
| 2534 val = funcall_lambda (fun, numargs, args + 1); | |
| 2535 else if (EQ (funcar, Qmocklisp)) | |
| 2536 val = ml_apply (fun, Flist (numargs, args + 1)); | |
| 2537 else if (EQ (funcar, Qautoload)) | |
| 2538 { | |
| 2539 do_autoload (fun, args[0]); | |
| 2540 goto retry; | |
| 2541 } | |
| 2542 else | |
| 2543 return Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | |
| 2544 } | |
| 2545 done: | |
| 2546 lisp_eval_depth--; | |
| 2547 if (backtrace.debug_on_exit) | |
| 2548 val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); | |
| 2549 backtrace_list = backtrace.next; | |
| 2550 return val; | |
| 2551 } | |
| 2552 | |
| 2553 Lisp_Object | |
| 2554 apply_lambda (fun, args, eval_flag) | |
| 2555 Lisp_Object fun, args; | |
| 2556 int eval_flag; | |
| 2557 { | |
| 2558 Lisp_Object args_left; | |
| 2559 Lisp_Object numargs; | |
| 2560 register Lisp_Object *arg_vector; | |
| 2561 struct gcpro gcpro1, gcpro2, gcpro3; | |
| 2562 register int i; | |
| 2563 register Lisp_Object tem; | |
| 2564 | |
| 2565 numargs = Flength (args); | |
| 2566 arg_vector = (Lisp_Object *) alloca (XINT (numargs) * sizeof (Lisp_Object)); | |
| 2567 args_left = args; | |
| 2568 | |
| 2569 GCPRO3 (*arg_vector, args_left, fun); | |
| 2570 gcpro1.nvars = 0; | |
| 2571 | |
| 2572 for (i = 0; i < XINT (numargs);) | |
| 2573 { | |
| 2574 tem = Fcar (args_left), args_left = Fcdr (args_left); | |
| 2575 if (eval_flag) tem = Feval (tem); | |
| 2576 arg_vector[i++] = tem; | |
| 2577 gcpro1.nvars = i; | |
| 2578 } | |
| 2579 | |
| 2580 UNGCPRO; | |
| 2581 | |
| 2582 if (eval_flag) | |
| 2583 { | |
| 2584 backtrace_list->args = arg_vector; | |
| 2585 backtrace_list->nargs = i; | |
| 2586 } | |
| 2587 backtrace_list->evalargs = 0; | |
| 2588 tem = funcall_lambda (fun, XINT (numargs), arg_vector); | |
| 2589 | |
| 2590 /* Do the debug-on-exit now, while arg_vector still exists. */ | |
| 2591 if (backtrace_list->debug_on_exit) | |
| 2592 tem = call_debugger (Fcons (Qexit, Fcons (tem, Qnil))); | |
| 2593 /* Don't do it again when we return to eval. */ | |
| 2594 backtrace_list->debug_on_exit = 0; | |
| 2595 return tem; | |
| 2596 } | |
| 2597 | |
| 2598 /* Apply a Lisp function FUN to the NARGS evaluated arguments in ARG_VECTOR | |
| 2599 and return the result of evaluation. | |
| 2600 FUN must be either a lambda-expression or a compiled-code object. */ | |
| 2601 | |
| 2602 Lisp_Object | |
| 2603 funcall_lambda (fun, nargs, arg_vector) | |
| 2604 Lisp_Object fun; | |
| 2605 int nargs; | |
| 2606 register Lisp_Object *arg_vector; | |
| 2607 { | |
| 2608 Lisp_Object val, tem; | |
| 2609 register Lisp_Object syms_left; | |
| 2610 Lisp_Object numargs; | |
| 2611 register Lisp_Object next; | |
| 2612 int count = specpdl_ptr - specpdl; | |
| 2613 register int i; | |
| 2614 int optional = 0, rest = 0; | |
| 2615 | |
| 2616 specbind (Qmocklisp_arguments, Qt); /* t means NOT mocklisp! */ | |
| 2617 | |
|
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
2618 XSETFASTINT (numargs, nargs); |
| 272 | 2619 |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2620 if (CONSP (fun)) |
| 272 | 2621 syms_left = Fcar (Fcdr (fun)); |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2622 else if (COMPILEDP (fun)) |
| 272 | 2623 syms_left = XVECTOR (fun)->contents[COMPILED_ARGLIST]; |
| 2624 else abort (); | |
| 2625 | |
| 2626 i = 0; | |
| 485 | 2627 for (; !NILP (syms_left); syms_left = Fcdr (syms_left)) |
| 272 | 2628 { |
| 2629 QUIT; | |
| 2630 next = Fcar (syms_left); | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2631 while (!SYMBOLP (next)) |
| 431 | 2632 next = Fsignal (Qinvalid_function, Fcons (fun, Qnil)); |
| 272 | 2633 if (EQ (next, Qand_rest)) |
| 2634 rest = 1; | |
| 2635 else if (EQ (next, Qand_optional)) | |
| 2636 optional = 1; | |
| 2637 else if (rest) | |
| 2638 { | |
| 431 | 2639 specbind (next, Flist (nargs - i, &arg_vector[i])); |
| 272 | 2640 i = nargs; |
| 2641 } | |
| 2642 else if (i < nargs) | |
| 2643 { | |
| 2644 tem = arg_vector[i++]; | |
| 2645 specbind (next, tem); | |
| 2646 } | |
| 2647 else if (!optional) | |
| 2648 return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (numargs, Qnil))); | |
| 2649 else | |
| 2650 specbind (next, Qnil); | |
| 2651 } | |
| 2652 | |
| 2653 if (i < nargs) | |
| 2654 return Fsignal (Qwrong_number_of_arguments, Fcons (fun, Fcons (numargs, Qnil))); | |
| 2655 | |
|
9148
e7ab930bb7eb
(Fprogn, Finteractive_p, Fuser_variable_p, FletX, Flet, Fmacroexpand,
Karl Heuer <kwzh@gnu.org>
parents:
8980
diff
changeset
|
2656 if (CONSP (fun)) |
| 272 | 2657 val = Fprogn (Fcdr (Fcdr (fun))); |
| 2658 else | |
|
10201
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2659 { |
|
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2660 /* If we have not actually read the bytecode string |
|
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2661 and constants vector yet, fetch them from the file. */ |
|
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2662 if (CONSP (XVECTOR (fun)->contents[COMPILED_BYTECODE])) |
|
11205
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2663 Ffetch_bytecode (fun); |
|
10201
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2664 val = Fbyte_code (XVECTOR (fun)->contents[COMPILED_BYTECODE], |
|
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2665 XVECTOR (fun)->contents[COMPILED_CONSTANTS], |
|
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2666 XVECTOR (fun)->contents[COMPILED_STACK_DEPTH]); |
|
03f3a1f4264a
(Fdefvar): Fix minor error in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10161
diff
changeset
|
2667 } |
| 272 | 2668 return unbind_to (count, val); |
| 2669 } | |
|
11205
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2670 |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2671 DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode, |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2672 1, 1, 0, |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2673 "If byte-compiled OBJECT is lazy-loaded, fetch it now.") |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2674 (object) |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2675 Lisp_Object object; |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2676 { |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2677 Lisp_Object tem; |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2678 |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2679 if (COMPILEDP (object) |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2680 && CONSP (XVECTOR (object)->contents[COMPILED_BYTECODE])) |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2681 { |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2682 tem = read_doc_string (XVECTOR (object)->contents[COMPILED_BYTECODE]); |
|
11481
af7833ecb551
(Ffetch_bytecode): Check the type of the object being read from the file.
Richard M. Stallman <rms@gnu.org>
parents:
11365
diff
changeset
|
2683 if (!CONSP (tem)) |
|
af7833ecb551
(Ffetch_bytecode): Check the type of the object being read from the file.
Richard M. Stallman <rms@gnu.org>
parents:
11365
diff
changeset
|
2684 error ("invalid byte code"); |
|
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2685 XVECTOR (object)->contents[COMPILED_BYTECODE] = XCAR (tem); |
|
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25314
diff
changeset
|
2686 XVECTOR (object)->contents[COMPILED_CONSTANTS] = XCDR (tem); |
|
11205
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2687 } |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2688 return object; |
|
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
2689 } |
| 272 | 2690 |
| 2691 void | |
| 2692 grow_specpdl () | |
| 2693 { | |
| 2694 register int count = specpdl_ptr - specpdl; | |
| 2695 if (specpdl_size >= max_specpdl_size) | |
| 2696 { | |
| 2697 if (max_specpdl_size < 400) | |
| 2698 max_specpdl_size = 400; | |
| 2699 if (specpdl_size >= max_specpdl_size) | |
| 2700 { | |
|
1452
ed79bb8047e8
(grow_specpdl): Increase max_specpdl_size before Fsignal.
Richard M. Stallman <rms@gnu.org>
parents:
1199
diff
changeset
|
2701 if (!NILP (Vdebug_on_error)) |
|
ed79bb8047e8
(grow_specpdl): Increase max_specpdl_size before Fsignal.
Richard M. Stallman <rms@gnu.org>
parents:
1199
diff
changeset
|
2702 /* Leave room for some specpdl in the debugger. */ |
|
ed79bb8047e8
(grow_specpdl): Increase max_specpdl_size before Fsignal.
Richard M. Stallman <rms@gnu.org>
parents:
1199
diff
changeset
|
2703 max_specpdl_size = specpdl_size + 100; |
| 272 | 2704 Fsignal (Qerror, |
| 2705 Fcons (build_string ("Variable binding depth exceeds max-specpdl-size"), Qnil)); | |
| 2706 } | |
| 2707 } | |
| 2708 specpdl_size *= 2; | |
| 2709 if (specpdl_size > max_specpdl_size) | |
| 2710 specpdl_size = max_specpdl_size; | |
| 2711 specpdl = (struct specbinding *) xrealloc (specpdl, specpdl_size * sizeof (struct specbinding)); | |
| 2712 specpdl_ptr = specpdl + count; | |
| 2713 } | |
| 2714 | |
| 2715 void | |
| 2716 specbind (symbol, value) | |
| 2717 Lisp_Object symbol, value; | |
| 2718 { | |
| 2719 Lisp_Object ovalue; | |
| 2720 | |
| 431 | 2721 CHECK_SYMBOL (symbol, 0); |
| 2722 | |
| 272 | 2723 if (specpdl_ptr == specpdl + specpdl_size) |
| 2724 grow_specpdl (); | |
| 2725 specpdl_ptr->symbol = symbol; | |
| 2726 specpdl_ptr->func = 0; | |
|
6826
903d03ddf99c
(specbind): Use find_symbol_value.
Richard M. Stallman <rms@gnu.org>
parents:
6803
diff
changeset
|
2727 specpdl_ptr->old_value = ovalue = find_symbol_value (symbol); |
| 272 | 2728 specpdl_ptr++; |
|
11007
433d4013f39b
(specbind): Rename perdisplay to kboard.
Karl Heuer <kwzh@gnu.org>
parents:
10604
diff
changeset
|
2729 if (BUFFER_OBJFWDP (ovalue) || KBOARD_OBJFWDP (ovalue)) |
| 272 | 2730 store_symval_forwarding (symbol, ovalue, value); |
| 2731 else | |
|
16930
e1aba4a05388
(unbind_to, specbind): Use set_internal.
Richard M. Stallman <rms@gnu.org>
parents:
16895
diff
changeset
|
2732 set_internal (symbol, value, 1); |
| 272 | 2733 } |
| 2734 | |
| 2735 void | |
| 2736 record_unwind_protect (function, arg) | |
|
20312
d75a1b915e20
(record_unwind_protect): Protoize parameter.
Andreas Schwab <schwab@suse.de>
parents:
19544
diff
changeset
|
2737 Lisp_Object (*function) P_ ((Lisp_Object)); |
| 272 | 2738 Lisp_Object arg; |
| 2739 { | |
| 2740 if (specpdl_ptr == specpdl + specpdl_size) | |
| 2741 grow_specpdl (); | |
| 2742 specpdl_ptr->func = function; | |
| 2743 specpdl_ptr->symbol = Qnil; | |
| 2744 specpdl_ptr->old_value = arg; | |
| 2745 specpdl_ptr++; | |
| 2746 } | |
| 2747 | |
| 2748 Lisp_Object | |
| 2749 unbind_to (count, value) | |
| 2750 int count; | |
| 2751 Lisp_Object value; | |
| 2752 { | |
| 485 | 2753 int quitf = !NILP (Vquit_flag); |
| 272 | 2754 struct gcpro gcpro1; |
| 2755 | |
| 2756 GCPRO1 (value); | |
| 2757 | |
| 2758 Vquit_flag = Qnil; | |
| 2759 | |
| 2760 while (specpdl_ptr != specpdl + count) | |
| 2761 { | |
| 2762 --specpdl_ptr; | |
| 2763 if (specpdl_ptr->func != 0) | |
| 2764 (*specpdl_ptr->func) (specpdl_ptr->old_value); | |
| 2765 /* Note that a "binding" of nil is really an unwind protect, | |
| 2766 so in that case the "old value" is a list of forms to evaluate. */ | |
| 485 | 2767 else if (NILP (specpdl_ptr->symbol)) |
| 272 | 2768 Fprogn (specpdl_ptr->old_value); |
| 2769 else | |
|
16930
e1aba4a05388
(unbind_to, specbind): Use set_internal.
Richard M. Stallman <rms@gnu.org>
parents:
16895
diff
changeset
|
2770 set_internal (specpdl_ptr->symbol, specpdl_ptr->old_value, 1); |
| 272 | 2771 } |
| 485 | 2772 if (NILP (Vquit_flag) && quitf) Vquit_flag = Qt; |
| 272 | 2773 |
| 2774 UNGCPRO; | |
| 2775 | |
| 2776 return value; | |
| 2777 } | |
| 2778 | |
| 2779 #if 0 | |
| 2780 | |
| 2781 /* Get the value of symbol's global binding, even if that binding | |
| 2782 is not now dynamically visible. */ | |
| 2783 | |
| 2784 Lisp_Object | |
| 2785 top_level_value (symbol) | |
| 2786 Lisp_Object symbol; | |
| 2787 { | |
| 2788 register struct specbinding *ptr = specpdl; | |
| 2789 | |
| 2790 CHECK_SYMBOL (symbol, 0); | |
| 2791 for (; ptr != specpdl_ptr; ptr++) | |
| 2792 { | |
| 2793 if (EQ (ptr->symbol, symbol)) | |
| 2794 return ptr->old_value; | |
| 2795 } | |
| 2796 return Fsymbol_value (symbol); | |
| 2797 } | |
| 2798 | |
| 2799 Lisp_Object | |
| 2800 top_level_set (symbol, newval) | |
| 2801 Lisp_Object symbol, newval; | |
| 2802 { | |
| 2803 register struct specbinding *ptr = specpdl; | |
| 2804 | |
| 2805 CHECK_SYMBOL (symbol, 0); | |
| 2806 for (; ptr != specpdl_ptr; ptr++) | |
| 2807 { | |
| 2808 if (EQ (ptr->symbol, symbol)) | |
| 2809 { | |
| 2810 ptr->old_value = newval; | |
| 2811 return newval; | |
| 2812 } | |
| 2813 } | |
| 2814 return Fset (symbol, newval); | |
| 2815 } | |
| 2816 | |
| 2817 #endif /* 0 */ | |
| 2818 | |
| 2819 DEFUN ("backtrace-debug", Fbacktrace_debug, Sbacktrace_debug, 2, 2, 0, | |
| 2820 "Set the debug-on-exit flag of eval frame LEVEL levels down to FLAG.\n\ | |
| 2821 The debugger is entered when that frame exits, if the flag is non-nil.") | |
| 2822 (level, flag) | |
| 2823 Lisp_Object level, flag; | |
| 2824 { | |
| 2825 register struct backtrace *backlist = backtrace_list; | |
| 2826 register int i; | |
| 2827 | |
| 2828 CHECK_NUMBER (level, 0); | |
| 2829 | |
| 2830 for (i = 0; backlist && i < XINT (level); i++) | |
| 2831 { | |
| 2832 backlist = backlist->next; | |
| 2833 } | |
| 2834 | |
| 2835 if (backlist) | |
| 485 | 2836 backlist->debug_on_exit = !NILP (flag); |
| 272 | 2837 |
| 2838 return flag; | |
| 2839 } | |
| 2840 | |
| 2841 DEFUN ("backtrace", Fbacktrace, Sbacktrace, 0, 0, "", | |
| 2842 "Print a trace of Lisp function calls currently active.\n\ | |
| 2843 Output stream used is value of `standard-output'.") | |
| 2844 () | |
| 2845 { | |
| 2846 register struct backtrace *backlist = backtrace_list; | |
| 2847 register int i; | |
| 2848 Lisp_Object tail; | |
| 2849 Lisp_Object tem; | |
| 2850 extern Lisp_Object Vprint_level; | |
| 2851 struct gcpro gcpro1; | |
| 2852 | |
|
9306
ac852c183fa1
(Feval, Ffuncall, funcall_lambda, Fbacktrace): Don't use XFASTINT as an
Karl Heuer <kwzh@gnu.org>
parents:
9148
diff
changeset
|
2853 XSETFASTINT (Vprint_level, 3); |
| 272 | 2854 |
| 2855 tail = Qnil; | |
| 2856 GCPRO1 (tail); | |
| 2857 | |
| 2858 while (backlist) | |
| 2859 { | |
| 2860 write_string (backlist->debug_on_exit ? "* " : " ", 2); | |
| 2861 if (backlist->nargs == UNEVALLED) | |
| 2862 { | |
| 2863 Fprin1 (Fcons (*backlist->function, *backlist->args), Qnil); | |
|
7533
62e3e25bc8f6
(Fbacktrace): Properly nest parentheses.
Karl Heuer <kwzh@gnu.org>
parents:
7511
diff
changeset
|
2864 write_string ("\n", -1); |
| 272 | 2865 } |
| 2866 else | |
| 2867 { | |
| 2868 tem = *backlist->function; | |
| 2869 Fprin1 (tem, Qnil); /* This can QUIT */ | |
| 2870 write_string ("(", -1); | |
| 2871 if (backlist->nargs == MANY) | |
| 2872 { | |
| 2873 for (tail = *backlist->args, i = 0; | |
| 485 | 2874 !NILP (tail); |
| 272 | 2875 tail = Fcdr (tail), i++) |
| 2876 { | |
| 2877 if (i) write_string (" ", -1); | |
| 2878 Fprin1 (Fcar (tail), Qnil); | |
| 2879 } | |
| 2880 } | |
| 2881 else | |
| 2882 { | |
| 2883 for (i = 0; i < backlist->nargs; i++) | |
| 2884 { | |
| 2885 if (i) write_string (" ", -1); | |
| 2886 Fprin1 (backlist->args[i], Qnil); | |
| 2887 } | |
| 2888 } | |
|
7533
62e3e25bc8f6
(Fbacktrace): Properly nest parentheses.
Karl Heuer <kwzh@gnu.org>
parents:
7511
diff
changeset
|
2889 write_string (")\n", -1); |
| 272 | 2890 } |
| 2891 backlist = backlist->next; | |
| 2892 } | |
| 2893 | |
| 2894 Vprint_level = Qnil; | |
| 2895 UNGCPRO; | |
| 2896 return Qnil; | |
| 2897 } | |
| 2898 | |
| 2899 DEFUN ("backtrace-frame", Fbacktrace_frame, Sbacktrace_frame, 1, 1, "", | |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
2900 "Return the function and arguments NFRAMES up from current execution point.\n\ |
| 272 | 2901 If that frame has not evaluated the arguments yet (or is a special form),\n\ |
| 2902 the value is (nil FUNCTION ARG-FORMS...).\n\ | |
| 2903 If that frame has evaluated its arguments and called its function already,\n\ | |
| 2904 the value is (t FUNCTION ARG-VALUES...).\n\ | |
| 2905 A &rest arg is represented as the tail of the list ARG-VALUES.\n\ | |
| 2906 FUNCTION is whatever was supplied as car of evaluated list,\n\ | |
| 2907 or a lambda expression for macro calls.\n\ | |
|
14073
0df4b4f2a2a1
(Fmacroexpand, Fthrow, Fbacktrace_frame): Harmonize arguments with
Erik Naggum <erik@naggum.no>
parents:
13945
diff
changeset
|
2908 If NFRAMES is more than the number of frames, the value is nil.") |
| 272 | 2909 (nframes) |
| 2910 Lisp_Object nframes; | |
| 2911 { | |
| 2912 register struct backtrace *backlist = backtrace_list; | |
| 2913 register int i; | |
| 2914 Lisp_Object tem; | |
| 2915 | |
| 2916 CHECK_NATNUM (nframes, 0); | |
| 2917 | |
| 2918 /* Find the frame requested. */ | |
|
7533
62e3e25bc8f6
(Fbacktrace): Properly nest parentheses.
Karl Heuer <kwzh@gnu.org>
parents:
7511
diff
changeset
|
2919 for (i = 0; backlist && i < XFASTINT (nframes); i++) |
| 272 | 2920 backlist = backlist->next; |
| 2921 | |
| 2922 if (!backlist) | |
| 2923 return Qnil; | |
| 2924 if (backlist->nargs == UNEVALLED) | |
| 2925 return Fcons (Qnil, Fcons (*backlist->function, *backlist->args)); | |
| 2926 else | |
| 2927 { | |
| 2928 if (backlist->nargs == MANY) | |
| 2929 tem = *backlist->args; | |
| 2930 else | |
| 2931 tem = Flist (backlist->nargs, backlist->args); | |
| 2932 | |
| 2933 return Fcons (Qt, Fcons (*backlist->function, tem)); | |
| 2934 } | |
| 2935 } | |
| 2936 | |
| 21514 | 2937 void |
| 272 | 2938 syms_of_eval () |
| 2939 { | |
| 2940 DEFVAR_INT ("max-specpdl-size", &max_specpdl_size, | |
|
18920
9c03cae980ed
(syms_of_eval): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18636
diff
changeset
|
2941 "*Limit on number of Lisp variable bindings & unwind-protects.\n\ |
|
9c03cae980ed
(syms_of_eval): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18636
diff
changeset
|
2942 If Lisp code tries to make more than this many at once,\n\ |
|
9c03cae980ed
(syms_of_eval): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18636
diff
changeset
|
2943 an error is signaled."); |
| 272 | 2944 |
| 2945 DEFVAR_INT ("max-lisp-eval-depth", &max_lisp_eval_depth, | |
|
18920
9c03cae980ed
(syms_of_eval): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
18636
diff
changeset
|
2946 "*Limit on depth in `eval', `apply' and `funcall' before error.\n\ |
| 272 | 2947 This limit is to catch infinite recursions for you before they cause\n\ |
| 2948 actual stack overflow in C, which would be fatal for Emacs.\n\ | |
| 2949 You can safely make it considerably larger than its default value,\n\ | |
| 2950 if that proves inconveniently small."); | |
| 2951 | |
| 2952 DEFVAR_LISP ("quit-flag", &Vquit_flag, | |
| 2953 "Non-nil causes `eval' to abort, unless `inhibit-quit' is non-nil.\n\ | |
|
7511
9ec3fc16ab3a
(syms_of_eval): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
7353
diff
changeset
|
2954 Typing C-g sets `quit-flag' non-nil, regardless of `inhibit-quit'."); |
| 272 | 2955 Vquit_flag = Qnil; |
| 2956 | |
| 2957 DEFVAR_LISP ("inhibit-quit", &Vinhibit_quit, | |
| 2958 "Non-nil inhibits C-g quitting from happening immediately.\n\ | |
| 2959 Note that `quit-flag' will still be set by typing C-g,\n\ | |
|
13945
6a653c300631
(syms_of_eval): Doc fix for inhibit-quit.
Karl Heuer <kwzh@gnu.org>
parents:
13768
diff
changeset
|
2960 so a quit will be signaled as soon as `inhibit-quit' is nil.\n\ |
| 272 | 2961 To prevent this happening, set `quit-flag' to nil\n\ |
| 2962 before making `inhibit-quit' nil."); | |
| 2963 Vinhibit_quit = Qnil; | |
| 2964 | |
| 381 | 2965 Qinhibit_quit = intern ("inhibit-quit"); |
| 2966 staticpro (&Qinhibit_quit); | |
| 2967 | |
| 272 | 2968 Qautoload = intern ("autoload"); |
| 2969 staticpro (&Qautoload); | |
| 2970 | |
| 2971 Qdebug_on_error = intern ("debug-on-error"); | |
| 2972 staticpro (&Qdebug_on_error); | |
| 2973 | |
| 2974 Qmacro = intern ("macro"); | |
| 2975 staticpro (&Qmacro); | |
| 2976 | |
| 2977 /* Note that the process handling also uses Qexit, but we don't want | |
| 2978 to staticpro it twice, so we just do it here. */ | |
| 2979 Qexit = intern ("exit"); | |
| 2980 staticpro (&Qexit); | |
| 2981 | |
| 2982 Qinteractive = intern ("interactive"); | |
| 2983 staticpro (&Qinteractive); | |
| 2984 | |
| 2985 Qcommandp = intern ("commandp"); | |
| 2986 staticpro (&Qcommandp); | |
| 2987 | |
| 2988 Qdefun = intern ("defun"); | |
| 2989 staticpro (&Qdefun); | |
| 2990 | |
| 2991 Qand_rest = intern ("&rest"); | |
| 2992 staticpro (&Qand_rest); | |
| 2993 | |
| 2994 Qand_optional = intern ("&optional"); | |
| 2995 staticpro (&Qand_optional); | |
| 2996 | |
| 684 | 2997 DEFVAR_LISP ("stack-trace-on-error", &Vstack_trace_on_error, |
| 272 | 2998 "*Non-nil means automatically display a backtrace buffer\n\ |
| 684 | 2999 after any error that is handled by the editor command loop.\n\ |
| 3000 If the value is a list, an error only means to display a backtrace\n\ | |
| 3001 if one of its condition symbols appears in the list."); | |
| 3002 Vstack_trace_on_error = Qnil; | |
| 272 | 3003 |
| 684 | 3004 DEFVAR_LISP ("debug-on-error", &Vdebug_on_error, |
| 272 | 3005 "*Non-nil means enter debugger if an error is signaled.\n\ |
| 3006 Does not apply to errors handled by `condition-case'.\n\ | |
| 684 | 3007 If the value is a list, an error only means to enter the debugger\n\ |
| 3008 if one of its condition symbols appears in the list.\n\ | |
| 272 | 3009 See also variable `debug-on-quit'."); |
| 684 | 3010 Vdebug_on_error = Qnil; |
| 272 | 3011 |
| 13768 | 3012 DEFVAR_LISP ("debug-ignored-errors", &Vdebug_ignored_errors, |
| 3013 "*List of errors for which the debugger should not be called.\n\ | |
| 3014 Each element may be a condition-name or a regexp that matches error messages.\n\ | |
| 3015 If any element applies to a given error, that error skips the debugger\n\ | |
| 3016 and just returns to top level.\n\ | |
| 3017 This overrides the variable `debug-on-error'.\n\ | |
| 3018 It does not apply to errors handled by `condition-case'."); | |
| 3019 Vdebug_ignored_errors = Qnil; | |
| 3020 | |
| 272 | 3021 DEFVAR_BOOL ("debug-on-quit", &debug_on_quit, |
|
7511
9ec3fc16ab3a
(syms_of_eval): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
7353
diff
changeset
|
3022 "*Non-nil means enter debugger if quit is signaled (C-g, for example).\n\ |
| 940 | 3023 Does not apply if quit is handled by a `condition-case'."); |
| 272 | 3024 debug_on_quit = 0; |
| 3025 | |
| 3026 DEFVAR_BOOL ("debug-on-next-call", &debug_on_next_call, | |
| 3027 "Non-nil means enter debugger before next `eval', `apply' or `funcall'."); | |
| 3028 | |
| 3029 DEFVAR_LISP ("debugger", &Vdebugger, | |
| 3030 "Function to call to invoke debugger.\n\ | |
| 3031 If due to frame exit, args are `exit' and the value being returned;\n\ | |
| 3032 this function's value will be returned instead of that.\n\ | |
| 3033 If due to error, args are `error' and a list of the args to `signal'.\n\ | |
| 3034 If due to `apply' or `funcall' entry, one arg, `lambda'.\n\ | |
| 3035 If due to `eval' entry, one arg, t."); | |
| 3036 Vdebugger = Qnil; | |
| 3037 | |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3038 DEFVAR_LISP ("signal-hook-function", &Vsignal_hook_function, |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3039 "If non-nil, this is a function for `signal' to call.\n\ |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3040 It receives the same arguments that `signal' was given.\n\ |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3041 The Edebug package uses this to regain control."); |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3042 Vsignal_hook_function = Qnil; |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3043 |
| 272 | 3044 Qmocklisp_arguments = intern ("mocklisp-arguments"); |
| 3045 staticpro (&Qmocklisp_arguments); | |
| 3046 DEFVAR_LISP ("mocklisp-arguments", &Vmocklisp_arguments, | |
| 3047 "While in a mocklisp function, the list of its unevaluated args."); | |
| 3048 Vmocklisp_arguments = Qt; | |
| 3049 | |
|
16443
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
3050 DEFVAR_LISP ("debug-on-signal", &Vdebug_on_signal, |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3051 "*Non-nil means call the debugger regardless of condition handlers.\n\ |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3052 Note that `debug-on-error', `debug-on-quit' and friends\n\ |
|
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3053 still determine whether to handle the particular condition."); |
|
16443
0128b923d281
(Vdebug_on_signal): Renamed from Vdebug_force.
Richard M. Stallman <rms@gnu.org>
parents:
16355
diff
changeset
|
3054 Vdebug_on_signal = Qnil; |
|
16355
1d85b2698564
(Vdebug_force): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16296
diff
changeset
|
3055 |
|
16296
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
3056 Vrun_hooks = intern ("run-hooks"); |
|
584310941e70
(syms_of_eval): Initialize Vrun_hooks here.
Richard M. Stallman <rms@gnu.org>
parents:
16113
diff
changeset
|
3057 staticpro (&Vrun_hooks); |
| 272 | 3058 |
| 3059 staticpro (&Vautoload_queue); | |
| 3060 Vautoload_queue = Qnil; | |
| 3061 | |
| 3062 defsubr (&Sor); | |
| 3063 defsubr (&Sand); | |
| 3064 defsubr (&Sif); | |
| 3065 defsubr (&Scond); | |
| 3066 defsubr (&Sprogn); | |
| 3067 defsubr (&Sprog1); | |
| 3068 defsubr (&Sprog2); | |
| 3069 defsubr (&Ssetq); | |
| 3070 defsubr (&Squote); | |
| 3071 defsubr (&Sfunction); | |
| 3072 defsubr (&Sdefun); | |
| 3073 defsubr (&Sdefmacro); | |
| 3074 defsubr (&Sdefvar); | |
| 3075 defsubr (&Sdefconst); | |
| 3076 defsubr (&Suser_variable_p); | |
| 3077 defsubr (&Slet); | |
| 3078 defsubr (&SletX); | |
| 3079 defsubr (&Swhile); | |
| 3080 defsubr (&Smacroexpand); | |
| 3081 defsubr (&Scatch); | |
| 3082 defsubr (&Sthrow); | |
| 3083 defsubr (&Sunwind_protect); | |
| 3084 defsubr (&Scondition_case); | |
| 3085 defsubr (&Ssignal); | |
| 3086 defsubr (&Sinteractive_p); | |
| 3087 defsubr (&Scommandp); | |
| 3088 defsubr (&Sautoload); | |
| 3089 defsubr (&Seval); | |
| 3090 defsubr (&Sapply); | |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
3091 defsubr (&Sfuncall); |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
3092 defsubr (&Srun_hooks); |
|
12711
a8feaa42d775
(syms_of_eval): Add missing defsubr.
Karl Heuer <kwzh@gnu.org>
parents:
12663
diff
changeset
|
3093 defsubr (&Srun_hook_with_args); |
|
12732
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
3094 defsubr (&Srun_hook_with_args_until_success); |
|
981b924c832b
Add Frun_hooks, Frun_hook_with_args, Frun_hook_with_args_until_success, Frun_hook_with_args_until_failure in terms of run_hook_with_args.
Simon Marshall <simon@gnu.org>
parents:
12711
diff
changeset
|
3095 defsubr (&Srun_hook_with_args_until_failure); |
|
11205
81a008df9184
(Ffetch_bytecode): New function.
Karl Heuer <kwzh@gnu.org>
parents:
11007
diff
changeset
|
3096 defsubr (&Sfetch_bytecode); |
| 272 | 3097 defsubr (&Sbacktrace_debug); |
| 3098 defsubr (&Sbacktrace); | |
| 3099 defsubr (&Sbacktrace_frame); | |
| 3100 } |
