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