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