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