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