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