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