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