Mercurial > emacs
annotate src/data.c @ 12124:437eb190e7a7
updated for 19.29.
author | Melissa Weisshaus <melissa@gnu.org> |
---|---|
date | Thu, 08 Jun 1995 04:16:18 +0000 |
parents | d96b45f31afa |
children | a0067d2edef7 |
rev | line source |
---|---|
298 | 1 /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter. |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10290
diff
changeset
|
2 Copyright (C) 1985, 86, 88, 93, 94, 95 Free Software Foundation, Inc. |
298 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
21 #include <signal.h> | |
22 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4508
diff
changeset
|
23 #include <config.h> |
298 | 24 #include "lisp.h" |
336 | 25 #include "puresize.h" |
298 | 26 |
27 #ifndef standalone | |
28 #include "buffer.h" | |
11341 | 29 #include "keyboard.h" |
298 | 30 #endif |
31 | |
552 | 32 #include "syssignal.h" |
348 | 33 |
5504
6d6d042b3df6
(Frem) [MSDOS]: use `fmod', not `drem'. Put in config.h?
Richard M. Stallman <rms@gnu.org>
parents:
4860
diff
changeset
|
34 #ifdef MSDOS |
7205
a5199564772e
[MSDOS]: Re-enable some #undef's.
Karl Heuer <kwzh@gnu.org>
parents:
6919
diff
changeset
|
35 /* These are redefined (correctly, but differently) in values.h. */ |
5504
6d6d042b3df6
(Frem) [MSDOS]: use `fmod', not `drem'. Put in config.h?
Richard M. Stallman <rms@gnu.org>
parents:
4860
diff
changeset
|
36 #undef INTBITS |
6d6d042b3df6
(Frem) [MSDOS]: use `fmod', not `drem'. Put in config.h?
Richard M. Stallman <rms@gnu.org>
parents:
4860
diff
changeset
|
37 #undef LONGBITS |
6d6d042b3df6
(Frem) [MSDOS]: use `fmod', not `drem'. Put in config.h?
Richard M. Stallman <rms@gnu.org>
parents:
4860
diff
changeset
|
38 #undef SHORTBITS |
6d6d042b3df6
(Frem) [MSDOS]: use `fmod', not `drem'. Put in config.h?
Richard M. Stallman <rms@gnu.org>
parents:
4860
diff
changeset
|
39 #endif |
6d6d042b3df6
(Frem) [MSDOS]: use `fmod', not `drem'. Put in config.h?
Richard M. Stallman <rms@gnu.org>
parents:
4860
diff
changeset
|
40 |
298 | 41 #ifdef LISP_FLOAT_TYPE |
4860
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
42 |
2781
fde05936aebb
* lread.c, data.c: If STDC_HEADERS is #defined, include <stdlib.h>
Jim Blandy <jimb@redhat.com>
parents:
2647
diff
changeset
|
43 #ifdef STDC_HEADERS |
fde05936aebb
* lread.c, data.c: If STDC_HEADERS is #defined, include <stdlib.h>
Jim Blandy <jimb@redhat.com>
parents:
2647
diff
changeset
|
44 #include <stdlib.h> |
fde05936aebb
* lread.c, data.c: If STDC_HEADERS is #defined, include <stdlib.h>
Jim Blandy <jimb@redhat.com>
parents:
2647
diff
changeset
|
45 #endif |
4860
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
46 |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
47 /* Work around a problem that happens because math.h on hpux 7 |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
48 defines two static variables--which, in Emacs, are not really static, |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
49 because `static' is defined as nothing. The problem is that they are |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
50 here, in floatfns.c, and in lread.c. |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
51 These macros prevent the name conflict. */ |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
52 #if defined (HPUX) && !defined (HPUX8) |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
53 #define _MAXLDBL data_c_maxldbl |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
54 #define _NMAXLDBL data_c_nmaxldbl |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
55 #endif |
ff23fe23f58c
[hpux 7] (_MAXLDBL, _NMAXLDBL): New macro definitions.
Richard M. Stallman <rms@gnu.org>
parents:
4780
diff
changeset
|
56 |
298 | 57 #include <math.h> |
58 #endif /* LISP_FLOAT_TYPE */ | |
59 | |
4780
64cdff1c8ad1
Add declaration for atof if not predefined.
Brian Fox <bfox@gnu.org>
parents:
4696
diff
changeset
|
60 #if !defined (atof) |
64cdff1c8ad1
Add declaration for atof if not predefined.
Brian Fox <bfox@gnu.org>
parents:
4696
diff
changeset
|
61 extern double atof (); |
64cdff1c8ad1
Add declaration for atof if not predefined.
Brian Fox <bfox@gnu.org>
parents:
4696
diff
changeset
|
62 #endif /* !atof */ |
64cdff1c8ad1
Add declaration for atof if not predefined.
Brian Fox <bfox@gnu.org>
parents:
4696
diff
changeset
|
63 |
298 | 64 Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound; |
65 Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; | |
66 Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range; | |
648 | 67 Lisp_Object Qvoid_variable, Qvoid_function, Qcyclic_function_indirection; |
298 | 68 Lisp_Object Qsetting_constant, Qinvalid_read_syntax; |
69 Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch; | |
4036 | 70 Lisp_Object Qend_of_file, Qarith_error, Qmark_inactive; |
298 | 71 Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only; |
6459
30fabcc03f0c
(Qwholenump): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6448
diff
changeset
|
72 Lisp_Object Qintegerp, Qnatnump, Qwholenump, Qsymbolp, Qlistp, Qconsp; |
298 | 73 Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp; |
74 Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp; | |
1293 | 75 Lisp_Object Qbuffer_or_string_p; |
298 | 76 Lisp_Object Qboundp, Qfboundp; |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
77 |
298 | 78 Lisp_Object Qcdr; |
8448
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
79 Lisp_Object Qad_advice_info, Qad_activate; |
298 | 80 |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
81 Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
82 Lisp_Object Qoverflow_error, Qunderflow_error; |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
83 |
298 | 84 #ifdef LISP_FLOAT_TYPE |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
85 Lisp_Object Qfloatp; |
298 | 86 Lisp_Object Qnumberp, Qnumber_or_marker_p; |
87 #endif | |
88 | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
89 static Lisp_Object Qinteger, Qsymbol, Qstring, Qcons, Qmarker, Qoverlay; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
90 static Lisp_Object Qfloat, Qwindow_configuration, Qprocess, Qwindow; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
91 static Lisp_Object Qcompiled_function, Qbuffer, Qframe, Qvector; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
92 |
298 | 93 static Lisp_Object swap_in_symval_forwarding (); |
94 | |
95 Lisp_Object | |
96 wrong_type_argument (predicate, value) | |
97 register Lisp_Object predicate, value; | |
98 { | |
99 register Lisp_Object tem; | |
100 do | |
101 { | |
102 if (!EQ (Vmocklisp_arguments, Qt)) | |
103 { | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
104 if (STRINGP (value) && |
298 | 105 (EQ (predicate, Qintegerp) || EQ (predicate, Qinteger_or_marker_p))) |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
106 return Fstring_to_number (value); |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
107 if (INTEGERP (value) && EQ (predicate, Qstringp)) |
2429
96b55f2f19cd
Rename int-to-string to number-to-string, since it can handle
Jim Blandy <jimb@redhat.com>
parents:
2092
diff
changeset
|
108 return Fnumber_to_string (value); |
298 | 109 } |
10245
f0637b2f1671
(wrong_type_argument): Abort if VALUE is invalid Lisp object.
Richard M. Stallman <rms@gnu.org>
parents:
9966
diff
changeset
|
110 |
f0637b2f1671
(wrong_type_argument): Abort if VALUE is invalid Lisp object.
Richard M. Stallman <rms@gnu.org>
parents:
9966
diff
changeset
|
111 /* If VALUE is not even a valid Lisp object, abort here |
f0637b2f1671
(wrong_type_argument): Abort if VALUE is invalid Lisp object.
Richard M. Stallman <rms@gnu.org>
parents:
9966
diff
changeset
|
112 where we can get a backtrace showing where it came from. */ |
10248
8b95a9a6d466
(wrong_type_argument): Use Lisp_Type_Limit.
Richard M. Stallman <rms@gnu.org>
parents:
10245
diff
changeset
|
113 if ((unsigned int) XGCTYPE (value) >= Lisp_Type_Limit) |
10245
f0637b2f1671
(wrong_type_argument): Abort if VALUE is invalid Lisp object.
Richard M. Stallman <rms@gnu.org>
parents:
9966
diff
changeset
|
114 abort (); |
f0637b2f1671
(wrong_type_argument): Abort if VALUE is invalid Lisp object.
Richard M. Stallman <rms@gnu.org>
parents:
9966
diff
changeset
|
115 |
298 | 116 value = Fsignal (Qwrong_type_argument, Fcons (predicate, Fcons (value, Qnil))); |
117 tem = call1 (predicate, value); | |
118 } | |
490 | 119 while (NILP (tem)); |
298 | 120 return value; |
121 } | |
122 | |
123 pure_write_error () | |
124 { | |
125 error ("Attempt to modify read-only object"); | |
126 } | |
127 | |
128 void | |
129 args_out_of_range (a1, a2) | |
130 Lisp_Object a1, a2; | |
131 { | |
132 while (1) | |
133 Fsignal (Qargs_out_of_range, Fcons (a1, Fcons (a2, Qnil))); | |
134 } | |
135 | |
136 void | |
137 args_out_of_range_3 (a1, a2, a3) | |
138 Lisp_Object a1, a2, a3; | |
139 { | |
140 while (1) | |
141 Fsignal (Qargs_out_of_range, Fcons (a1, Fcons (a2, Fcons (a3, Qnil)))); | |
142 } | |
143 | |
144 Lisp_Object | |
145 make_number (num) | |
146 int num; | |
147 { | |
148 register Lisp_Object val; | |
9263
cda13734e32c
(make_number, Fsymbol_name, do_symval_forwarding, swap_in_symval_forwarding,
Karl Heuer <kwzh@gnu.org>
parents:
9194
diff
changeset
|
149 XSETINT (val, num); |
298 | 150 return val; |
151 } | |
152 | |
153 /* On some machines, XINT needs a temporary location. | |
154 Here it is, in case it is needed. */ | |
155 | |
156 int sign_extend_temp; | |
157 | |
158 /* On a few machines, XINT can only be done by calling this. */ | |
159 | |
160 int | |
161 sign_extend_lisp_int (num) | |
8820
f68749766ed1
(sign_extend_lisp_int): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
8798
diff
changeset
|
162 EMACS_INT num; |
298 | 163 { |
8820
f68749766ed1
(sign_extend_lisp_int): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
8798
diff
changeset
|
164 if (num & (((EMACS_INT) 1) << (VALBITS - 1))) |
f68749766ed1
(sign_extend_lisp_int): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
8798
diff
changeset
|
165 return num | (((EMACS_INT) (-1)) << VALBITS); |
298 | 166 else |
8820
f68749766ed1
(sign_extend_lisp_int): Use EMACS_INT.
Richard M. Stallman <rms@gnu.org>
parents:
8798
diff
changeset
|
167 return num & ((((EMACS_INT) 1) << VALBITS) - 1); |
298 | 168 } |
169 | |
170 /* Data type predicates */ | |
171 | |
172 DEFUN ("eq", Feq, Seq, 2, 2, 0, | |
173 "T if the two args are the same Lisp object.") | |
174 (obj1, obj2) | |
175 Lisp_Object obj1, obj2; | |
176 { | |
177 if (EQ (obj1, obj2)) | |
178 return Qt; | |
179 return Qnil; | |
180 } | |
181 | |
182 DEFUN ("null", Fnull, Snull, 1, 1, 0, "T if OBJECT is nil.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
183 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
184 Lisp_Object object; |
298 | 185 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
186 if (NILP (object)) |
298 | 187 return Qt; |
188 return Qnil; | |
189 } | |
190 | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
191 DEFUN ("type-of", Ftype_of, Stype_of, 1, 1, 0, |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
192 "Return a symbol representing the type of OBJECT.\n\ |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
193 The symbol returned names the object's basic type;\n\ |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
194 for example, (type-of 1) returns `integer'.") |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
195 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
196 Lisp_Object object; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
197 { |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
198 switch (XGCTYPE (object)) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
199 { |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
200 case Lisp_Int: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
201 return Qinteger; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
202 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
203 case Lisp_Symbol: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
204 return Qsymbol; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
205 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
206 case Lisp_String: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
207 return Qstring; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
208 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
209 case Lisp_Cons: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
210 return Qcons; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
211 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
212 case Lisp_Misc: |
11239
38aef18e8e3d
(Ftype_of, do_symval_forwarding, store_symval_forwarding)
Richard M. Stallman <rms@gnu.org>
parents:
11219
diff
changeset
|
213 switch (XMISCTYPE (object)) |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
214 { |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
215 case Lisp_Misc_Marker: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
216 return Qmarker; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
217 case Lisp_Misc_Overlay: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
218 return Qoverlay; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
219 case Lisp_Misc_Float: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
220 return Qfloat; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
221 } |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
222 abort (); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
223 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
224 case Lisp_Vectorlike: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
225 if (GC_WINDOW_CONFIGURATIONP (object)) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
226 return Qwindow_configuration; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
227 if (GC_PROCESSP (object)) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
228 return Qprocess; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
229 if (GC_WINDOWP (object)) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
230 return Qwindow; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
231 if (GC_SUBRP (object)) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
232 return Qsubr; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
233 if (GC_COMPILEDP (object)) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
234 return Qcompiled_function; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
235 if (GC_BUFFERP (object)) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
236 return Qbuffer; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
237 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
238 #ifdef MULTI_FRAME |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
239 if (GC_FRAMEP (object)) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
240 return Qframe; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
241 #endif |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
242 return Qvector; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
243 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
244 #ifdef LISP_FLOAT_TYPE |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
245 case Lisp_Float: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
246 return Qfloat; |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
247 #endif |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
248 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
249 default: |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
250 abort (); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
251 } |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
252 } |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
253 |
298 | 254 DEFUN ("consp", Fconsp, Sconsp, 1, 1, 0, "T if OBJECT is a cons cell.") |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
255 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
256 Lisp_Object object; |
298 | 257 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
258 if (CONSP (object)) |
298 | 259 return Qt; |
260 return Qnil; | |
261 } | |
262 | |
263 DEFUN ("atom", Fatom, Satom, 1, 1, 0, "T if OBJECT is not a cons cell. This includes nil.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
264 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
265 Lisp_Object object; |
298 | 266 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
267 if (CONSP (object)) |
298 | 268 return Qnil; |
269 return Qt; | |
270 } | |
271 | |
272 DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "T if OBJECT is a list. This includes nil.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
273 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
274 Lisp_Object object; |
298 | 275 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
276 if (CONSP (object) || NILP (object)) |
298 | 277 return Qt; |
278 return Qnil; | |
279 } | |
280 | |
281 DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "T if OBJECT is not a list. Lists include nil.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
282 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
283 Lisp_Object object; |
298 | 284 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
285 if (CONSP (object) || NILP (object)) |
298 | 286 return Qnil; |
287 return Qt; | |
288 } | |
289 | |
290 DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "T if OBJECT is a symbol.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
291 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
292 Lisp_Object object; |
298 | 293 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
294 if (SYMBOLP (object)) |
298 | 295 return Qt; |
296 return Qnil; | |
297 } | |
298 | |
299 DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "T if OBJECT is a vector.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
300 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
301 Lisp_Object object; |
298 | 302 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
303 if (VECTORP (object)) |
298 | 304 return Qt; |
305 return Qnil; | |
306 } | |
307 | |
308 DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "T if OBJECT is a string.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
309 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
310 Lisp_Object object; |
298 | 311 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
312 if (STRINGP (object)) |
298 | 313 return Qt; |
314 return Qnil; | |
315 } | |
316 | |
317 DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, "T if OBJECT is an array (string or vector).") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
318 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
319 Lisp_Object object; |
298 | 320 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
321 if (VECTORP (object) || STRINGP (object)) |
298 | 322 return Qt; |
323 return Qnil; | |
324 } | |
325 | |
326 DEFUN ("sequencep", Fsequencep, Ssequencep, 1, 1, 0, | |
327 "T if OBJECT is a sequence (list or array).") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
328 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
329 register Lisp_Object object; |
298 | 330 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
331 if (CONSP (object) || NILP (object) || VECTORP (object) || STRINGP (object)) |
298 | 332 return Qt; |
333 return Qnil; | |
334 } | |
335 | |
336 DEFUN ("bufferp", Fbufferp, Sbufferp, 1, 1, 0, "T if OBJECT is an editor buffer.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
337 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
338 Lisp_Object object; |
298 | 339 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
340 if (BUFFERP (object)) |
298 | 341 return Qt; |
342 return Qnil; | |
343 } | |
344 | |
345 DEFUN ("markerp", Fmarkerp, Smarkerp, 1, 1, 0, "T if OBJECT is a marker (editor pointer).") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
346 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
347 Lisp_Object object; |
298 | 348 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
349 if (MARKERP (object)) |
298 | 350 return Qt; |
351 return Qnil; | |
352 } | |
353 | |
354 DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, "T if OBJECT is a built-in function.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
355 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
356 Lisp_Object object; |
298 | 357 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
358 if (SUBRP (object)) |
298 | 359 return Qt; |
360 return Qnil; | |
361 } | |
362 | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1648
diff
changeset
|
363 DEFUN ("byte-code-function-p", Fbyte_code_function_p, Sbyte_code_function_p, |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1648
diff
changeset
|
364 1, 1, 0, "T if OBJECT is a byte-compiled function object.") |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
365 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
366 Lisp_Object object; |
298 | 367 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
368 if (COMPILEDP (object)) |
298 | 369 return Qt; |
370 return Qnil; | |
371 } | |
372 | |
6385
e81e7c424e8a
(Fchar_or_string_p, Fintegerp, Fnatnump): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6201
diff
changeset
|
373 DEFUN ("char-or-string-p", Fchar_or_string_p, Schar_or_string_p, 1, 1, 0, |
e81e7c424e8a
(Fchar_or_string_p, Fintegerp, Fnatnump): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6201
diff
changeset
|
374 "T if OBJECT is a character (an integer) or a string.") |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
375 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
376 register Lisp_Object object; |
298 | 377 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
378 if (INTEGERP (object) || STRINGP (object)) |
298 | 379 return Qt; |
380 return Qnil; | |
381 } | |
382 | |
6385
e81e7c424e8a
(Fchar_or_string_p, Fintegerp, Fnatnump): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6201
diff
changeset
|
383 DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0, "T if OBJECT is an integer.") |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
384 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
385 Lisp_Object object; |
298 | 386 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
387 if (INTEGERP (object)) |
298 | 388 return Qt; |
389 return Qnil; | |
390 } | |
391 | |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
392 DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0, |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
393 "T if OBJECT is an integer or a marker (editor pointer).") |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
394 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
395 register Lisp_Object object; |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
396 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
397 if (MARKERP (object) || INTEGERP (object)) |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
398 return Qt; |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
399 return Qnil; |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
400 } |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
401 |
6385
e81e7c424e8a
(Fchar_or_string_p, Fintegerp, Fnatnump): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6201
diff
changeset
|
402 DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, |
e81e7c424e8a
(Fchar_or_string_p, Fintegerp, Fnatnump): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6201
diff
changeset
|
403 "T if OBJECT is a nonnegative integer.") |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
404 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
405 Lisp_Object object; |
298 | 406 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
407 if (NATNUMP (object)) |
298 | 408 return Qt; |
409 return Qnil; | |
410 } | |
411 | |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
412 DEFUN ("numberp", Fnumberp, Snumberp, 1, 1, 0, |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
413 "T if OBJECT is a number (floating point or integer).") |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
414 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
415 Lisp_Object object; |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
416 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
417 if (NUMBERP (object)) |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
418 return Qt; |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1648
diff
changeset
|
419 else |
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1648
diff
changeset
|
420 return Qnil; |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
421 } |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
422 |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
423 DEFUN ("number-or-marker-p", Fnumber_or_marker_p, |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
424 Snumber_or_marker_p, 1, 1, 0, |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
425 "T if OBJECT is a number or a marker.") |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
426 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
427 Lisp_Object object; |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
428 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
429 if (NUMBERP (object) || MARKERP (object)) |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
430 return Qt; |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
431 return Qnil; |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
432 } |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
433 |
298 | 434 #ifdef LISP_FLOAT_TYPE |
435 DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0, | |
436 "T if OBJECT is a floating point number.") | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
437 (object) |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
438 Lisp_Object object; |
298 | 439 { |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
440 if (FLOATP (object)) |
298 | 441 return Qt; |
442 return Qnil; | |
443 } | |
444 #endif /* LISP_FLOAT_TYPE */ | |
445 | |
446 /* Extract and set components of lists */ | |
447 | |
448 DEFUN ("car", Fcar, Scar, 1, 1, 0, | |
11219
e9702b711640
Doc fixes to match declared args.
Simon Marshall <simon@gnu.org>
parents:
11155
diff
changeset
|
449 "Return the car of LIST. If arg is nil, return nil.\n\ |
298 | 450 Error if arg is not nil and not a cons cell. See also `car-safe'.") |
451 (list) | |
452 register Lisp_Object list; | |
453 { | |
454 while (1) | |
455 { | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
456 if (CONSP (list)) |
298 | 457 return XCONS (list)->car; |
458 else if (EQ (list, Qnil)) | |
459 return Qnil; | |
460 else | |
461 list = wrong_type_argument (Qlistp, list); | |
462 } | |
463 } | |
464 | |
465 DEFUN ("car-safe", Fcar_safe, Scar_safe, 1, 1, 0, | |
466 "Return the car of OBJECT if it is a cons cell, or else nil.") | |
467 (object) | |
468 Lisp_Object object; | |
469 { | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
470 if (CONSP (object)) |
298 | 471 return XCONS (object)->car; |
472 else | |
473 return Qnil; | |
474 } | |
475 | |
476 DEFUN ("cdr", Fcdr, Scdr, 1, 1, 0, | |
11219
e9702b711640
Doc fixes to match declared args.
Simon Marshall <simon@gnu.org>
parents:
11155
diff
changeset
|
477 "Return the cdr of LIST. If arg is nil, return nil.\n\ |
298 | 478 Error if arg is not nil and not a cons cell. See also `cdr-safe'.") |
479 | |
480 (list) | |
481 register Lisp_Object list; | |
482 { | |
483 while (1) | |
484 { | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
485 if (CONSP (list)) |
298 | 486 return XCONS (list)->cdr; |
487 else if (EQ (list, Qnil)) | |
488 return Qnil; | |
489 else | |
490 list = wrong_type_argument (Qlistp, list); | |
491 } | |
492 } | |
493 | |
494 DEFUN ("cdr-safe", Fcdr_safe, Scdr_safe, 1, 1, 0, | |
8798
e10362de8eba
(Fcdr_safe): Delete extraneous blank in docstring.
Karl Heuer <kwzh@gnu.org>
parents:
8448
diff
changeset
|
495 "Return the cdr of OBJECT if it is a cons cell, or else nil.") |
298 | 496 (object) |
497 Lisp_Object object; | |
498 { | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
499 if (CONSP (object)) |
298 | 500 return XCONS (object)->cdr; |
501 else | |
502 return Qnil; | |
503 } | |
504 | |
505 DEFUN ("setcar", Fsetcar, Ssetcar, 2, 2, 0, | |
11219
e9702b711640
Doc fixes to match declared args.
Simon Marshall <simon@gnu.org>
parents:
11155
diff
changeset
|
506 "Set the car of CELL to be NEWCAR. Returns NEWCAR.") |
298 | 507 (cell, newcar) |
508 register Lisp_Object cell, newcar; | |
509 { | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
510 if (!CONSP (cell)) |
298 | 511 cell = wrong_type_argument (Qconsp, cell); |
512 | |
513 CHECK_IMPURE (cell); | |
514 XCONS (cell)->car = newcar; | |
515 return newcar; | |
516 } | |
517 | |
518 DEFUN ("setcdr", Fsetcdr, Ssetcdr, 2, 2, 0, | |
11219
e9702b711640
Doc fixes to match declared args.
Simon Marshall <simon@gnu.org>
parents:
11155
diff
changeset
|
519 "Set the cdr of CELL to be NEWCDR. Returns NEWCDR.") |
298 | 520 (cell, newcdr) |
521 register Lisp_Object cell, newcdr; | |
522 { | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
523 if (!CONSP (cell)) |
298 | 524 cell = wrong_type_argument (Qconsp, cell); |
525 | |
526 CHECK_IMPURE (cell); | |
527 XCONS (cell)->cdr = newcdr; | |
528 return newcdr; | |
529 } | |
530 | |
531 /* Extract and set components of symbols */ | |
532 | |
533 DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0, "T if SYMBOL's value is not void.") | |
534 (sym) | |
535 register Lisp_Object sym; | |
536 { | |
537 Lisp_Object valcontents; | |
538 CHECK_SYMBOL (sym, 0); | |
539 | |
540 valcontents = XSYMBOL (sym)->value; | |
541 | |
9889 | 542 if (BUFFER_LOCAL_VALUEP (valcontents) |
543 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | |
9878
8a68b5794c91
(Fboundp, find_symbol_value): Use type test macros instead of checking XTYPE
Karl Heuer <kwzh@gnu.org>
parents:
9465
diff
changeset
|
544 valcontents = swap_in_symval_forwarding (sym, valcontents); |
298 | 545 |
9369
379c7b900689
(Fboundp, Ffboundp, find_symbol_value, Fset, Fdefault_boundp, Fdefault_value):
Karl Heuer <kwzh@gnu.org>
parents:
9366
diff
changeset
|
546 return (EQ (valcontents, Qunbound) ? Qnil : Qt); |
298 | 547 } |
548 | |
549 DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, "T if SYMBOL's function definition is not void.") | |
550 (sym) | |
551 register Lisp_Object sym; | |
552 { | |
553 CHECK_SYMBOL (sym, 0); | |
9369
379c7b900689
(Fboundp, Ffboundp, find_symbol_value, Fset, Fdefault_boundp, Fdefault_value):
Karl Heuer <kwzh@gnu.org>
parents:
9366
diff
changeset
|
554 return (EQ (XSYMBOL (sym)->function, Qunbound) ? Qnil : Qt); |
298 | 555 } |
556 | |
557 DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0, "Make SYMBOL's value be void.") | |
558 (sym) | |
559 register Lisp_Object sym; | |
560 { | |
561 CHECK_SYMBOL (sym, 0); | |
490 | 562 if (NILP (sym) || EQ (sym, Qt)) |
298 | 563 return Fsignal (Qsetting_constant, Fcons (sym, Qnil)); |
564 Fset (sym, Qunbound); | |
565 return sym; | |
566 } | |
567 | |
568 DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0, "Make SYMBOL's function definition be void.") | |
569 (sym) | |
570 register Lisp_Object sym; | |
571 { | |
572 CHECK_SYMBOL (sym, 0); | |
7206
b6aa3d718d8a
(Ffset, Ffmakunbound): Signal an error if SYM is nil or t.
Karl Heuer <kwzh@gnu.org>
parents:
7205
diff
changeset
|
573 if (NILP (sym) || EQ (sym, Qt)) |
b6aa3d718d8a
(Ffset, Ffmakunbound): Signal an error if SYM is nil or t.
Karl Heuer <kwzh@gnu.org>
parents:
7205
diff
changeset
|
574 return Fsignal (Qsetting_constant, Fcons (sym, Qnil)); |
298 | 575 XSYMBOL (sym)->function = Qunbound; |
576 return sym; | |
577 } | |
578 | |
579 DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0, | |
580 "Return SYMBOL's function definition. Error if that is void.") | |
648 | 581 (symbol) |
582 register Lisp_Object symbol; | |
298 | 583 { |
648 | 584 CHECK_SYMBOL (symbol, 0); |
585 if (EQ (XSYMBOL (symbol)->function, Qunbound)) | |
586 return Fsignal (Qvoid_function, Fcons (symbol, Qnil)); | |
587 return XSYMBOL (symbol)->function; | |
298 | 588 } |
589 | |
590 DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, "Return SYMBOL's property list.") | |
591 (sym) | |
592 register Lisp_Object sym; | |
593 { | |
594 CHECK_SYMBOL (sym, 0); | |
595 return XSYMBOL (sym)->plist; | |
596 } | |
597 | |
598 DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, "Return SYMBOL's name, a string.") | |
599 (sym) | |
600 register Lisp_Object sym; | |
601 { | |
602 register Lisp_Object name; | |
603 | |
604 CHECK_SYMBOL (sym, 0); | |
9263
cda13734e32c
(make_number, Fsymbol_name, do_symval_forwarding, swap_in_symval_forwarding,
Karl Heuer <kwzh@gnu.org>
parents:
9194
diff
changeset
|
605 XSETSTRING (name, XSYMBOL (sym)->name); |
298 | 606 return name; |
607 } | |
608 | |
609 DEFUN ("fset", Ffset, Sfset, 2, 2, 0, | |
610 "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.") | |
611 (sym, newdef) | |
612 register Lisp_Object sym, newdef; | |
613 { | |
614 CHECK_SYMBOL (sym, 0); | |
7206
b6aa3d718d8a
(Ffset, Ffmakunbound): Signal an error if SYM is nil or t.
Karl Heuer <kwzh@gnu.org>
parents:
7205
diff
changeset
|
615 if (NILP (sym) || EQ (sym, Qt)) |
b6aa3d718d8a
(Ffset, Ffmakunbound): Signal an error if SYM is nil or t.
Karl Heuer <kwzh@gnu.org>
parents:
7205
diff
changeset
|
616 return Fsignal (Qsetting_constant, Fcons (sym, Qnil)); |
490 | 617 if (!NILP (Vautoload_queue) && !EQ (XSYMBOL (sym)->function, Qunbound)) |
298 | 618 Vautoload_queue = Fcons (Fcons (sym, XSYMBOL (sym)->function), |
619 Vautoload_queue); | |
620 XSYMBOL (sym)->function = newdef; | |
8401
1eee41c8120c
(syms_of_data): Set up Qadvice_info, Qactivate_advice.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
621 /* Handle automatic advice activation */ |
8448
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
622 if (CONSP (XSYMBOL (sym)->plist) && !NILP (Fget (sym, Qad_advice_info))) |
8401
1eee41c8120c
(syms_of_data): Set up Qadvice_info, Qactivate_advice.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
623 { |
8448
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
624 call2 (Qad_activate, sym, Qnil); |
8401
1eee41c8120c
(syms_of_data): Set up Qadvice_info, Qactivate_advice.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
625 newdef = XSYMBOL (sym)->function; |
1eee41c8120c
(syms_of_data): Set up Qadvice_info, Qactivate_advice.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
626 } |
298 | 627 return newdef; |
628 } | |
629 | |
2606
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
630 /* This name should be removed once it is eliminated from elsewhere. */ |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
631 |
2565
c1a1557bffde
(Fdefine_function): Changed name back to Fdefalias, so we get things
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2548
diff
changeset
|
632 DEFUN ("defalias", Fdefalias, Sdefalias, 2, 2, 0, |
2548
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
633 "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.\n\ |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
634 Associates the function with the current load file, if any.") |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
635 (sym, newdef) |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
636 register Lisp_Object sym, newdef; |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
637 { |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
638 CHECK_SYMBOL (sym, 0); |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
639 if (!NILP (Vautoload_queue) && !EQ (XSYMBOL (sym)->function, Qunbound)) |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
640 Vautoload_queue = Fcons (Fcons (sym, XSYMBOL (sym)->function), |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
641 Vautoload_queue); |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
642 XSYMBOL (sym)->function = newdef; |
8448
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
643 /* Handle automatic advice activation */ |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
644 if (CONSP (XSYMBOL (sym)->plist) && !NILP (Fget (sym, Qad_advice_info))) |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
645 { |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
646 call2 (Qad_activate, sym, Qnil); |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
647 newdef = XSYMBOL (sym)->function; |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
648 } |
2548
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
649 LOADHIST_ATTACH (sym); |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
650 return newdef; |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
651 } |
b66eeded6afc
(Fdefine_function): New function.
Richard M. Stallman <rms@gnu.org>
parents:
2515
diff
changeset
|
652 |
2606
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
653 DEFUN ("define-function", Fdefine_function, Sdefine_function, 2, 2, 0, |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
654 "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.\n\ |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
655 Associates the function with the current load file, if any.") |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
656 (sym, newdef) |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
657 register Lisp_Object sym, newdef; |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
658 { |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
659 CHECK_SYMBOL (sym, 0); |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
660 if (!NILP (Vautoload_queue) && !EQ (XSYMBOL (sym)->function, Qunbound)) |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
661 Vautoload_queue = Fcons (Fcons (sym, XSYMBOL (sym)->function), |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
662 Vautoload_queue); |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
663 XSYMBOL (sym)->function = newdef; |
8448
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
664 /* Handle automatic advice activation */ |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
665 if (CONSP (XSYMBOL (sym)->plist) && !NILP (Fget (sym, Qad_advice_info))) |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
666 { |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
667 call2 (Qad_activate, sym, Qnil); |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
668 newdef = XSYMBOL (sym)->function; |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
669 } |
2606
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
670 LOADHIST_ATTACH (sym); |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
671 return newdef; |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
672 } |
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
673 |
298 | 674 DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0, |
675 "Set SYMBOL's property list to NEWVAL, and return NEWVAL.") | |
676 (sym, newplist) | |
677 register Lisp_Object sym, newplist; | |
678 { | |
679 CHECK_SYMBOL (sym, 0); | |
680 XSYMBOL (sym)->plist = newplist; | |
681 return newplist; | |
682 } | |
648 | 683 |
298 | 684 |
685 /* Getting and setting values of symbols */ | |
686 | |
687 /* Given the raw contents of a symbol value cell, | |
688 return the Lisp value of the symbol. | |
689 This does not handle buffer-local variables; use | |
690 swap_in_symval_forwarding for that. */ | |
691 | |
692 Lisp_Object | |
693 do_symval_forwarding (valcontents) | |
694 register Lisp_Object valcontents; | |
695 { | |
696 register Lisp_Object val; | |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
697 int offset; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
698 if (MISCP (valcontents)) |
11239
38aef18e8e3d
(Ftype_of, do_symval_forwarding, store_symval_forwarding)
Richard M. Stallman <rms@gnu.org>
parents:
11219
diff
changeset
|
699 switch (XMISCTYPE (valcontents)) |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
700 { |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
701 case Lisp_Misc_Intfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
702 XSETINT (val, *XINTFWD (valcontents)->intvar); |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
703 return val; |
298 | 704 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
705 case Lisp_Misc_Boolfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
706 return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); |
298 | 707 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
708 case Lisp_Misc_Objfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
709 return *XOBJFWD (valcontents)->objvar; |
298 | 710 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
711 case Lisp_Misc_Buffer_Objfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
712 offset = XBUFFER_OBJFWD (valcontents)->offset; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
713 return *(Lisp_Object *)(offset + (char *)current_buffer); |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
714 |
11019
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
715 case Lisp_Misc_Kboard_Objfwd: |
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
716 offset = XKBOARD_OBJFWD (valcontents)->offset; |
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
717 return *(Lisp_Object *)(offset + (char *)current_kboard); |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
718 } |
298 | 719 return valcontents; |
720 } | |
721 | |
722 /* Store NEWVAL into SYM, where VALCONTENTS is found in the value cell | |
723 of SYM. If SYM is buffer-local, VALCONTENTS should be the | |
724 buffer-independent contents of the value cell: forwarded just one | |
725 step past the buffer-localness. */ | |
726 | |
727 void | |
728 store_symval_forwarding (sym, valcontents, newval) | |
729 Lisp_Object sym; | |
730 register Lisp_Object valcontents, newval; | |
731 { | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10290
diff
changeset
|
732 switch (SWITCH_ENUM_CAST (XTYPE (valcontents))) |
298 | 733 { |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
734 case Lisp_Misc: |
11239
38aef18e8e3d
(Ftype_of, do_symval_forwarding, store_symval_forwarding)
Richard M. Stallman <rms@gnu.org>
parents:
11219
diff
changeset
|
735 switch (XMISCTYPE (valcontents)) |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
736 { |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
737 case Lisp_Misc_Intfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
738 CHECK_NUMBER (newval, 1); |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
739 *XINTFWD (valcontents)->intvar = XINT (newval); |
11701
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
740 if (*XINTFWD (valcontents)->intvar != XINT (newval)) |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
741 error ("Value out of range for variable `%s'", |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
742 XSYMBOL (sym)->name->data); |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
743 break; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
744 |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
745 case Lisp_Misc_Boolfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
746 *XBOOLFWD (valcontents)->boolvar = NILP (newval) ? 0 : 1; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
747 break; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
748 |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
749 case Lisp_Misc_Objfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
750 *XOBJFWD (valcontents)->objvar = newval; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
751 break; |
298 | 752 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
753 case Lisp_Misc_Buffer_Objfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
754 { |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
755 int offset = XBUFFER_OBJFWD (valcontents)->offset; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
756 Lisp_Object type; |
298 | 757 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
758 type = *(Lisp_Object *)(offset + (char *)&buffer_local_types); |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
759 if (! NILP (type) && ! NILP (newval) |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
760 && XTYPE (newval) != XINT (type)) |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
761 buffer_slot_type_mismatch (offset); |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
762 |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
763 *(Lisp_Object *)(offset + (char *)current_buffer) = newval; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
764 } |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
765 break; |
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
766 |
11019
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
767 case Lisp_Misc_Kboard_Objfwd: |
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
768 (*(Lisp_Object *)((char *)current_kboard |
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
769 + XKBOARD_OBJFWD (valcontents)->offset)) |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
770 = newval; |
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
771 break; |
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
772 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
773 default: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
774 goto def; |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
775 } |
298 | 776 break; |
777 | |
778 default: | |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
779 def: |
298 | 780 valcontents = XSYMBOL (sym)->value; |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
781 if (BUFFER_LOCAL_VALUEP (valcontents) |
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
782 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
783 XBUFFER_LOCAL_VALUE (valcontents)->car = newval; |
298 | 784 else |
785 XSYMBOL (sym)->value = newval; | |
786 } | |
787 } | |
788 | |
789 /* Set up the buffer-local symbol SYM for validity in the current | |
790 buffer. VALCONTENTS is the contents of its value cell. | |
791 Return the value forwarded one step past the buffer-local indicator. */ | |
792 | |
793 static Lisp_Object | |
794 swap_in_symval_forwarding (sym, valcontents) | |
795 Lisp_Object sym, valcontents; | |
796 { | |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
797 /* valcontents is a pointer to a struct resembling the cons |
298 | 798 (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE)). |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
799 |
298 | 800 CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's |
1263
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
801 local_var_alist, that being the element whose car is this |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
802 variable. Or it can be a pointer to the |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
803 (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER does not have |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
804 an element in its alist for this variable. |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
805 |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
806 If the current buffer is not BUFFER, we store the current |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
807 REALVALUE value into CURRENT-ALIST-ELEMENT, then find the |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
808 appropriate alist element for the buffer now current and set up |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
809 CURRENT-ALIST-ELEMENT. Then we set REALVALUE out of that |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
810 element, and store into BUFFER. |
3790dfbefb30
* data.c (swap_in_symval_forwarding): Formatting tweaked.
Jim Blandy <jimb@redhat.com>
parents:
1253
diff
changeset
|
811 |
298 | 812 Note that REALVALUE can be a forwarding pointer. */ |
813 | |
814 register Lisp_Object tem1; | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
815 tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; |
298 | 816 |
490 | 817 if (NILP (tem1) || current_buffer != XBUFFER (tem1)) |
298 | 818 { |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
819 tem1 = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
820 Fsetcdr (tem1, |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
821 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car)); |
298 | 822 tem1 = assq_no_quit (sym, current_buffer->local_var_alist); |
490 | 823 if (NILP (tem1)) |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
824 tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
825 XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car = tem1; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
826 XSETBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car, |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
827 current_buffer); |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
828 store_symval_forwarding (sym, XBUFFER_LOCAL_VALUE (valcontents)->car, |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
829 Fcdr (tem1)); |
298 | 830 } |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
831 return XBUFFER_LOCAL_VALUE (valcontents)->car; |
298 | 832 } |
833 | |
514 | 834 /* Find the value of a symbol, returning Qunbound if it's not bound. |
835 This is helpful for code which just wants to get a variable's value | |
836 if it has one, without signalling an error. | |
837 Note that it must not be possible to quit | |
838 within this function. Great care is required for this. */ | |
298 | 839 |
514 | 840 Lisp_Object |
841 find_symbol_value (sym) | |
298 | 842 Lisp_Object sym; |
843 { | |
844 register Lisp_Object valcontents, tem1; | |
845 register Lisp_Object val; | |
846 CHECK_SYMBOL (sym, 0); | |
847 valcontents = XSYMBOL (sym)->value; | |
848 | |
9889 | 849 if (BUFFER_LOCAL_VALUEP (valcontents) |
850 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | |
9878
8a68b5794c91
(Fboundp, find_symbol_value): Use type test macros instead of checking XTYPE
Karl Heuer <kwzh@gnu.org>
parents:
9465
diff
changeset
|
851 valcontents = swap_in_symval_forwarding (sym, valcontents); |
8a68b5794c91
(Fboundp, find_symbol_value): Use type test macros instead of checking XTYPE
Karl Heuer <kwzh@gnu.org>
parents:
9465
diff
changeset
|
852 |
8a68b5794c91
(Fboundp, find_symbol_value): Use type test macros instead of checking XTYPE
Karl Heuer <kwzh@gnu.org>
parents:
9465
diff
changeset
|
853 if (MISCP (valcontents)) |
298 | 854 { |
11239
38aef18e8e3d
(Ftype_of, do_symval_forwarding, store_symval_forwarding)
Richard M. Stallman <rms@gnu.org>
parents:
11219
diff
changeset
|
855 switch (XMISCTYPE (valcontents)) |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
856 { |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
857 case Lisp_Misc_Intfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
858 XSETINT (val, *XINTFWD (valcontents)->intvar); |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
859 return val; |
298 | 860 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
861 case Lisp_Misc_Boolfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
862 return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); |
298 | 863 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
864 case Lisp_Misc_Objfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
865 return *XOBJFWD (valcontents)->objvar; |
298 | 866 |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
867 case Lisp_Misc_Buffer_Objfwd: |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
868 return *(Lisp_Object *)(XBUFFER_OBJFWD (valcontents)->offset |
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
869 + (char *)current_buffer); |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
870 |
11019
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
871 case Lisp_Misc_Kboard_Objfwd: |
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
872 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset |
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
873 + (char *)current_kboard); |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
874 } |
298 | 875 } |
876 | |
877 return valcontents; | |
878 } | |
879 | |
514 | 880 DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, |
881 "Return SYMBOL's value. Error if that is void.") | |
882 (sym) | |
883 Lisp_Object sym; | |
884 { | |
6497
89ff61b53cee
(store_symval_forwarding, Fsymbol_value): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6459
diff
changeset
|
885 Lisp_Object val; |
514 | 886 |
6497
89ff61b53cee
(store_symval_forwarding, Fsymbol_value): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6459
diff
changeset
|
887 val = find_symbol_value (sym); |
514 | 888 if (EQ (val, Qunbound)) |
889 return Fsignal (Qvoid_variable, Fcons (sym, Qnil)); | |
890 else | |
891 return val; | |
892 } | |
893 | |
298 | 894 DEFUN ("set", Fset, Sset, 2, 2, 0, |
895 "Set SYMBOL's value to NEWVAL, and return NEWVAL.") | |
896 (sym, newval) | |
897 register Lisp_Object sym, newval; | |
898 { | |
9369
379c7b900689
(Fboundp, Ffboundp, find_symbol_value, Fset, Fdefault_boundp, Fdefault_value):
Karl Heuer <kwzh@gnu.org>
parents:
9366
diff
changeset
|
899 int voide = EQ (newval, Qunbound); |
298 | 900 |
901 register Lisp_Object valcontents, tem1, current_alist_element; | |
902 | |
903 CHECK_SYMBOL (sym, 0); | |
490 | 904 if (NILP (sym) || EQ (sym, Qt)) |
298 | 905 return Fsignal (Qsetting_constant, Fcons (sym, Qnil)); |
906 valcontents = XSYMBOL (sym)->value; | |
907 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
908 if (BUFFER_OBJFWDP (valcontents)) |
298 | 909 { |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
910 register int idx = XBUFFER_OBJFWD (valcontents)->offset; |
9364
0bba3bd707c7
(Fset, default_value, Fset_default, Fkill_local_variable): Access
Karl Heuer <kwzh@gnu.org>
parents:
9301
diff
changeset
|
911 register int mask = XINT (*((Lisp_Object *) |
0bba3bd707c7
(Fset, default_value, Fset_default, Fkill_local_variable): Access
Karl Heuer <kwzh@gnu.org>
parents:
9301
diff
changeset
|
912 (idx + (char *)&buffer_local_flags))); |
298 | 913 if (mask > 0) |
914 current_buffer->local_var_flags |= mask; | |
915 } | |
916 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
917 else if (BUFFER_LOCAL_VALUEP (valcontents) |
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
918 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
298 | 919 { |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
920 /* valcontents is actually a pointer to a struct resembling a cons, |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
921 with contents something like: |
733 | 922 (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE). |
923 | |
924 BUFFER is the last buffer for which this symbol's value was | |
925 made up to date. | |
298 | 926 |
733 | 927 CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's |
928 local_var_alist, that being the element whose car is this | |
929 variable. Or it can be a pointer to the | |
930 (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER does not | |
931 have an element in its alist for this variable (that is, if | |
932 BUFFER sees the default value of this variable). | |
933 | |
934 If we want to examine or set the value and BUFFER is current, | |
935 we just examine or set REALVALUE. If BUFFER is not current, we | |
936 store the current REALVALUE value into CURRENT-ALIST-ELEMENT, | |
937 then find the appropriate alist element for the buffer now | |
938 current and set up CURRENT-ALIST-ELEMENT. Then we set | |
939 REALVALUE out of that element, and store into BUFFER. | |
298 | 940 |
733 | 941 If we are setting the variable and the current buffer does |
942 not have an alist entry for this variable, an alist entry is | |
943 created. | |
944 | |
945 Note that REALVALUE can be a forwarding pointer. Each time | |
946 it is examined or set, forwarding must be done. */ | |
947 | |
948 /* What value are we caching right now? */ | |
949 current_alist_element = | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
950 XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; |
298 | 951 |
733 | 952 /* If the current buffer is not the buffer whose binding is |
953 currently cached, or if it's a Lisp_Buffer_Local_Value and | |
954 we're looking at the default value, the cache is invalid; we | |
955 need to write it out, and find the new CURRENT-ALIST-ELEMENT. */ | |
956 if ((current_buffer | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
957 != XBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car)) |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
958 || (BUFFER_LOCAL_VALUEP (valcontents) |
1508
768d4c10c2bf
* data.c (Fset): See if current_alist_element points to itself
Jim Blandy <jimb@redhat.com>
parents:
1293
diff
changeset
|
959 && EQ (XCONS (current_alist_element)->car, |
768d4c10c2bf
* data.c (Fset): See if current_alist_element points to itself
Jim Blandy <jimb@redhat.com>
parents:
1293
diff
changeset
|
960 current_alist_element))) |
298 | 961 { |
733 | 962 /* Write out the cached value for the old buffer; copy it |
963 back to its alist element. This works if the current | |
964 buffer only sees the default value, too. */ | |
965 Fsetcdr (current_alist_element, | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
966 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car)); |
298 | 967 |
733 | 968 /* Find the new value for CURRENT-ALIST-ELEMENT. */ |
298 | 969 tem1 = Fassq (sym, current_buffer->local_var_alist); |
490 | 970 if (NILP (tem1)) |
733 | 971 { |
972 /* This buffer still sees the default value. */ | |
973 | |
974 /* If the variable is a Lisp_Some_Buffer_Local_Value, | |
975 make CURRENT-ALIST-ELEMENT point to itself, | |
976 indicating that we're seeing the default value. */ | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
977 if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
978 tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr; |
733 | 979 |
980 /* If it's a Lisp_Buffer_Local_Value, give this buffer a | |
981 new assoc for a local value and set | |
982 CURRENT-ALIST-ELEMENT to point to that. */ | |
983 else | |
984 { | |
985 tem1 = Fcons (sym, Fcdr (current_alist_element)); | |
986 current_buffer->local_var_alist = | |
987 Fcons (tem1, current_buffer->local_var_alist); | |
988 } | |
989 } | |
990 /* Cache the new buffer's assoc in CURRENT-ALIST-ELEMENT. */ | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
991 XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
992 = tem1; |
733 | 993 |
994 /* Set BUFFER, now that CURRENT-ALIST-ELEMENT is accurate. */ | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
995 XSETBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car, |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
996 current_buffer); |
298 | 997 } |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
998 valcontents = XBUFFER_LOCAL_VALUE (valcontents)->car; |
298 | 999 } |
733 | 1000 |
298 | 1001 /* If storing void (making the symbol void), forward only through |
1002 buffer-local indicator, not through Lisp_Objfwd, etc. */ | |
1003 if (voide) | |
1004 store_symval_forwarding (sym, Qnil, newval); | |
1005 else | |
1006 store_symval_forwarding (sym, valcontents, newval); | |
733 | 1007 |
298 | 1008 return newval; |
1009 } | |
1010 | |
1011 /* Access or set a buffer-local symbol's default value. */ | |
1012 | |
1013 /* Return the default value of SYM, but don't check for voidness. | |
9369
379c7b900689
(Fboundp, Ffboundp, find_symbol_value, Fset, Fdefault_boundp, Fdefault_value):
Karl Heuer <kwzh@gnu.org>
parents:
9366
diff
changeset
|
1014 Return Qunbound if it is void. */ |
298 | 1015 |
1016 Lisp_Object | |
1017 default_value (sym) | |
1018 Lisp_Object sym; | |
1019 { | |
1020 register Lisp_Object valcontents; | |
1021 | |
1022 CHECK_SYMBOL (sym, 0); | |
1023 valcontents = XSYMBOL (sym)->value; | |
1024 | |
1025 /* For a built-in buffer-local variable, get the default value | |
1026 rather than letting do_symval_forwarding get the current value. */ | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1027 if (BUFFER_OBJFWDP (valcontents)) |
298 | 1028 { |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
1029 register int idx = XBUFFER_OBJFWD (valcontents)->offset; |
298 | 1030 |
9364
0bba3bd707c7
(Fset, default_value, Fset_default, Fkill_local_variable): Access
Karl Heuer <kwzh@gnu.org>
parents:
9301
diff
changeset
|
1031 if (XINT (*(Lisp_Object *) (idx + (char *) &buffer_local_flags)) != 0) |
298 | 1032 return *(Lisp_Object *)(idx + (char *) &buffer_defaults); |
1033 } | |
1034 | |
1035 /* Handle user-created local variables. */ | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1036 if (BUFFER_LOCAL_VALUEP (valcontents) |
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1037 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
298 | 1038 { |
1039 /* If var is set up for a buffer that lacks a local value for it, | |
1040 the current value is nominally the default value. | |
1041 But the current value slot may be more up to date, since | |
1042 ordinary setq stores just that slot. So use that. */ | |
1043 Lisp_Object current_alist_element, alist_element_car; | |
1044 current_alist_element | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1045 = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; |
298 | 1046 alist_element_car = XCONS (current_alist_element)->car; |
1047 if (EQ (alist_element_car, current_alist_element)) | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1048 return do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car); |
298 | 1049 else |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1050 return XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->cdr; |
298 | 1051 } |
1052 /* For other variables, get the current value. */ | |
1053 return do_symval_forwarding (valcontents); | |
1054 } | |
1055 | |
1056 DEFUN ("default-boundp", Fdefault_boundp, Sdefault_boundp, 1, 1, 0, | |
1057 "Return T if SYMBOL has a non-void default value.\n\ | |
1058 This is the value that is seen in buffers that do not have their own values\n\ | |
1059 for this variable.") | |
1060 (sym) | |
1061 Lisp_Object sym; | |
1062 { | |
1063 register Lisp_Object value; | |
1064 | |
1065 value = default_value (sym); | |
9369
379c7b900689
(Fboundp, Ffboundp, find_symbol_value, Fset, Fdefault_boundp, Fdefault_value):
Karl Heuer <kwzh@gnu.org>
parents:
9366
diff
changeset
|
1066 return (EQ (value, Qunbound) ? Qnil : Qt); |
298 | 1067 } |
1068 | |
1069 DEFUN ("default-value", Fdefault_value, Sdefault_value, 1, 1, 0, | |
1070 "Return SYMBOL's default value.\n\ | |
1071 This is the value that is seen in buffers that do not have their own values\n\ | |
1072 for this variable. The default value is meaningful for variables with\n\ | |
1073 local bindings in certain buffers.") | |
1074 (sym) | |
1075 Lisp_Object sym; | |
1076 { | |
1077 register Lisp_Object value; | |
1078 | |
1079 value = default_value (sym); | |
9369
379c7b900689
(Fboundp, Ffboundp, find_symbol_value, Fset, Fdefault_boundp, Fdefault_value):
Karl Heuer <kwzh@gnu.org>
parents:
9366
diff
changeset
|
1080 if (EQ (value, Qunbound)) |
298 | 1081 return Fsignal (Qvoid_variable, Fcons (sym, Qnil)); |
1082 return value; | |
1083 } | |
1084 | |
1085 DEFUN ("set-default", Fset_default, Sset_default, 2, 2, 0, | |
1086 "Set SYMBOL's default value to VAL. SYMBOL and VAL are evaluated.\n\ | |
1087 The default value is seen in buffers that do not have their own values\n\ | |
1088 for this variable.") | |
1089 (sym, value) | |
1090 Lisp_Object sym, value; | |
1091 { | |
1092 register Lisp_Object valcontents, current_alist_element, alist_element_buffer; | |
1093 | |
1094 CHECK_SYMBOL (sym, 0); | |
1095 valcontents = XSYMBOL (sym)->value; | |
1096 | |
1097 /* Handle variables like case-fold-search that have special slots | |
1098 in the buffer. Make them work apparently like Lisp_Buffer_Local_Value | |
1099 variables. */ | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1100 if (BUFFER_OBJFWDP (valcontents)) |
298 | 1101 { |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
1102 register int idx = XBUFFER_OBJFWD (valcontents)->offset; |
298 | 1103 register struct buffer *b; |
9364
0bba3bd707c7
(Fset, default_value, Fset_default, Fkill_local_variable): Access
Karl Heuer <kwzh@gnu.org>
parents:
9301
diff
changeset
|
1104 register int mask = XINT (*((Lisp_Object *) |
0bba3bd707c7
(Fset, default_value, Fset_default, Fkill_local_variable): Access
Karl Heuer <kwzh@gnu.org>
parents:
9301
diff
changeset
|
1105 (idx + (char *)&buffer_local_flags))); |
298 | 1106 |
1107 if (mask > 0) | |
1108 { | |
1109 *(Lisp_Object *)(idx + (char *) &buffer_defaults) = value; | |
1110 for (b = all_buffers; b; b = b->next) | |
1111 if (!(b->local_var_flags & mask)) | |
1112 *(Lisp_Object *)(idx + (char *) b) = value; | |
1113 } | |
1114 return value; | |
1115 } | |
1116 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1117 if (!BUFFER_LOCAL_VALUEP (valcontents) |
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1118 && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
298 | 1119 return Fset (sym, value); |
1120 | |
1121 /* Store new value into the DEFAULT-VALUE slot */ | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1122 XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->cdr = value; |
298 | 1123 |
1124 /* If that slot is current, we must set the REALVALUE slot too */ | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1125 current_alist_element |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1126 = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; |
298 | 1127 alist_element_buffer = Fcar (current_alist_element); |
1128 if (EQ (alist_element_buffer, current_alist_element)) | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1129 store_symval_forwarding (sym, XBUFFER_LOCAL_VALUE (valcontents)->car, |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1130 value); |
298 | 1131 |
1132 return value; | |
1133 } | |
1134 | |
1135 DEFUN ("setq-default", Fsetq_default, Ssetq_default, 2, UNEVALLED, 0, | |
6919
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1136 "Set the default value of variable VAR to VALUE.\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1137 VAR, the variable name, is literal (not evaluated);\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1138 VALUE is an expression and it is evaluated.\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1139 The default value of a variable is seen in buffers\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1140 that do not have their own values for the variable.\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1141 \n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1142 More generally, you can use multiple variables and values, as in\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1143 (setq-default SYM VALUE SYM VALUE...)\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1144 This sets each SYM's default value to the corresponding VALUE.\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1145 The VALUE for the Nth SYM can refer to the new default values\n\ |
dabe7a363f28
(Fsetq_default): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6825
diff
changeset
|
1146 of previous SYMs.") |
298 | 1147 (args) |
1148 Lisp_Object args; | |
1149 { | |
1150 register Lisp_Object args_left; | |
1151 register Lisp_Object val, sym; | |
1152 struct gcpro gcpro1; | |
1153 | |
490 | 1154 if (NILP (args)) |
298 | 1155 return Qnil; |
1156 | |
1157 args_left = args; | |
1158 GCPRO1 (args); | |
1159 | |
1160 do | |
1161 { | |
1162 val = Feval (Fcar (Fcdr (args_left))); | |
1163 sym = Fcar (args_left); | |
1164 Fset_default (sym, val); | |
1165 args_left = Fcdr (Fcdr (args_left)); | |
1166 } | |
490 | 1167 while (!NILP (args_left)); |
298 | 1168 |
1169 UNGCPRO; | |
1170 return val; | |
1171 } | |
1172 | |
1278
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1173 /* Lisp functions for creating and removing buffer-local variables. */ |
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1174 |
298 | 1175 DEFUN ("make-variable-buffer-local", Fmake_variable_buffer_local, Smake_variable_buffer_local, |
1176 1, 1, "vMake Variable Buffer Local: ", | |
1177 "Make VARIABLE have a separate value for each buffer.\n\ | |
1178 At any time, the value for the current buffer is in effect.\n\ | |
1179 There is also a default value which is seen in any buffer which has not yet\n\ | |
1180 set its own value.\n\ | |
1181 Using `set' or `setq' to set the variable causes it to have a separate value\n\ | |
1182 for the current buffer if it was previously using the default value.\n\ | |
1183 The function `default-value' gets the default value and `set-default' sets it.") | |
1184 (sym) | |
1185 register Lisp_Object sym; | |
1186 { | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1187 register Lisp_Object tem, valcontents, newval; |
298 | 1188 |
1189 CHECK_SYMBOL (sym, 0); | |
1190 | |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
1191 valcontents = XSYMBOL (sym)->value; |
11019
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
1192 if (EQ (sym, Qnil) || EQ (sym, Qt) || KBOARD_OBJFWDP (valcontents)) |
298 | 1193 error ("Symbol %s may not be buffer-local", XSYMBOL (sym)->name->data); |
1194 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1195 if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) |
298 | 1196 return sym; |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1197 if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
298 | 1198 { |
11239
38aef18e8e3d
(Ftype_of, do_symval_forwarding, store_symval_forwarding)
Richard M. Stallman <rms@gnu.org>
parents:
11219
diff
changeset
|
1199 XMISCTYPE (XSYMBOL (sym)->value) = Lisp_Misc_Buffer_Local_Value; |
298 | 1200 return sym; |
1201 } | |
1202 if (EQ (valcontents, Qunbound)) | |
1203 XSYMBOL (sym)->value = Qnil; | |
1204 tem = Fcons (Qnil, Fsymbol_value (sym)); | |
1205 XCONS (tem)->car = tem; | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1206 newval = allocate_misc (); |
11239
38aef18e8e3d
(Ftype_of, do_symval_forwarding, store_symval_forwarding)
Richard M. Stallman <rms@gnu.org>
parents:
11219
diff
changeset
|
1207 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1208 XBUFFER_LOCAL_VALUE (newval)->car = XSYMBOL (sym)->value; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1209 XBUFFER_LOCAL_VALUE (newval)->cdr = Fcons (Fcurrent_buffer (), tem); |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1210 XSYMBOL (sym)->value = newval; |
298 | 1211 return sym; |
1212 } | |
1213 | |
1214 DEFUN ("make-local-variable", Fmake_local_variable, Smake_local_variable, | |
1215 1, 1, "vMake Local Variable: ", | |
1216 "Make VARIABLE have a separate value in the current buffer.\n\ | |
1217 Other buffers will continue to share a common default value.\n\ | |
6825
f70a517ae9e2
(Fsetq_default, Fmake_local_variable): Doc syntax fix.
Richard M. Stallman <rms@gnu.org>
parents:
6497
diff
changeset
|
1218 \(The buffer-local value of VARIABLE starts out as the same value\n\ |
f70a517ae9e2
(Fsetq_default, Fmake_local_variable): Doc syntax fix.
Richard M. Stallman <rms@gnu.org>
parents:
6497
diff
changeset
|
1219 VARIABLE previously had. If VARIABLE was void, it remains void.\)\n\ |
298 | 1220 See also `make-variable-buffer-local'.\n\n\ |
1221 If the variable is already arranged to become local when set,\n\ | |
1222 this function causes a local value to exist for this buffer,\n\ | |
9194
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1223 just as setting the variable would do.\n\ |
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1224 \n\ |
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1225 Do not use `make-local-variable' to make a hook variable buffer-local.\n\ |
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1226 Use `make-local-hook' instead.") |
298 | 1227 (sym) |
1228 register Lisp_Object sym; | |
1229 { | |
1230 register Lisp_Object tem, valcontents; | |
1231 | |
1232 CHECK_SYMBOL (sym, 0); | |
1233 | |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
1234 valcontents = XSYMBOL (sym)->value; |
11019
48bf6677dab3
(find_symbol_value): current_perdisplay now is never null.
Karl Heuer <kwzh@gnu.org>
parents:
11002
diff
changeset
|
1235 if (EQ (sym, Qnil) || EQ (sym, Qt) || KBOARD_OBJFWDP (valcontents)) |
298 | 1236 error ("Symbol %s may not be buffer-local", XSYMBOL (sym)->name->data); |
1237 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1238 if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents)) |
298 | 1239 { |
1240 tem = Fboundp (sym); | |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
1241 |
298 | 1242 /* Make sure the symbol has a local value in this particular buffer, |
1243 by setting it to the same value it already has. */ | |
1244 Fset (sym, (EQ (tem, Qt) ? Fsymbol_value (sym) : Qunbound)); | |
1245 return sym; | |
1246 } | |
1247 /* Make sure sym is set up to hold per-buffer values */ | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1248 if (!SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
298 | 1249 { |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1250 Lisp_Object newval; |
298 | 1251 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); |
1252 XCONS (tem)->car = tem; | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1253 newval = allocate_misc (); |
11239
38aef18e8e3d
(Ftype_of, do_symval_forwarding, store_symval_forwarding)
Richard M. Stallman <rms@gnu.org>
parents:
11219
diff
changeset
|
1254 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1255 XBUFFER_LOCAL_VALUE (newval)->car = XSYMBOL (sym)->value; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1256 XBUFFER_LOCAL_VALUE (newval)->cdr = Fcons (Qnil, tem); |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1257 XSYMBOL (sym)->value = newval; |
298 | 1258 } |
1259 /* Make sure this buffer has its own value of sym */ | |
1260 tem = Fassq (sym, current_buffer->local_var_alist); | |
490 | 1261 if (NILP (tem)) |
298 | 1262 { |
1263 current_buffer->local_var_alist | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1264 = Fcons (Fcons (sym, XCONS (XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->cdr)->cdr), |
298 | 1265 current_buffer->local_var_alist); |
1266 | |
1267 /* Make sure symbol does not think it is set up for this buffer; | |
1268 force it to look once again for this buffer's value */ | |
1269 { | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1270 Lisp_Object *pvalbuf; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1271 valcontents = XSYMBOL (sym)->value; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1272 pvalbuf = &XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1273 if (current_buffer == XBUFFER (*pvalbuf)) |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1274 *pvalbuf = Qnil; |
298 | 1275 } |
1278
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1276 } |
298 | 1277 |
1278
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1278 /* If the symbol forwards into a C variable, then swap in the |
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1279 variable for this buffer immediately. If C code modifies the |
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1280 variable before we swap in, then that new value will clobber the |
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1281 default value the next time we swap. */ |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1282 valcontents = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->car; |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1283 if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents)) |
1278
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1284 swap_in_symval_forwarding (sym, XSYMBOL (sym)->value); |
0a0646ae381f
* data.c (Fmake_local_variable): If SYM forwards to a C variable,
Jim Blandy <jimb@redhat.com>
parents:
1263
diff
changeset
|
1285 |
298 | 1286 return sym; |
1287 } | |
1288 | |
1289 DEFUN ("kill-local-variable", Fkill_local_variable, Skill_local_variable, | |
1290 1, 1, "vKill Local Variable: ", | |
1291 "Make VARIABLE no longer have a separate value in the current buffer.\n\ | |
1292 From now on the default value will apply in this buffer.") | |
1293 (sym) | |
1294 register Lisp_Object sym; | |
1295 { | |
1296 register Lisp_Object tem, valcontents; | |
1297 | |
1298 CHECK_SYMBOL (sym, 0); | |
1299 | |
1300 valcontents = XSYMBOL (sym)->value; | |
1301 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1302 if (BUFFER_OBJFWDP (valcontents)) |
298 | 1303 { |
9465
ea2ee8bd3c63
(do_symval_forwarding, store_symval_forwarding, find_symbol_value, Fset,
Karl Heuer <kwzh@gnu.org>
parents:
9369
diff
changeset
|
1304 register int idx = XBUFFER_OBJFWD (valcontents)->offset; |
9364
0bba3bd707c7
(Fset, default_value, Fset_default, Fkill_local_variable): Access
Karl Heuer <kwzh@gnu.org>
parents:
9301
diff
changeset
|
1305 register int mask = XINT (*((Lisp_Object*) |
0bba3bd707c7
(Fset, default_value, Fset_default, Fkill_local_variable): Access
Karl Heuer <kwzh@gnu.org>
parents:
9301
diff
changeset
|
1306 (idx + (char *)&buffer_local_flags))); |
298 | 1307 |
1308 if (mask > 0) | |
1309 { | |
1310 *(Lisp_Object *)(idx + (char *) current_buffer) | |
1311 = *(Lisp_Object *)(idx + (char *) &buffer_defaults); | |
1312 current_buffer->local_var_flags &= ~mask; | |
1313 } | |
1314 return sym; | |
1315 } | |
1316 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1317 if (!BUFFER_LOCAL_VALUEP (valcontents) |
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1318 && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
298 | 1319 return sym; |
1320 | |
1321 /* Get rid of this buffer's alist element, if any */ | |
1322 | |
1323 tem = Fassq (sym, current_buffer->local_var_alist); | |
490 | 1324 if (!NILP (tem)) |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1325 current_buffer->local_var_alist |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1326 = Fdelq (tem, current_buffer->local_var_alist); |
298 | 1327 |
1328 /* Make sure symbol does not think it is set up for this buffer; | |
1329 force it to look once again for this buffer's value */ | |
1330 { | |
9895
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1331 Lisp_Object *pvalbuf; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1332 valcontents = XSYMBOL (sym)->value; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1333 pvalbuf = &XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1334 if (current_buffer == XBUFFER (*pvalbuf)) |
924f7b9ce544
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Karl Heuer <kwzh@gnu.org>
parents:
9889
diff
changeset
|
1335 *pvalbuf = Qnil; |
298 | 1336 } |
1337 | |
1338 return sym; | |
1339 } | |
9194
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1340 |
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1341 DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, |
12113
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1342 1, 2, 0, |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1343 "Non-nil if VARIABLE has a local binding in buffer BUFFER.\n\ |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1344 BUFFER defaults to the current buffer.") |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1345 (sym, buffer) |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1346 register Lisp_Object sym, buffer; |
9194
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1347 { |
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1348 Lisp_Object valcontents; |
12113
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1349 register struct buffer *buf; |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1350 |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1351 if (NILP (buffer)) |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1352 buf = current_buffer; |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1353 else |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1354 { |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1355 CHECK_BUFFER (buffer, 0); |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1356 buf = XBUFFER (buffer); |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1357 } |
9194
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1358 |
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1359 CHECK_SYMBOL (sym, 0); |
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1360 |
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1361 valcontents = XSYMBOL (sym)->value; |
12113
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1362 if (BUFFER_LOCAL_VALUEP (valcontents) |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1363 && SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1364 { |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1365 Lisp_Object tail, elt; |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1366 for (tail = buf->local_var_alist; CONSP (tail); tail = XCONS (tail)->cdr) |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1367 { |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1368 elt = XCONS (tail)->car; |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1369 if (EQ (sym, XCONS (elt)->car)) |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1370 return Qt; |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1371 } |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1372 } |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1373 if (BUFFER_OBJFWDP (valcontents)) |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1374 { |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1375 int offset = XBUFFER_OBJFWD (valcontents)->offset; |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1376 int mask = XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_flags)); |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1377 if (mask == -1 || (buf->local_var_flags & mask)) |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1378 return Qt; |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1379 } |
d96b45f31afa
(Flocal_variable_p): New optional arg BUFFER.
Karl Heuer <kwzh@gnu.org>
parents:
12043
diff
changeset
|
1380 return Qnil; |
9194
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1381 } |
298 | 1382 |
648 | 1383 /* Find the function at the end of a chain of symbol function indirections. */ |
1384 | |
1385 /* If OBJECT is a symbol, find the end of its function chain and | |
1386 return the value found there. If OBJECT is not a symbol, just | |
1387 return it. If there is a cycle in the function chain, signal a | |
1388 cyclic-function-indirection error. | |
1389 | |
1390 This is like Findirect_function, except that it doesn't signal an | |
1391 error if the chain ends up unbound. */ | |
1392 Lisp_Object | |
1648
27e9f99fe095
src/ * data.c (indirect_function): Delete unused argument ERROR.
Jim Blandy <jimb@redhat.com>
parents:
1508
diff
changeset
|
1393 indirect_function (object) |
9194
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
1394 register Lisp_Object object; |
648 | 1395 { |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3529
diff
changeset
|
1396 Lisp_Object tortoise, hare; |
648 | 1397 |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3529
diff
changeset
|
1398 hare = tortoise = object; |
648 | 1399 |
1400 for (;;) | |
1401 { | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1402 if (!SYMBOLP (hare) || EQ (hare, Qunbound)) |
648 | 1403 break; |
1404 hare = XSYMBOL (hare)->function; | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1405 if (!SYMBOLP (hare) || EQ (hare, Qunbound)) |
648 | 1406 break; |
1407 hare = XSYMBOL (hare)->function; | |
1408 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3529
diff
changeset
|
1409 tortoise = XSYMBOL (tortoise)->function; |
648 | 1410 |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3529
diff
changeset
|
1411 if (EQ (hare, tortoise)) |
648 | 1412 Fsignal (Qcyclic_function_indirection, Fcons (object, Qnil)); |
1413 } | |
1414 | |
1415 return hare; | |
1416 } | |
1417 | |
1418 DEFUN ("indirect-function", Findirect_function, Sindirect_function, 1, 1, 0, | |
1419 "Return the function at the end of OBJECT's function chain.\n\ | |
1420 If OBJECT is a symbol, follow all function indirections and return the final\n\ | |
1421 function binding.\n\ | |
1422 If OBJECT is not a symbol, just return it.\n\ | |
1423 Signal a void-function error if the final symbol is unbound.\n\ | |
1424 Signal a cyclic-function-indirection error if there is a loop in the\n\ | |
1425 function chain of symbols.") | |
1426 (object) | |
1427 register Lisp_Object object; | |
1428 { | |
1429 Lisp_Object result; | |
1430 | |
1431 result = indirect_function (object); | |
1432 | |
1433 if (EQ (result, Qunbound)) | |
1434 return Fsignal (Qvoid_function, Fcons (object, Qnil)); | |
1435 return result; | |
1436 } | |
1437 | |
298 | 1438 /* Extract and set vector and string elements */ |
1439 | |
1440 DEFUN ("aref", Faref, Saref, 2, 2, 0, | |
1441 "Return the element of ARRAY at index INDEX.\n\ | |
1442 ARRAY may be a vector or a string, or a byte-code object. INDEX starts at 0.") | |
1443 (array, idx) | |
1444 register Lisp_Object array; | |
1445 Lisp_Object idx; | |
1446 { | |
1447 register int idxval; | |
1448 | |
1449 CHECK_NUMBER (idx, 1); | |
1450 idxval = XINT (idx); | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1451 if (STRINGP (array)) |
298 | 1452 { |
1453 Lisp_Object val; | |
9966
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1454 if (idxval < 0 || idxval >= XSTRING (array)->size) |
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1455 args_out_of_range (array, idx); |
9301
e6daff3e246f
(Faref, Farray_length): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9263
diff
changeset
|
1456 XSETFASTINT (val, (unsigned char) XSTRING (array)->data[idxval]); |
298 | 1457 return val; |
1458 } | |
1459 else | |
9966
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1460 { |
10290
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1461 int size; |
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1462 if (VECTORP (array)) |
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1463 size = XVECTOR (array)->size; |
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1464 else if (COMPILEDP (array)) |
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1465 size = XVECTOR (array)->size & PSEUDOVECTOR_SIZE_MASK; |
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1466 else |
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1467 wrong_type_argument (Qarrayp, array); |
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1468 |
1bcc91a4b210
(Faref): Handle compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10248
diff
changeset
|
1469 if (idxval < 0 || idxval >= size) |
9966
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1470 args_out_of_range (array, idx); |
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1471 return XVECTOR (array)->contents[idxval]; |
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1472 } |
298 | 1473 } |
1474 | |
1475 DEFUN ("aset", Faset, Saset, 3, 3, 0, | |
5660 | 1476 "Store into the element of ARRAY at index IDX the value NEWELT.\n\ |
1477 ARRAY may be a vector or a string. IDX starts at 0.") | |
298 | 1478 (array, idx, newelt) |
1479 register Lisp_Object array; | |
1480 Lisp_Object idx, newelt; | |
1481 { | |
1482 register int idxval; | |
1483 | |
1484 CHECK_NUMBER (idx, 1); | |
1485 idxval = XINT (idx); | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1486 if (!VECTORP (array) && !STRINGP (array)) |
298 | 1487 array = wrong_type_argument (Qarrayp, array); |
1488 CHECK_IMPURE (array); | |
1489 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1490 if (VECTORP (array)) |
9966
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1491 { |
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1492 if (idxval < 0 || idxval >= XVECTOR (array)->size) |
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1493 args_out_of_range (array, idx); |
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1494 XVECTOR (array)->contents[idxval] = newelt; |
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1495 } |
298 | 1496 else |
1497 { | |
9966
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1498 if (idxval < 0 || idxval >= XSTRING (array)->size) |
d64bdd958254
(Farray_length): Delete this obsolete function.
Karl Heuer <kwzh@gnu.org>
parents:
9954
diff
changeset
|
1499 args_out_of_range (array, idx); |
298 | 1500 CHECK_NUMBER (newelt, 2); |
1501 XSTRING (array)->data[idxval] = XINT (newelt); | |
1502 } | |
1503 | |
1504 return newelt; | |
1505 } | |
1506 | |
1507 /* Arithmetic functions */ | |
1508 | |
1509 enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal }; | |
1510 | |
1511 Lisp_Object | |
1512 arithcompare (num1, num2, comparison) | |
1513 Lisp_Object num1, num2; | |
1514 enum comparison comparison; | |
1515 { | |
1516 double f1, f2; | |
1517 int floatp = 0; | |
1518 | |
1519 #ifdef LISP_FLOAT_TYPE | |
1520 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0); | |
1521 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0); | |
1522 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1523 if (FLOATP (num1) || FLOATP (num2)) |
298 | 1524 { |
1525 floatp = 1; | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1526 f1 = (FLOATP (num1)) ? XFLOAT (num1)->data : XINT (num1); |
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1527 f2 = (FLOATP (num2)) ? XFLOAT (num2)->data : XINT (num2); |
298 | 1528 } |
1529 #else | |
1530 CHECK_NUMBER_COERCE_MARKER (num1, 0); | |
1531 CHECK_NUMBER_COERCE_MARKER (num2, 0); | |
1532 #endif /* LISP_FLOAT_TYPE */ | |
1533 | |
1534 switch (comparison) | |
1535 { | |
1536 case equal: | |
1537 if (floatp ? f1 == f2 : XINT (num1) == XINT (num2)) | |
1538 return Qt; | |
1539 return Qnil; | |
1540 | |
1541 case notequal: | |
1542 if (floatp ? f1 != f2 : XINT (num1) != XINT (num2)) | |
1543 return Qt; | |
1544 return Qnil; | |
1545 | |
1546 case less: | |
1547 if (floatp ? f1 < f2 : XINT (num1) < XINT (num2)) | |
1548 return Qt; | |
1549 return Qnil; | |
1550 | |
1551 case less_or_equal: | |
1552 if (floatp ? f1 <= f2 : XINT (num1) <= XINT (num2)) | |
1553 return Qt; | |
1554 return Qnil; | |
1555 | |
1556 case grtr: | |
1557 if (floatp ? f1 > f2 : XINT (num1) > XINT (num2)) | |
1558 return Qt; | |
1559 return Qnil; | |
1560 | |
1561 case grtr_or_equal: | |
1562 if (floatp ? f1 >= f2 : XINT (num1) >= XINT (num2)) | |
1563 return Qt; | |
1564 return Qnil; | |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1565 |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1566 default: |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1567 abort (); |
298 | 1568 } |
1569 } | |
1570 | |
1571 DEFUN ("=", Feqlsign, Seqlsign, 2, 2, 0, | |
1572 "T if two args, both numbers or markers, are equal.") | |
1573 (num1, num2) | |
1574 register Lisp_Object num1, num2; | |
1575 { | |
1576 return arithcompare (num1, num2, equal); | |
1577 } | |
1578 | |
1579 DEFUN ("<", Flss, Slss, 2, 2, 0, | |
1580 "T if first arg is less than second arg. Both must be numbers or markers.") | |
1581 (num1, num2) | |
1582 register Lisp_Object num1, num2; | |
1583 { | |
1584 return arithcompare (num1, num2, less); | |
1585 } | |
1586 | |
1587 DEFUN (">", Fgtr, Sgtr, 2, 2, 0, | |
1588 "T if first arg is greater than second arg. Both must be numbers or markers.") | |
1589 (num1, num2) | |
1590 register Lisp_Object num1, num2; | |
1591 { | |
1592 return arithcompare (num1, num2, grtr); | |
1593 } | |
1594 | |
1595 DEFUN ("<=", Fleq, Sleq, 2, 2, 0, | |
1596 "T if first arg is less than or equal to second arg.\n\ | |
1597 Both must be numbers or markers.") | |
1598 (num1, num2) | |
1599 register Lisp_Object num1, num2; | |
1600 { | |
1601 return arithcompare (num1, num2, less_or_equal); | |
1602 } | |
1603 | |
1604 DEFUN (">=", Fgeq, Sgeq, 2, 2, 0, | |
1605 "T if first arg is greater than or equal to second arg.\n\ | |
1606 Both must be numbers or markers.") | |
1607 (num1, num2) | |
1608 register Lisp_Object num1, num2; | |
1609 { | |
1610 return arithcompare (num1, num2, grtr_or_equal); | |
1611 } | |
1612 | |
1613 DEFUN ("/=", Fneq, Sneq, 2, 2, 0, | |
1614 "T if first arg is not equal to second arg. Both must be numbers or markers.") | |
1615 (num1, num2) | |
1616 register Lisp_Object num1, num2; | |
1617 { | |
1618 return arithcompare (num1, num2, notequal); | |
1619 } | |
1620 | |
1621 DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0, "T if NUMBER is zero.") | |
1622 (num) | |
1623 register Lisp_Object num; | |
1624 { | |
1625 #ifdef LISP_FLOAT_TYPE | |
1626 CHECK_NUMBER_OR_FLOAT (num, 0); | |
1627 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1628 if (FLOATP (num)) |
298 | 1629 { |
1630 if (XFLOAT(num)->data == 0.0) | |
1631 return Qt; | |
1632 return Qnil; | |
1633 } | |
1634 #else | |
1635 CHECK_NUMBER (num, 0); | |
1636 #endif /* LISP_FLOAT_TYPE */ | |
1637 | |
1638 if (!XINT (num)) | |
1639 return Qt; | |
1640 return Qnil; | |
1641 } | |
1642 | |
12043 | 1643 /* Convert between long values and pairs of Lisp integers. */ |
2515
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1644 |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1645 Lisp_Object |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1646 long_to_cons (i) |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1647 unsigned long i; |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1648 { |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1649 unsigned int top = i >> 16; |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1650 unsigned int bot = i & 0xFFFF; |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1651 if (top == 0) |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1652 return make_number (bot); |
11879
606889516975
(long_to_cons): Don't assume 32-bit longs.
Karl Heuer <kwzh@gnu.org>
parents:
11734
diff
changeset
|
1653 if (top == (unsigned long)-1 >> 16) |
2515
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1654 return Fcons (make_number (-1), make_number (bot)); |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1655 return Fcons (make_number (top), make_number (bot)); |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1656 } |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1657 |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1658 unsigned long |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1659 cons_to_long (c) |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1660 Lisp_Object c; |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1661 { |
3675
f42eaf84478f
(cons_to_long): Declare top, bot as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1662 Lisp_Object top, bot; |
2515
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1663 if (INTEGERP (c)) |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1664 return XINT (c); |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1665 top = XCONS (c)->car; |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1666 bot = XCONS (c)->cdr; |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1667 if (CONSP (bot)) |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1668 bot = XCONS (bot)->car; |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1669 return ((XINT (top) << 16) | XINT (bot)); |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1670 } |
c0cdd6a80391
long_to_cons and cons_to_long are generally useful things; they're
Jim Blandy <jimb@redhat.com>
parents:
2429
diff
changeset
|
1671 |
2429
96b55f2f19cd
Rename int-to-string to number-to-string, since it can handle
Jim Blandy <jimb@redhat.com>
parents:
2092
diff
changeset
|
1672 DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0, |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1673 "Convert NUM to a string by printing it in decimal.\n\ |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1674 Uses a minus sign if negative.\n\ |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1675 NUM may be an integer or a floating point number.") |
298 | 1676 (num) |
1677 Lisp_Object num; | |
1678 { | |
1679 char buffer[20]; | |
1680 | |
1681 #ifndef LISP_FLOAT_TYPE | |
1682 CHECK_NUMBER (num, 0); | |
1683 #else | |
1684 CHECK_NUMBER_OR_FLOAT (num, 0); | |
1685 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1686 if (FLOATP (num)) |
298 | 1687 { |
1688 char pigbuf[350]; /* see comments in float_to_string */ | |
1689 | |
1690 float_to_string (pigbuf, XFLOAT(num)->data); | |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
1691 return build_string (pigbuf); |
298 | 1692 } |
1693 #endif /* LISP_FLOAT_TYPE */ | |
1694 | |
11701
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1695 if (sizeof (int) == sizeof (EMACS_INT)) |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1696 sprintf (buffer, "%d", XINT (num)); |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1697 else if (sizeof (long) == sizeof (EMACS_INT)) |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1698 sprintf (buffer, "%ld", XINT (num)); |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1699 else |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1700 abort (); |
298 | 1701 return build_string (buffer); |
1702 } | |
1703 | |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1704 DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 1, 0, |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1705 "Convert STRING to a number by parsing it as a decimal number.\n\ |
6448
9d04c87e0da1
(Fstring_to_number): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6446
diff
changeset
|
1706 This parses both integers and floating point numbers.\n\ |
9d04c87e0da1
(Fstring_to_number): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6446
diff
changeset
|
1707 It ignores leading spaces and tabs.") |
298 | 1708 (str) |
1709 register Lisp_Object str; | |
1710 { | |
11701
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1711 Lisp_Object value; |
1987
cd893024d6b9
* data.c (Fstring_to_number): Declare p to be an unsigned char, to
Jim Blandy <jimb@redhat.com>
parents:
1914
diff
changeset
|
1712 unsigned char *p; |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1713 |
298 | 1714 CHECK_STRING (str, 0); |
1715 | |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1716 p = XSTRING (str)->data; |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1717 |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1718 /* Skip any whitespace at the front of the number. Some versions of |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1719 atoi do this anyway, so we might as well make Emacs lisp consistent. */ |
1987
cd893024d6b9
* data.c (Fstring_to_number): Declare p to be an unsigned char, to
Jim Blandy <jimb@redhat.com>
parents:
1914
diff
changeset
|
1720 while (*p == ' ' || *p == '\t') |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1721 p++; |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1722 |
298 | 1723 #ifdef LISP_FLOAT_TYPE |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1724 if (isfloat_string (p)) |
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1725 return make_float (atof (p)); |
298 | 1726 #endif /* LISP_FLOAT_TYPE */ |
1727 | |
11701
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1728 if (sizeof (int) == sizeof (EMACS_INT)) |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1729 XSETINT (value, atoi (p)); |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1730 else if (sizeof (long) == sizeof (EMACS_INT)) |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1731 XSETINT (value, atol (p)); |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1732 else |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1733 abort (); |
d0eaa6b6dc72
(Fnumber_to_string, Fstring_to_number):
Richard M. Stallman <rms@gnu.org>
parents:
11688
diff
changeset
|
1734 return value; |
298 | 1735 } |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
1736 |
298 | 1737 enum arithop |
1738 { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin }; | |
1739 | |
1508
768d4c10c2bf
* data.c (Fset): See if current_alist_element points to itself
Jim Blandy <jimb@redhat.com>
parents:
1293
diff
changeset
|
1740 extern Lisp_Object float_arith_driver (); |
768d4c10c2bf
* data.c (Fset): See if current_alist_element points to itself
Jim Blandy <jimb@redhat.com>
parents:
1293
diff
changeset
|
1741 |
298 | 1742 Lisp_Object |
3338
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1743 arith_driver (code, nargs, args) |
298 | 1744 enum arithop code; |
1745 int nargs; | |
1746 register Lisp_Object *args; | |
1747 { | |
1748 register Lisp_Object val; | |
1749 register int argnum; | |
11688
f1e6033d8aca
(arith_driver): Make accum and next EMACS_INTs.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
1750 register EMACS_INT accum; |
f1e6033d8aca
(arith_driver): Make accum and next EMACS_INTs.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
1751 register EMACS_INT next; |
298 | 1752 |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10290
diff
changeset
|
1753 switch (SWITCH_ENUM_CAST (code)) |
298 | 1754 { |
1755 case Alogior: | |
1756 case Alogxor: | |
1757 case Aadd: | |
1758 case Asub: | |
1759 accum = 0; break; | |
1760 case Amult: | |
1761 accum = 1; break; | |
1762 case Alogand: | |
1763 accum = -1; break; | |
1764 } | |
1765 | |
1766 for (argnum = 0; argnum < nargs; argnum++) | |
1767 { | |
1768 val = args[argnum]; /* using args[argnum] as argument to CHECK_NUMBER_... */ | |
1769 #ifdef LISP_FLOAT_TYPE | |
1770 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum); | |
1771 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1772 if (FLOATP (val)) /* time to do serious math */ |
298 | 1773 return (float_arith_driver ((double) accum, argnum, code, |
1774 nargs, args)); | |
1775 #else | |
1776 CHECK_NUMBER_COERCE_MARKER (val, argnum); | |
1777 #endif /* LISP_FLOAT_TYPE */ | |
1778 args[argnum] = val; /* runs into a compiler bug. */ | |
1779 next = XINT (args[argnum]); | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10290
diff
changeset
|
1780 switch (SWITCH_ENUM_CAST (code)) |
298 | 1781 { |
1782 case Aadd: accum += next; break; | |
1783 case Asub: | |
1784 if (!argnum && nargs != 1) | |
1785 next = - next; | |
1786 accum -= next; | |
1787 break; | |
1788 case Amult: accum *= next; break; | |
1789 case Adiv: | |
1790 if (!argnum) accum = next; | |
3338
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1791 else |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1792 { |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1793 if (next == 0) |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1794 Fsignal (Qarith_error, Qnil); |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1795 accum /= next; |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1796 } |
298 | 1797 break; |
1798 case Alogand: accum &= next; break; | |
1799 case Alogior: accum |= next; break; | |
1800 case Alogxor: accum ^= next; break; | |
1801 case Amax: if (!argnum || next > accum) accum = next; break; | |
1802 case Amin: if (!argnum || next < accum) accum = next; break; | |
1803 } | |
1804 } | |
1805 | |
9263
cda13734e32c
(make_number, Fsymbol_name, do_symval_forwarding, swap_in_symval_forwarding,
Karl Heuer <kwzh@gnu.org>
parents:
9194
diff
changeset
|
1806 XSETINT (val, accum); |
298 | 1807 return val; |
1808 } | |
1809 | |
1810 #ifdef LISP_FLOAT_TYPE | |
6201 | 1811 |
1812 #undef isnan | |
1813 #define isnan(x) ((x) != (x)) | |
1814 | |
298 | 1815 Lisp_Object |
1816 float_arith_driver (accum, argnum, code, nargs, args) | |
1817 double accum; | |
1818 register int argnum; | |
1819 enum arithop code; | |
1820 int nargs; | |
1821 register Lisp_Object *args; | |
1822 { | |
1823 register Lisp_Object val; | |
1824 double next; | |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
1825 |
298 | 1826 for (; argnum < nargs; argnum++) |
1827 { | |
1828 val = args[argnum]; /* using args[argnum] as argument to CHECK_NUMBER_... */ | |
1829 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum); | |
1830 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1831 if (FLOATP (val)) |
298 | 1832 { |
1833 next = XFLOAT (val)->data; | |
1834 } | |
1835 else | |
1836 { | |
1837 args[argnum] = val; /* runs into a compiler bug. */ | |
1838 next = XINT (args[argnum]); | |
1839 } | |
10457
2ab3bd0288a9
Change all occurences of SWITCH_ENUM_BUG to use SWITCH_ENUM_CAST instead.
Karl Heuer <kwzh@gnu.org>
parents:
10290
diff
changeset
|
1840 switch (SWITCH_ENUM_CAST (code)) |
298 | 1841 { |
1842 case Aadd: | |
1843 accum += next; | |
1844 break; | |
1845 case Asub: | |
1846 if (!argnum && nargs != 1) | |
1847 next = - next; | |
1848 accum -= next; | |
1849 break; | |
1850 case Amult: | |
1851 accum *= next; | |
1852 break; | |
1853 case Adiv: | |
1854 if (!argnum) | |
1855 accum = next; | |
1856 else | |
3338
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1857 { |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1858 if (next == 0) |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1859 Fsignal (Qarith_error, Qnil); |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1860 accum /= next; |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1861 } |
298 | 1862 break; |
1863 case Alogand: | |
1864 case Alogior: | |
1865 case Alogxor: | |
1866 return wrong_type_argument (Qinteger_or_marker_p, val); | |
1867 case Amax: | |
6201 | 1868 if (!argnum || isnan (next) || next > accum) |
298 | 1869 accum = next; |
1870 break; | |
1871 case Amin: | |
6201 | 1872 if (!argnum || isnan (next) || next < accum) |
298 | 1873 accum = next; |
1874 break; | |
1875 } | |
1876 } | |
1877 | |
1878 return make_float (accum); | |
1879 } | |
1880 #endif /* LISP_FLOAT_TYPE */ | |
1881 | |
1882 DEFUN ("+", Fplus, Splus, 0, MANY, 0, | |
1883 "Return sum of any number of arguments, which are numbers or markers.") | |
1884 (nargs, args) | |
1885 int nargs; | |
1886 Lisp_Object *args; | |
1887 { | |
1888 return arith_driver (Aadd, nargs, args); | |
1889 } | |
1890 | |
1891 DEFUN ("-", Fminus, Sminus, 0, MANY, 0, | |
1892 "Negate number or subtract numbers or markers.\n\ | |
1893 With one arg, negates it. With more than one arg,\n\ | |
1894 subtracts all but the first from the first.") | |
1895 (nargs, args) | |
1896 int nargs; | |
1897 Lisp_Object *args; | |
1898 { | |
1899 return arith_driver (Asub, nargs, args); | |
1900 } | |
1901 | |
1902 DEFUN ("*", Ftimes, Stimes, 0, MANY, 0, | |
1903 "Returns product of any number of arguments, which are numbers or markers.") | |
1904 (nargs, args) | |
1905 int nargs; | |
1906 Lisp_Object *args; | |
1907 { | |
1908 return arith_driver (Amult, nargs, args); | |
1909 } | |
1910 | |
1911 DEFUN ("/", Fquo, Squo, 2, MANY, 0, | |
1912 "Returns first argument divided by all the remaining arguments.\n\ | |
1913 The arguments must be numbers or markers.") | |
1914 (nargs, args) | |
1915 int nargs; | |
1916 Lisp_Object *args; | |
1917 { | |
1918 return arith_driver (Adiv, nargs, args); | |
1919 } | |
1920 | |
1921 DEFUN ("%", Frem, Srem, 2, 2, 0, | |
1922 "Returns remainder of first arg divided by second.\n\ | |
4447
ba273b48143b
(Frem): Don't accept floats, just ints and markers.
Richard M. Stallman <rms@gnu.org>
parents:
4037
diff
changeset
|
1923 Both must be integers or markers.") |
298 | 1924 (num1, num2) |
1925 register Lisp_Object num1, num2; | |
1926 { | |
1927 Lisp_Object val; | |
1928 | |
1929 CHECK_NUMBER_COERCE_MARKER (num1, 0); | |
1930 CHECK_NUMBER_COERCE_MARKER (num2, 1); | |
1931 | |
3338
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1932 if (XFASTINT (num2) == 0) |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1933 Fsignal (Qarith_error, Qnil); |
30b946dd8c66
(float_arith_driver): Detect division by zero in advance.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1934 |
9263
cda13734e32c
(make_number, Fsymbol_name, do_symval_forwarding, swap_in_symval_forwarding,
Karl Heuer <kwzh@gnu.org>
parents:
9194
diff
changeset
|
1935 XSETINT (val, XINT (num1) % XINT (num2)); |
298 | 1936 return val; |
1937 } | |
1938 | |
5776
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1939 #ifndef HAVE_FMOD |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1940 double |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1941 fmod (f1, f2) |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1942 double f1, f2; |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1943 { |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1944 #ifdef HAVE_DREM /* Some systems use this non-standard name. */ |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1945 return (drem (f1, f2)); |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1946 #else /* Other systems don't seem to have it at all. */ |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1947 return (f1 - f2 * floor (f1/f2)); |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1948 #endif |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1949 } |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1950 #endif /* ! HAVE_FMOD */ |
6130ebde8d3b
(fmod): Implement it on systems where it's missing, using drem if available.
Karl Heuer <kwzh@gnu.org>
parents:
5729
diff
changeset
|
1951 |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1952 DEFUN ("mod", Fmod, Smod, 2, 2, 0, |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1953 "Returns X modulo Y.\n\ |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1954 The result falls between zero (inclusive) and Y (exclusive).\n\ |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1955 Both X and Y must be numbers or markers.") |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1956 (num1, num2) |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1957 register Lisp_Object num1, num2; |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1958 { |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1959 Lisp_Object val; |
11688
f1e6033d8aca
(arith_driver): Make accum and next EMACS_INTs.
Richard M. Stallman <rms@gnu.org>
parents:
11341
diff
changeset
|
1960 EMACS_INT i1, i2; |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1961 |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1962 #ifdef LISP_FLOAT_TYPE |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1963 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1964 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 1); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1965 |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1966 if (FLOATP (num1) || FLOATP (num2)) |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1967 { |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1968 double f1, f2; |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1969 |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1970 f1 = FLOATP (num1) ? XFLOAT (num1)->data : XINT (num1); |
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
1971 f2 = FLOATP (num2) ? XFLOAT (num2)->data : XINT (num2); |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1972 if (f2 == 0) |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1973 Fsignal (Qarith_error, Qnil); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1974 |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1975 f1 = fmod (f1, f2); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1976 /* If the "remainder" comes out with the wrong sign, fix it. */ |
11734
e6675e3ed8b3
(Fmod): Fix the final adjustment, when f2 < 0 and f1 == 0.
Richard M. Stallman <rms@gnu.org>
parents:
11701
diff
changeset
|
1977 if (f2 < 0 ? f1 > 0 : f1 < 0) |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1978 f1 += f2; |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1979 return (make_float (f1)); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1980 } |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1981 #else /* not LISP_FLOAT_TYPE */ |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1982 CHECK_NUMBER_COERCE_MARKER (num1, 0); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1983 CHECK_NUMBER_COERCE_MARKER (num2, 1); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1984 #endif /* not LISP_FLOAT_TYPE */ |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1985 |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1986 i1 = XINT (num1); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1987 i2 = XINT (num2); |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1988 |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1989 if (i2 == 0) |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1990 Fsignal (Qarith_error, Qnil); |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
1991 |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1992 i1 %= i2; |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1993 |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1994 /* If the "remainder" comes out with the wrong sign, fix it. */ |
11155
0aede77c1593
(Fmod): Fix the final adjustment, when i2 < 0 and i1 == 0.
Richard M. Stallman <rms@gnu.org>
parents:
11019
diff
changeset
|
1995 if (i2 < 0 ? i1 > 0 : i1 < 0) |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1996 i1 += i2; |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1997 |
9263
cda13734e32c
(make_number, Fsymbol_name, do_symval_forwarding, swap_in_symval_forwarding,
Karl Heuer <kwzh@gnu.org>
parents:
9194
diff
changeset
|
1998 XSETINT (val, i1); |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
1999 return val; |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
2000 } |
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
2001 |
298 | 2002 DEFUN ("max", Fmax, Smax, 1, MANY, 0, |
2003 "Return largest of all the arguments (which must be numbers or markers).\n\ | |
2004 The value is always a number; markers are converted to numbers.") | |
2005 (nargs, args) | |
2006 int nargs; | |
2007 Lisp_Object *args; | |
2008 { | |
2009 return arith_driver (Amax, nargs, args); | |
2010 } | |
2011 | |
2012 DEFUN ("min", Fmin, Smin, 1, MANY, 0, | |
2013 "Return smallest of all the arguments (which must be numbers or markers).\n\ | |
2014 The value is always a number; markers are converted to numbers.") | |
2015 (nargs, args) | |
2016 int nargs; | |
2017 Lisp_Object *args; | |
2018 { | |
2019 return arith_driver (Amin, nargs, args); | |
2020 } | |
2021 | |
2022 DEFUN ("logand", Flogand, Slogand, 0, MANY, 0, | |
2023 "Return bitwise-and of all the arguments.\n\ | |
2024 Arguments may be integers, or markers converted to integers.") | |
2025 (nargs, args) | |
2026 int nargs; | |
2027 Lisp_Object *args; | |
2028 { | |
2029 return arith_driver (Alogand, nargs, args); | |
2030 } | |
2031 | |
2032 DEFUN ("logior", Flogior, Slogior, 0, MANY, 0, | |
2033 "Return bitwise-or of all the arguments.\n\ | |
2034 Arguments may be integers, or markers converted to integers.") | |
2035 (nargs, args) | |
2036 int nargs; | |
2037 Lisp_Object *args; | |
2038 { | |
2039 return arith_driver (Alogior, nargs, args); | |
2040 } | |
2041 | |
2042 DEFUN ("logxor", Flogxor, Slogxor, 0, MANY, 0, | |
2043 "Return bitwise-exclusive-or of all the arguments.\n\ | |
2044 Arguments may be integers, or markers converted to integers.") | |
2045 (nargs, args) | |
2046 int nargs; | |
2047 Lisp_Object *args; | |
2048 { | |
2049 return arith_driver (Alogxor, nargs, args); | |
2050 } | |
2051 | |
2052 DEFUN ("ash", Fash, Sash, 2, 2, 0, | |
2053 "Return VALUE with its bits shifted left by COUNT.\n\ | |
2054 If COUNT is negative, shifting is actually to the right.\n\ | |
2055 In this case, the sign bit is duplicated.") | |
11002
ff115809a39e
(Fash): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10951
diff
changeset
|
2056 (value, count) |
ff115809a39e
(Fash): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
10951
diff
changeset
|
2057 register Lisp_Object value, count; |
298 | 2058 { |
2059 register Lisp_Object val; | |
2060 | |
10951
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2061 CHECK_NUMBER (value, 0); |
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2062 CHECK_NUMBER (count, 1); |
298 | 2063 |
10951
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2064 if (XINT (count) > 0) |
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2065 XSETINT (val, XINT (value) << XFASTINT (count)); |
298 | 2066 else |
10951
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2067 XSETINT (val, XINT (value) >> -XINT (count)); |
298 | 2068 return val; |
2069 } | |
2070 | |
2071 DEFUN ("lsh", Flsh, Slsh, 2, 2, 0, | |
2072 "Return VALUE with its bits shifted left by COUNT.\n\ | |
2073 If COUNT is negative, shifting is actually to the right.\n\ | |
2074 In this case, zeros are shifted in on the left.") | |
10951
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2075 (value, count) |
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2076 register Lisp_Object value, count; |
298 | 2077 { |
2078 register Lisp_Object val; | |
2079 | |
10951
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2080 CHECK_NUMBER (value, 0); |
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2081 CHECK_NUMBER (count, 1); |
298 | 2082 |
10951
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2083 if (XINT (count) > 0) |
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2084 XSETINT (val, (EMACS_UINT) XUINT (value) << XFASTINT (count)); |
298 | 2085 else |
10951
6a8b6db450dc
(Fash, Flsh): Change arg names.
Richard M. Stallman <rms@gnu.org>
parents:
10725
diff
changeset
|
2086 XSETINT (val, (EMACS_UINT) XUINT (value) >> -XINT (count)); |
298 | 2087 return val; |
2088 } | |
2089 | |
2090 DEFUN ("1+", Fadd1, Sadd1, 1, 1, 0, | |
2091 "Return NUMBER plus one. NUMBER may be a number or a marker.\n\ | |
2092 Markers are converted to integers.") | |
2093 (num) | |
2094 register Lisp_Object num; | |
2095 { | |
2096 #ifdef LISP_FLOAT_TYPE | |
2097 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0); | |
2098 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
2099 if (FLOATP (num)) |
298 | 2100 return (make_float (1.0 + XFLOAT (num)->data)); |
2101 #else | |
2102 CHECK_NUMBER_COERCE_MARKER (num, 0); | |
2103 #endif /* LISP_FLOAT_TYPE */ | |
2104 | |
9366
60542ab81fb1
(Flsh, Fadd1, Fsub1, Flognot): Don't use XFASTINT when negative.
Karl Heuer <kwzh@gnu.org>
parents:
9364
diff
changeset
|
2105 XSETINT (num, XINT (num) + 1); |
298 | 2106 return num; |
2107 } | |
2108 | |
2109 DEFUN ("1-", Fsub1, Ssub1, 1, 1, 0, | |
2110 "Return NUMBER minus one. NUMBER may be a number or a marker.\n\ | |
2111 Markers are converted to integers.") | |
2112 (num) | |
2113 register Lisp_Object num; | |
2114 { | |
2115 #ifdef LISP_FLOAT_TYPE | |
2116 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0); | |
2117 | |
9147
ee9adbda1ad1
(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp,
Karl Heuer <kwzh@gnu.org>
parents:
9035
diff
changeset
|
2118 if (FLOATP (num)) |
298 | 2119 return (make_float (-1.0 + XFLOAT (num)->data)); |
2120 #else | |
2121 CHECK_NUMBER_COERCE_MARKER (num, 0); | |
2122 #endif /* LISP_FLOAT_TYPE */ | |
2123 | |
9366
60542ab81fb1
(Flsh, Fadd1, Fsub1, Flognot): Don't use XFASTINT when negative.
Karl Heuer <kwzh@gnu.org>
parents:
9364
diff
changeset
|
2124 XSETINT (num, XINT (num) - 1); |
298 | 2125 return num; |
2126 } | |
2127 | |
2128 DEFUN ("lognot", Flognot, Slognot, 1, 1, 0, | |
2129 "Return the bitwise complement of ARG. ARG must be an integer.") | |
2130 (num) | |
2131 register Lisp_Object num; | |
2132 { | |
2133 CHECK_NUMBER (num, 0); | |
9366
60542ab81fb1
(Flsh, Fadd1, Fsub1, Flognot): Don't use XFASTINT when negative.
Karl Heuer <kwzh@gnu.org>
parents:
9364
diff
changeset
|
2134 XSETINT (num, ~XINT (num)); |
298 | 2135 return num; |
2136 } | |
2137 | |
2138 void | |
2139 syms_of_data () | |
2140 { | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2141 Lisp_Object error_tail, arith_tail; |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2142 |
298 | 2143 Qquote = intern ("quote"); |
2144 Qlambda = intern ("lambda"); | |
2145 Qsubr = intern ("subr"); | |
2146 Qerror_conditions = intern ("error-conditions"); | |
2147 Qerror_message = intern ("error-message"); | |
2148 Qtop_level = intern ("top-level"); | |
2149 | |
2150 Qerror = intern ("error"); | |
2151 Qquit = intern ("quit"); | |
2152 Qwrong_type_argument = intern ("wrong-type-argument"); | |
2153 Qargs_out_of_range = intern ("args-out-of-range"); | |
2154 Qvoid_function = intern ("void-function"); | |
648 | 2155 Qcyclic_function_indirection = intern ("cyclic-function-indirection"); |
298 | 2156 Qvoid_variable = intern ("void-variable"); |
2157 Qsetting_constant = intern ("setting-constant"); | |
2158 Qinvalid_read_syntax = intern ("invalid-read-syntax"); | |
2159 | |
2160 Qinvalid_function = intern ("invalid-function"); | |
2161 Qwrong_number_of_arguments = intern ("wrong-number-of-arguments"); | |
2162 Qno_catch = intern ("no-catch"); | |
2163 Qend_of_file = intern ("end-of-file"); | |
2164 Qarith_error = intern ("arith-error"); | |
2165 Qbeginning_of_buffer = intern ("beginning-of-buffer"); | |
2166 Qend_of_buffer = intern ("end-of-buffer"); | |
2167 Qbuffer_read_only = intern ("buffer-read-only"); | |
4036 | 2168 Qmark_inactive = intern ("mark-inactive"); |
298 | 2169 |
2170 Qlistp = intern ("listp"); | |
2171 Qconsp = intern ("consp"); | |
2172 Qsymbolp = intern ("symbolp"); | |
2173 Qintegerp = intern ("integerp"); | |
2174 Qnatnump = intern ("natnump"); | |
6459
30fabcc03f0c
(Qwholenump): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6448
diff
changeset
|
2175 Qwholenump = intern ("wholenump"); |
298 | 2176 Qstringp = intern ("stringp"); |
2177 Qarrayp = intern ("arrayp"); | |
2178 Qsequencep = intern ("sequencep"); | |
2179 Qbufferp = intern ("bufferp"); | |
2180 Qvectorp = intern ("vectorp"); | |
2181 Qchar_or_string_p = intern ("char-or-string-p"); | |
2182 Qmarkerp = intern ("markerp"); | |
1293 | 2183 Qbuffer_or_string_p = intern ("buffer-or-string-p"); |
298 | 2184 Qinteger_or_marker_p = intern ("integer-or-marker-p"); |
2185 Qboundp = intern ("boundp"); | |
2186 Qfboundp = intern ("fboundp"); | |
2187 | |
2188 #ifdef LISP_FLOAT_TYPE | |
2189 Qfloatp = intern ("floatp"); | |
2190 Qnumberp = intern ("numberp"); | |
2191 Qnumber_or_marker_p = intern ("number-or-marker-p"); | |
2192 #endif /* LISP_FLOAT_TYPE */ | |
2193 | |
2194 Qcdr = intern ("cdr"); | |
2195 | |
8401
1eee41c8120c
(syms_of_data): Set up Qadvice_info, Qactivate_advice.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
2196 /* Handle automatic advice activation */ |
8448
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
2197 Qad_advice_info = intern ("ad-advice-info"); |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
2198 Qad_activate = intern ("ad-activate"); |
8401
1eee41c8120c
(syms_of_data): Set up Qadvice_info, Qactivate_advice.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
2199 |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2200 error_tail = Fcons (Qerror, Qnil); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2201 |
298 | 2202 /* ERROR is used as a signaler for random errors for which nothing else is right */ |
2203 | |
2204 Fput (Qerror, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2205 error_tail); |
298 | 2206 Fput (Qerror, Qerror_message, |
2207 build_string ("error")); | |
2208 | |
2209 Fput (Qquit, Qerror_conditions, | |
2210 Fcons (Qquit, Qnil)); | |
2211 Fput (Qquit, Qerror_message, | |
2212 build_string ("Quit")); | |
2213 | |
2214 Fput (Qwrong_type_argument, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2215 Fcons (Qwrong_type_argument, error_tail)); |
298 | 2216 Fput (Qwrong_type_argument, Qerror_message, |
2217 build_string ("Wrong type argument")); | |
2218 | |
2219 Fput (Qargs_out_of_range, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2220 Fcons (Qargs_out_of_range, error_tail)); |
298 | 2221 Fput (Qargs_out_of_range, Qerror_message, |
2222 build_string ("Args out of range")); | |
2223 | |
2224 Fput (Qvoid_function, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2225 Fcons (Qvoid_function, error_tail)); |
298 | 2226 Fput (Qvoid_function, Qerror_message, |
2227 build_string ("Symbol's function definition is void")); | |
2228 | |
648 | 2229 Fput (Qcyclic_function_indirection, Qerror_conditions, |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2230 Fcons (Qcyclic_function_indirection, error_tail)); |
648 | 2231 Fput (Qcyclic_function_indirection, Qerror_message, |
2232 build_string ("Symbol's chain of function indirections contains a loop")); | |
2233 | |
298 | 2234 Fput (Qvoid_variable, Qerror_conditions, |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2235 Fcons (Qvoid_variable, error_tail)); |
298 | 2236 Fput (Qvoid_variable, Qerror_message, |
2237 build_string ("Symbol's value as variable is void")); | |
2238 | |
2239 Fput (Qsetting_constant, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2240 Fcons (Qsetting_constant, error_tail)); |
298 | 2241 Fput (Qsetting_constant, Qerror_message, |
2242 build_string ("Attempt to set a constant symbol")); | |
2243 | |
2244 Fput (Qinvalid_read_syntax, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2245 Fcons (Qinvalid_read_syntax, error_tail)); |
298 | 2246 Fput (Qinvalid_read_syntax, Qerror_message, |
2247 build_string ("Invalid read syntax")); | |
2248 | |
2249 Fput (Qinvalid_function, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2250 Fcons (Qinvalid_function, error_tail)); |
298 | 2251 Fput (Qinvalid_function, Qerror_message, |
2252 build_string ("Invalid function")); | |
2253 | |
2254 Fput (Qwrong_number_of_arguments, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2255 Fcons (Qwrong_number_of_arguments, error_tail)); |
298 | 2256 Fput (Qwrong_number_of_arguments, Qerror_message, |
2257 build_string ("Wrong number of arguments")); | |
2258 | |
2259 Fput (Qno_catch, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2260 Fcons (Qno_catch, error_tail)); |
298 | 2261 Fput (Qno_catch, Qerror_message, |
2262 build_string ("No catch for tag")); | |
2263 | |
2264 Fput (Qend_of_file, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2265 Fcons (Qend_of_file, error_tail)); |
298 | 2266 Fput (Qend_of_file, Qerror_message, |
2267 build_string ("End of file during parsing")); | |
2268 | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2269 arith_tail = Fcons (Qarith_error, error_tail); |
298 | 2270 Fput (Qarith_error, Qerror_conditions, |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2271 arith_tail); |
298 | 2272 Fput (Qarith_error, Qerror_message, |
2273 build_string ("Arithmetic error")); | |
2274 | |
2275 Fput (Qbeginning_of_buffer, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2276 Fcons (Qbeginning_of_buffer, error_tail)); |
298 | 2277 Fput (Qbeginning_of_buffer, Qerror_message, |
2278 build_string ("Beginning of buffer")); | |
2279 | |
2280 Fput (Qend_of_buffer, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2281 Fcons (Qend_of_buffer, error_tail)); |
298 | 2282 Fput (Qend_of_buffer, Qerror_message, |
2283 build_string ("End of buffer")); | |
2284 | |
2285 Fput (Qbuffer_read_only, Qerror_conditions, | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2286 Fcons (Qbuffer_read_only, error_tail)); |
298 | 2287 Fput (Qbuffer_read_only, Qerror_message, |
2288 build_string ("Buffer is read-only")); | |
2289 | |
2092
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2290 #ifdef LISP_FLOAT_TYPE |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2291 Qrange_error = intern ("range-error"); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2292 Qdomain_error = intern ("domain-error"); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2293 Qsingularity_error = intern ("singularity-error"); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2294 Qoverflow_error = intern ("overflow-error"); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2295 Qunderflow_error = intern ("underflow-error"); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2296 |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2297 Fput (Qdomain_error, Qerror_conditions, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2298 Fcons (Qdomain_error, arith_tail)); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2299 Fput (Qdomain_error, Qerror_message, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2300 build_string ("Arithmetic domain error")); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2301 |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2302 Fput (Qrange_error, Qerror_conditions, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2303 Fcons (Qrange_error, arith_tail)); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2304 Fput (Qrange_error, Qerror_message, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2305 build_string ("Arithmetic range error")); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2306 |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2307 Fput (Qsingularity_error, Qerror_conditions, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2308 Fcons (Qsingularity_error, Fcons (Qdomain_error, arith_tail))); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2309 Fput (Qsingularity_error, Qerror_message, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2310 build_string ("Arithmetic singularity error")); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2311 |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2312 Fput (Qoverflow_error, Qerror_conditions, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2313 Fcons (Qoverflow_error, Fcons (Qdomain_error, arith_tail))); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2314 Fput (Qoverflow_error, Qerror_message, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2315 build_string ("Arithmetic overflow error")); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2316 |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2317 Fput (Qunderflow_error, Qerror_conditions, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2318 Fcons (Qunderflow_error, Fcons (Qdomain_error, arith_tail))); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2319 Fput (Qunderflow_error, Qerror_message, |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2320 build_string ("Arithmetic underflow error")); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2321 |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2322 staticpro (&Qrange_error); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2323 staticpro (&Qdomain_error); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2324 staticpro (&Qsingularity_error); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2325 staticpro (&Qoverflow_error); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2326 staticpro (&Qunderflow_error); |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2327 #endif /* LISP_FLOAT_TYPE */ |
7497fce1e426
(syms_of_data) [LISP_FLOAT_TYPE]: Define new error conditions:
Richard M. Stallman <rms@gnu.org>
parents:
1987
diff
changeset
|
2328 |
298 | 2329 staticpro (&Qnil); |
2330 staticpro (&Qt); | |
2331 staticpro (&Qquote); | |
2332 staticpro (&Qlambda); | |
2333 staticpro (&Qsubr); | |
2334 staticpro (&Qunbound); | |
2335 staticpro (&Qerror_conditions); | |
2336 staticpro (&Qerror_message); | |
2337 staticpro (&Qtop_level); | |
2338 | |
2339 staticpro (&Qerror); | |
2340 staticpro (&Qquit); | |
2341 staticpro (&Qwrong_type_argument); | |
2342 staticpro (&Qargs_out_of_range); | |
2343 staticpro (&Qvoid_function); | |
648 | 2344 staticpro (&Qcyclic_function_indirection); |
298 | 2345 staticpro (&Qvoid_variable); |
2346 staticpro (&Qsetting_constant); | |
2347 staticpro (&Qinvalid_read_syntax); | |
2348 staticpro (&Qwrong_number_of_arguments); | |
2349 staticpro (&Qinvalid_function); | |
2350 staticpro (&Qno_catch); | |
2351 staticpro (&Qend_of_file); | |
2352 staticpro (&Qarith_error); | |
2353 staticpro (&Qbeginning_of_buffer); | |
2354 staticpro (&Qend_of_buffer); | |
2355 staticpro (&Qbuffer_read_only); | |
4037
aecb99c65ab0
(syms_of_data): Staticpro Qmark_inactive.
Roland McGrath <roland@gnu.org>
parents:
4036
diff
changeset
|
2356 staticpro (&Qmark_inactive); |
298 | 2357 |
2358 staticpro (&Qlistp); | |
2359 staticpro (&Qconsp); | |
2360 staticpro (&Qsymbolp); | |
2361 staticpro (&Qintegerp); | |
2362 staticpro (&Qnatnump); | |
6459
30fabcc03f0c
(Qwholenump): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6448
diff
changeset
|
2363 staticpro (&Qwholenump); |
298 | 2364 staticpro (&Qstringp); |
2365 staticpro (&Qarrayp); | |
2366 staticpro (&Qsequencep); | |
2367 staticpro (&Qbufferp); | |
2368 staticpro (&Qvectorp); | |
2369 staticpro (&Qchar_or_string_p); | |
2370 staticpro (&Qmarkerp); | |
1293 | 2371 staticpro (&Qbuffer_or_string_p); |
298 | 2372 staticpro (&Qinteger_or_marker_p); |
2373 #ifdef LISP_FLOAT_TYPE | |
2374 staticpro (&Qfloatp); | |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
2375 staticpro (&Qnumberp); |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
2376 staticpro (&Qnumber_or_marker_p); |
298 | 2377 #endif /* LISP_FLOAT_TYPE */ |
2378 | |
2379 staticpro (&Qboundp); | |
2380 staticpro (&Qfboundp); | |
2381 staticpro (&Qcdr); | |
8448
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
2382 staticpro (&Qad_advice_info); |
b6335ce87e16
(Fdefine_function, Fdefalias): Handle advice as in Ffset.
Richard M. Stallman <rms@gnu.org>
parents:
8415
diff
changeset
|
2383 staticpro (&Qad_activate); |
298 | 2384 |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2385 /* Types that type-of returns. */ |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2386 Qinteger = intern ("integer"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2387 Qsymbol = intern ("symbol"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2388 Qstring = intern ("string"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2389 Qcons = intern ("cons"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2390 Qmarker = intern ("marker"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2391 Qoverlay = intern ("overlay"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2392 Qfloat = intern ("float"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2393 Qwindow_configuration = intern ("window-configuration"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2394 Qprocess = intern ("process"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2395 Qwindow = intern ("window"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2396 /* Qsubr = intern ("subr"); */ |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2397 Qcompiled_function = intern ("compiled-function"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2398 Qbuffer = intern ("buffer"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2399 Qframe = intern ("frame"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2400 Qvector = intern ("vector"); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2401 |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2402 staticpro (&Qinteger); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2403 staticpro (&Qsymbol); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2404 staticpro (&Qstring); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2405 staticpro (&Qcons); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2406 staticpro (&Qmarker); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2407 staticpro (&Qoverlay); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2408 staticpro (&Qfloat); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2409 staticpro (&Qwindow_configuration); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2410 staticpro (&Qprocess); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2411 staticpro (&Qwindow); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2412 /* staticpro (&Qsubr); */ |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2413 staticpro (&Qcompiled_function); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2414 staticpro (&Qbuffer); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2415 staticpro (&Qframe); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2416 staticpro (&Qvector); |
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2417 |
298 | 2418 defsubr (&Seq); |
2419 defsubr (&Snull); | |
10725
24958130d147
Rename arg OBJ to OBJECT in all type predicates.
Richard M. Stallman <rms@gnu.org>
parents:
10645
diff
changeset
|
2420 defsubr (&Stype_of); |
298 | 2421 defsubr (&Slistp); |
2422 defsubr (&Snlistp); | |
2423 defsubr (&Sconsp); | |
2424 defsubr (&Satom); | |
2425 defsubr (&Sintegerp); | |
695
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
2426 defsubr (&Sinteger_or_marker_p); |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
2427 defsubr (&Snumberp); |
e3fac20d3015
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
648
diff
changeset
|
2428 defsubr (&Snumber_or_marker_p); |
298 | 2429 #ifdef LISP_FLOAT_TYPE |
2430 defsubr (&Sfloatp); | |
2431 #endif /* LISP_FLOAT_TYPE */ | |
2432 defsubr (&Snatnump); | |
2433 defsubr (&Ssymbolp); | |
2434 defsubr (&Sstringp); | |
2435 defsubr (&Svectorp); | |
2436 defsubr (&Sarrayp); | |
2437 defsubr (&Ssequencep); | |
2438 defsubr (&Sbufferp); | |
2439 defsubr (&Smarkerp); | |
2440 defsubr (&Ssubrp); | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1648
diff
changeset
|
2441 defsubr (&Sbyte_code_function_p); |
298 | 2442 defsubr (&Schar_or_string_p); |
2443 defsubr (&Scar); | |
2444 defsubr (&Scdr); | |
2445 defsubr (&Scar_safe); | |
2446 defsubr (&Scdr_safe); | |
2447 defsubr (&Ssetcar); | |
2448 defsubr (&Ssetcdr); | |
2449 defsubr (&Ssymbol_function); | |
648 | 2450 defsubr (&Sindirect_function); |
298 | 2451 defsubr (&Ssymbol_plist); |
2452 defsubr (&Ssymbol_name); | |
2453 defsubr (&Smakunbound); | |
2454 defsubr (&Sfmakunbound); | |
2455 defsubr (&Sboundp); | |
2456 defsubr (&Sfboundp); | |
2457 defsubr (&Sfset); | |
2565
c1a1557bffde
(Fdefine_function): Changed name back to Fdefalias, so we get things
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2548
diff
changeset
|
2458 defsubr (&Sdefalias); |
2606
6bf6499fe4db
(Fdefine_function): New function (same code as Fdefalias).
Richard M. Stallman <rms@gnu.org>
parents:
2565
diff
changeset
|
2459 defsubr (&Sdefine_function); |
298 | 2460 defsubr (&Ssetplist); |
2461 defsubr (&Ssymbol_value); | |
2462 defsubr (&Sset); | |
2463 defsubr (&Sdefault_boundp); | |
2464 defsubr (&Sdefault_value); | |
2465 defsubr (&Sset_default); | |
2466 defsubr (&Ssetq_default); | |
2467 defsubr (&Smake_variable_buffer_local); | |
2468 defsubr (&Smake_local_variable); | |
2469 defsubr (&Skill_local_variable); | |
9194
3db4151c3d00
(Fmake_local_variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9147
diff
changeset
|
2470 defsubr (&Slocal_variable_p); |
298 | 2471 defsubr (&Saref); |
2472 defsubr (&Saset); | |
2429
96b55f2f19cd
Rename int-to-string to number-to-string, since it can handle
Jim Blandy <jimb@redhat.com>
parents:
2092
diff
changeset
|
2473 defsubr (&Snumber_to_string); |
1914
60965a5c325f
* data.c (Fstring_to_number): Skip initial spaces, to make Emacs
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
2474 defsubr (&Sstring_to_number); |
298 | 2475 defsubr (&Seqlsign); |
2476 defsubr (&Slss); | |
2477 defsubr (&Sgtr); | |
2478 defsubr (&Sleq); | |
2479 defsubr (&Sgeq); | |
2480 defsubr (&Sneq); | |
2481 defsubr (&Szerop); | |
2482 defsubr (&Splus); | |
2483 defsubr (&Sminus); | |
2484 defsubr (&Stimes); | |
2485 defsubr (&Squo); | |
2486 defsubr (&Srem); | |
4508
763987892042
(Fmod): New function; result is always same sign as divisor.
Paul Eggert <eggert@twinsun.com>
parents:
4447
diff
changeset
|
2487 defsubr (&Smod); |
298 | 2488 defsubr (&Smax); |
2489 defsubr (&Smin); | |
2490 defsubr (&Slogand); | |
2491 defsubr (&Slogior); | |
2492 defsubr (&Slogxor); | |
2493 defsubr (&Slsh); | |
2494 defsubr (&Sash); | |
2495 defsubr (&Sadd1); | |
2496 defsubr (&Ssub1); | |
2497 defsubr (&Slognot); | |
6459
30fabcc03f0c
(Qwholenump): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6448
diff
changeset
|
2498 |
9954
18b408b05189
(syms_of_data): Set Qwholenump as function, not variable.
Karl Heuer <kwzh@gnu.org>
parents:
9895
diff
changeset
|
2499 XSYMBOL (Qwholenump)->function = XSYMBOL (Qnatnump)->function; |
298 | 2500 } |
2501 | |
490 | 2502 SIGTYPE |
298 | 2503 arith_error (signo) |
2504 int signo; | |
2505 { | |
2506 #ifdef USG | |
2507 /* USG systems forget handlers when they are used; | |
2508 must reestablish each time */ | |
2509 signal (signo, arith_error); | |
2510 #endif /* USG */ | |
2511 #ifdef VMS | |
2512 /* VMS systems are like USG. */ | |
2513 signal (signo, arith_error); | |
2514 #endif /* VMS */ | |
2515 #ifdef BSD4_1 | |
2516 sigrelse (SIGFPE); | |
2517 #else /* not BSD4_1 */ | |
638 | 2518 sigsetmask (SIGEMPTYMASK); |
298 | 2519 #endif /* not BSD4_1 */ |
2520 | |
2521 Fsignal (Qarith_error, Qnil); | |
2522 } | |
2523 | |
2524 init_data () | |
2525 { | |
2526 /* Don't do this if just dumping out. | |
2527 We don't want to call `signal' in this case | |
2528 so that we don't have trouble with dumping | |
2529 signal-delivering routines in an inconsistent state. */ | |
2530 #ifndef CANNOT_DUMP | |
2531 if (!initialized) | |
2532 return; | |
2533 #endif /* CANNOT_DUMP */ | |
2534 signal (SIGFPE, arith_error); | |
10605
bc37b55fcbb9
(do_symval_forwarding): Handle display-local vars.
Karl Heuer <kwzh@gnu.org>
parents:
10457
diff
changeset
|
2535 |
298 | 2536 #ifdef uts |
2537 signal (SIGEMT, arith_error); | |
2538 #endif /* uts */ | |
2539 } |