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