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