Mercurial > emacs
comparison src/data.c @ 21144:6988880cc529
(store_symval_forwarding, swap_in_symval_forwarding)
(set_internal, default_value, Fset_default, Fmake_local_variable)
(Fmake_variable_buffer_local, Fkill_local_variable):
Handle new data structure for struct Lisp_Buffer_Local_Value.
(Fmake_variable_frame_local): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 12 Mar 1998 05:50:33 +0000 |
parents | b52e351a40fa |
children | 50929073a0ba |
comparison
equal
deleted
inserted
replaced
21143:ce12eac1ee45 | 21144:6988880cc529 |
---|---|
27 #include "charset.h" | 27 #include "charset.h" |
28 | 28 |
29 #ifndef standalone | 29 #ifndef standalone |
30 #include "buffer.h" | 30 #include "buffer.h" |
31 #include "keyboard.h" | 31 #include "keyboard.h" |
32 #include "frame.h" | |
32 #endif | 33 #endif |
33 | 34 |
34 #include "syssignal.h" | 35 #include "syssignal.h" |
35 | 36 |
36 #ifdef LISP_FLOAT_TYPE | 37 #ifdef LISP_FLOAT_TYPE |
809 default: | 810 default: |
810 def: | 811 def: |
811 valcontents = XSYMBOL (symbol)->value; | 812 valcontents = XSYMBOL (symbol)->value; |
812 if (BUFFER_LOCAL_VALUEP (valcontents) | 813 if (BUFFER_LOCAL_VALUEP (valcontents) |
813 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 814 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
814 XBUFFER_LOCAL_VALUE (valcontents)->car = newval; | 815 XBUFFER_LOCAL_VALUE (valcontents)->realvalue = newval; |
815 else | 816 else |
816 XSYMBOL (symbol)->value = newval; | 817 XSYMBOL (symbol)->value = newval; |
817 } | 818 } |
818 } | 819 } |
819 | 820 |
841 element, and store into BUFFER. | 842 element, and store into BUFFER. |
842 | 843 |
843 Note that REALVALUE can be a forwarding pointer. */ | 844 Note that REALVALUE can be a forwarding pointer. */ |
844 | 845 |
845 register Lisp_Object tem1; | 846 register Lisp_Object tem1; |
846 tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; | 847 tem1 = XBUFFER_LOCAL_VALUE (valcontents)->buffer; |
847 | 848 |
848 if (NILP (tem1) || current_buffer != XBUFFER (tem1)) | 849 if (NILP (tem1) || current_buffer != XBUFFER (tem1) |
849 { | 850 || selected_frame != XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame)) |
850 tem1 = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; | 851 { |
852 tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; | |
851 Fsetcdr (tem1, | 853 Fsetcdr (tem1, |
852 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car)); | 854 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); |
853 tem1 = assq_no_quit (symbol, current_buffer->local_var_alist); | 855 tem1 = assq_no_quit (symbol, current_buffer->local_var_alist); |
856 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; | |
857 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; | |
854 if (NILP (tem1)) | 858 if (NILP (tem1)) |
855 tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr; | 859 { |
856 XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car = tem1; | 860 if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame) |
857 XSETBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car, | 861 tem1 = assq_no_quit (symbol, selected_frame->param_alist); |
858 current_buffer); | 862 if (! NILP (tem1)) |
859 store_symval_forwarding (symbol, XBUFFER_LOCAL_VALUE (valcontents)->car, | 863 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 1; |
864 else | |
865 tem1 = XBUFFER_LOCAL_VALUE (valcontents)->cdr; | |
866 } | |
867 else | |
868 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; | |
869 | |
870 XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car = tem1; | |
871 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, current_buffer); | |
872 XSETFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame, selected_frame); | |
873 store_symval_forwarding (symbol, | |
874 XBUFFER_LOCAL_VALUE (valcontents)->realvalue, | |
860 Fcdr (tem1)); | 875 Fcdr (tem1)); |
861 } | 876 } |
862 return XBUFFER_LOCAL_VALUE (valcontents)->car; | 877 return XBUFFER_LOCAL_VALUE (valcontents)->realvalue; |
863 } | 878 } |
864 | 879 |
865 /* Find the value of a symbol, returning Qunbound if it's not bound. | 880 /* Find the value of a symbol, returning Qunbound if it's not bound. |
866 This is helpful for code which just wants to get a variable's value | 881 This is helpful for code which just wants to get a variable's value |
867 if it has one, without signaling an error. | 882 if it has one, without signaling an error. |
988 | 1003 |
989 Note that REALVALUE can be a forwarding pointer. Each time | 1004 Note that REALVALUE can be a forwarding pointer. Each time |
990 it is examined or set, forwarding must be done. */ | 1005 it is examined or set, forwarding must be done. */ |
991 | 1006 |
992 /* What value are we caching right now? */ | 1007 /* What value are we caching right now? */ |
993 current_alist_element = | 1008 current_alist_element |
994 XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; | 1009 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; |
995 | 1010 |
996 /* If the current buffer is not the buffer whose binding is | 1011 /* If the current buffer is not the buffer whose binding is |
997 currently cached, or if it's a Lisp_Buffer_Local_Value and | 1012 currently cached, or if it's a Lisp_Buffer_Local_Value and |
998 we're looking at the default value, the cache is invalid; we | 1013 we're looking at the default value, the cache is invalid; we |
999 need to write it out, and find the new CURRENT-ALIST-ELEMENT. */ | 1014 need to write it out, and find the new CURRENT-ALIST-ELEMENT. */ |
1000 if ((current_buffer | 1015 if (current_buffer != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer) |
1001 != XBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car)) | 1016 || |
1017 selected_frame != XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) | |
1002 || (BUFFER_LOCAL_VALUEP (valcontents) | 1018 || (BUFFER_LOCAL_VALUEP (valcontents) |
1003 && EQ (XCONS (current_alist_element)->car, | 1019 && EQ (XCONS (current_alist_element)->car, |
1004 current_alist_element))) | 1020 current_alist_element))) |
1005 { | 1021 { |
1006 /* Write out the cached value for the old buffer; copy it | 1022 /* Write out the cached value for the old buffer; copy it |
1007 back to its alist element. This works if the current | 1023 back to its alist element. This works if the current |
1008 buffer only sees the default value, too. */ | 1024 buffer only sees the default value, too. */ |
1009 Fsetcdr (current_alist_element, | 1025 Fsetcdr (current_alist_element, |
1010 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car)); | 1026 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); |
1011 | 1027 |
1012 /* Find the new value for CURRENT-ALIST-ELEMENT. */ | 1028 /* Find the new value for CURRENT-ALIST-ELEMENT. */ |
1013 tem1 = Fassq (symbol, current_buffer->local_var_alist); | 1029 tem1 = Fassq (symbol, current_buffer->local_var_alist); |
1030 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; | |
1031 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; | |
1032 | |
1014 if (NILP (tem1)) | 1033 if (NILP (tem1)) |
1015 { | 1034 { |
1016 /* This buffer still sees the default value. */ | 1035 /* This buffer still sees the default value. */ |
1017 | 1036 |
1018 /* If the variable is a Lisp_Some_Buffer_Local_Value, | 1037 /* If the variable is a Lisp_Some_Buffer_Local_Value, |
1019 or if this is `let' rather than `set', | 1038 or if this is `let' rather than `set', |
1020 make CURRENT-ALIST-ELEMENT point to itself, | 1039 make CURRENT-ALIST-ELEMENT point to itself, |
1021 indicating that we're seeing the default value. */ | 1040 indicating that we're seeing the default value. */ |
1022 if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1041 if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
1023 tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr; | 1042 { |
1024 | 1043 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; |
1044 | |
1045 if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame) | |
1046 tem1 = Fassq (symbol, selected_frame->param_alist); | |
1047 | |
1048 if (! NILP (tem1)) | |
1049 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 1; | |
1050 else | |
1051 tem1 = XBUFFER_LOCAL_VALUE (valcontents)->cdr; | |
1052 } | |
1025 /* If it's a Lisp_Buffer_Local_Value, being set not bound, | 1053 /* If it's a Lisp_Buffer_Local_Value, being set not bound, |
1026 give this buffer a new assoc for a local value and set | 1054 give this buffer a new assoc for a local value and set |
1027 CURRENT-ALIST-ELEMENT to point to that. */ | 1055 CURRENT-ALIST-ELEMENT to point to that. */ |
1028 else | 1056 else |
1029 { | 1057 { |
1030 tem1 = Fcons (symbol, Fcdr (current_alist_element)); | 1058 tem1 = Fcons (symbol, Fcdr (current_alist_element)); |
1031 current_buffer->local_var_alist = | 1059 current_buffer->local_var_alist |
1032 Fcons (tem1, current_buffer->local_var_alist); | 1060 = Fcons (tem1, current_buffer->local_var_alist); |
1033 } | 1061 } |
1034 } | 1062 } |
1063 | |
1035 /* Cache the new buffer's assoc in CURRENT-ALIST-ELEMENT. */ | 1064 /* Cache the new buffer's assoc in CURRENT-ALIST-ELEMENT. */ |
1036 XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car | 1065 XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car |
1037 = tem1; | 1066 = tem1; |
1038 | 1067 |
1039 /* Set BUFFER, now that CURRENT-ALIST-ELEMENT is accurate. */ | 1068 /* Set BUFFER and FRAME for binding now loaded. */ |
1040 XSETBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car, | 1069 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, |
1041 current_buffer); | 1070 current_buffer); |
1071 XSETFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame, | |
1072 selected_frame); | |
1042 } | 1073 } |
1043 valcontents = XBUFFER_LOCAL_VALUE (valcontents)->car; | 1074 valcontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; |
1044 } | 1075 } |
1045 | 1076 |
1046 /* If storing void (making the symbol void), forward only through | 1077 /* If storing void (making the symbol void), forward only through |
1047 buffer-local indicator, not through Lisp_Objfwd, etc. */ | 1078 buffer-local indicator, not through Lisp_Objfwd, etc. */ |
1048 if (voide) | 1079 if (voide) |
1085 the current value is nominally the default value. | 1116 the current value is nominally the default value. |
1086 But the current value slot may be more up to date, since | 1117 But the current value slot may be more up to date, since |
1087 ordinary setq stores just that slot. So use that. */ | 1118 ordinary setq stores just that slot. So use that. */ |
1088 Lisp_Object current_alist_element, alist_element_car; | 1119 Lisp_Object current_alist_element, alist_element_car; |
1089 current_alist_element | 1120 current_alist_element |
1090 = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; | 1121 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; |
1091 alist_element_car = XCONS (current_alist_element)->car; | 1122 alist_element_car = XCONS (current_alist_element)->car; |
1092 if (EQ (alist_element_car, current_alist_element)) | 1123 if (EQ (alist_element_car, current_alist_element)) |
1093 return do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car); | 1124 return do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue); |
1094 else | 1125 else |
1095 return XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->cdr; | 1126 return XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr; |
1096 } | 1127 } |
1097 /* For other variables, get the current value. */ | 1128 /* For other variables, get the current value. */ |
1098 return do_symval_forwarding (valcontents); | 1129 return do_symval_forwarding (valcontents); |
1099 } | 1130 } |
1100 | 1131 |
1165 if (!BUFFER_LOCAL_VALUEP (valcontents) | 1196 if (!BUFFER_LOCAL_VALUEP (valcontents) |
1166 && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1197 && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
1167 return Fset (symbol, value); | 1198 return Fset (symbol, value); |
1168 | 1199 |
1169 /* Store new value into the DEFAULT-VALUE slot */ | 1200 /* Store new value into the DEFAULT-VALUE slot */ |
1170 XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->cdr = value; | 1201 XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr = value; |
1171 | 1202 |
1172 /* If that slot is current, we must set the REALVALUE slot too */ | 1203 /* If that slot is current, we must set the REALVALUE slot too */ |
1173 current_alist_element | 1204 current_alist_element |
1174 = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; | 1205 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; |
1175 alist_element_buffer = Fcar (current_alist_element); | 1206 alist_element_buffer = Fcar (current_alist_element); |
1176 if (EQ (alist_element_buffer, current_alist_element)) | 1207 if (EQ (alist_element_buffer, current_alist_element)) |
1177 store_symval_forwarding (symbol, XBUFFER_LOCAL_VALUE (valcontents)->car, | 1208 store_symval_forwarding (symbol, XBUFFER_LOCAL_VALUE (valcontents)->realvalue, |
1178 value); | 1209 value); |
1179 | 1210 |
1180 return value; | 1211 return value; |
1181 } | 1212 } |
1182 | 1213 |
1251 XSYMBOL (variable)->value = Qnil; | 1282 XSYMBOL (variable)->value = Qnil; |
1252 tem = Fcons (Qnil, Fsymbol_value (variable)); | 1283 tem = Fcons (Qnil, Fsymbol_value (variable)); |
1253 XCONS (tem)->car = tem; | 1284 XCONS (tem)->car = tem; |
1254 newval = allocate_misc (); | 1285 newval = allocate_misc (); |
1255 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; | 1286 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; |
1256 XBUFFER_LOCAL_VALUE (newval)->car = XSYMBOL (variable)->value; | 1287 XBUFFER_LOCAL_VALUE (newval)->realvalue = XSYMBOL (variable)->value; |
1257 XBUFFER_LOCAL_VALUE (newval)->cdr = Fcons (Fcurrent_buffer (), tem); | 1288 XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer (); |
1289 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; | |
1290 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 1; | |
1291 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; | |
1292 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; | |
1293 XBUFFER_LOCAL_VALUE (newval)->cdr = tem; | |
1258 XSYMBOL (variable)->value = newval; | 1294 XSYMBOL (variable)->value = newval; |
1259 return variable; | 1295 return variable; |
1260 } | 1296 } |
1261 | 1297 |
1262 DEFUN ("make-local-variable", Fmake_local_variable, Smake_local_variable, | 1298 DEFUN ("make-local-variable", Fmake_local_variable, Smake_local_variable, |
1298 Lisp_Object newval; | 1334 Lisp_Object newval; |
1299 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); | 1335 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); |
1300 XCONS (tem)->car = tem; | 1336 XCONS (tem)->car = tem; |
1301 newval = allocate_misc (); | 1337 newval = allocate_misc (); |
1302 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; | 1338 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; |
1303 XBUFFER_LOCAL_VALUE (newval)->car = XSYMBOL (variable)->value; | 1339 XBUFFER_LOCAL_VALUE (newval)->realvalue = XSYMBOL (variable)->value; |
1304 XBUFFER_LOCAL_VALUE (newval)->cdr = Fcons (Qnil, tem); | 1340 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; |
1341 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; | |
1342 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; | |
1343 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; | |
1344 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; | |
1345 XBUFFER_LOCAL_VALUE (newval)->cdr = tem; | |
1305 XSYMBOL (variable)->value = newval; | 1346 XSYMBOL (variable)->value = newval; |
1306 } | 1347 } |
1307 /* Make sure this buffer has its own value of symbol */ | 1348 /* Make sure this buffer has its own value of symbol */ |
1308 tem = Fassq (variable, current_buffer->local_var_alist); | 1349 tem = Fassq (variable, current_buffer->local_var_alist); |
1309 if (NILP (tem)) | 1350 if (NILP (tem)) |
1312 sure the current value is permanently recorded, if it's the | 1353 sure the current value is permanently recorded, if it's the |
1313 default value. */ | 1354 default value. */ |
1314 find_symbol_value (variable); | 1355 find_symbol_value (variable); |
1315 | 1356 |
1316 current_buffer->local_var_alist | 1357 current_buffer->local_var_alist |
1317 = Fcons (Fcons (variable, XCONS (XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (variable)->value)->cdr)->cdr)->cdr), | 1358 = Fcons (Fcons (variable, XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (variable)->value)->cdr)->cdr), |
1318 current_buffer->local_var_alist); | 1359 current_buffer->local_var_alist); |
1319 | 1360 |
1320 /* Make sure symbol does not think it is set up for this buffer; | 1361 /* Make sure symbol does not think it is set up for this buffer; |
1321 force it to look once again for this buffer's value */ | 1362 force it to look once again for this buffer's value */ |
1322 { | 1363 { |
1323 Lisp_Object *pvalbuf; | 1364 Lisp_Object *pvalbuf; |
1324 | 1365 |
1325 valcontents = XSYMBOL (variable)->value; | 1366 valcontents = XSYMBOL (variable)->value; |
1326 | 1367 |
1327 pvalbuf = &XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; | 1368 pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer; |
1328 if (current_buffer == XBUFFER (*pvalbuf)) | 1369 if (current_buffer == XBUFFER (*pvalbuf)) |
1329 *pvalbuf = Qnil; | 1370 *pvalbuf = Qnil; |
1371 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; | |
1330 } | 1372 } |
1331 } | 1373 } |
1332 | 1374 |
1333 /* If the symbol forwards into a C variable, then swap in the | 1375 /* If the symbol forwards into a C variable, then swap in the |
1334 variable for this buffer immediately. If C code modifies the | 1376 variable for this buffer immediately. If C code modifies the |
1335 variable before we swap in, then that new value will clobber the | 1377 variable before we swap in, then that new value will clobber the |
1336 default value the next time we swap. */ | 1378 default value the next time we swap. */ |
1337 valcontents = XBUFFER_LOCAL_VALUE (XSYMBOL (variable)->value)->car; | 1379 valcontents = XBUFFER_LOCAL_VALUE (XSYMBOL (variable)->value)->realvalue; |
1338 if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents)) | 1380 if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents)) |
1339 swap_in_symval_forwarding (variable, XSYMBOL (variable)->value); | 1381 swap_in_symval_forwarding (variable, XSYMBOL (variable)->value); |
1340 | 1382 |
1341 return variable; | 1383 return variable; |
1342 } | 1384 } |
1384 value. We have to do it now, or else forwarded objects won't | 1426 value. We have to do it now, or else forwarded objects won't |
1385 work right. */ | 1427 work right. */ |
1386 { | 1428 { |
1387 Lisp_Object *pvalbuf; | 1429 Lisp_Object *pvalbuf; |
1388 valcontents = XSYMBOL (variable)->value; | 1430 valcontents = XSYMBOL (variable)->value; |
1389 pvalbuf = &XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; | 1431 pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer; |
1390 if (current_buffer == XBUFFER (*pvalbuf)) | 1432 if (current_buffer == XBUFFER (*pvalbuf)) |
1391 { | 1433 { |
1392 *pvalbuf = Qnil; | 1434 *pvalbuf = Qnil; |
1435 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; | |
1393 find_symbol_value (variable); | 1436 find_symbol_value (variable); |
1394 } | 1437 } |
1395 } | 1438 } |
1396 | 1439 |
1440 return variable; | |
1441 } | |
1442 | |
1443 /* Lisp functions for creating and removing buffer-local variables. */ | |
1444 | |
1445 DEFUN ("make-variable-frame-local", Fmake_variable_frame_local, Smake_variable_frame_local, | |
1446 1, 1, "vMake Variable Frame Local: ", | |
1447 "Make VARIABLE have a separate value for each buffer.\n\ | |
1448 At any time, the value for the current buffer is in effect.\n\ | |
1449 There is also a default value which is seen in any buffer which has not yet\n\ | |
1450 set its own value.\n\ | |
1451 Using `set' or `setq' to set the variable causes it to have a separate value\n\ | |
1452 for the current buffer if it was previously using the default value.\n\ | |
1453 The function `default-value' gets the default value and `set-default' sets it.") | |
1454 (variable) | |
1455 register Lisp_Object variable; | |
1456 { | |
1457 register Lisp_Object tem, valcontents, newval; | |
1458 | |
1459 CHECK_SYMBOL (variable, 0); | |
1460 | |
1461 valcontents = XSYMBOL (variable)->value; | |
1462 if (EQ (variable, Qnil) || EQ (variable, Qt) || KBOARD_OBJFWDP (valcontents) | |
1463 || BUFFER_OBJFWDP (valcontents)) | |
1464 error ("Symbol %s may not be frame-local", XSYMBOL (variable)->name->data); | |
1465 | |
1466 if (BUFFER_LOCAL_VALUEP (valcontents) | |
1467 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | |
1468 return variable; | |
1469 | |
1470 if (EQ (valcontents, Qunbound)) | |
1471 XSYMBOL (variable)->value = Qnil; | |
1472 tem = Fcons (Qnil, Fsymbol_value (variable)); | |
1473 XCONS (tem)->car = tem; | |
1474 newval = allocate_misc (); | |
1475 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; | |
1476 XBUFFER_LOCAL_VALUE (newval)->realvalue = XSYMBOL (variable)->value; | |
1477 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; | |
1478 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; | |
1479 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; | |
1480 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; | |
1481 XBUFFER_LOCAL_VALUE (newval)->check_frame = 1; | |
1482 XBUFFER_LOCAL_VALUE (newval)->cdr = tem; | |
1483 XSYMBOL (variable)->value = newval; | |
1397 return variable; | 1484 return variable; |
1398 } | 1485 } |
1399 | 1486 |
1400 DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, | 1487 DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, |
1401 1, 2, 0, | 1488 1, 2, 0, |
2799 defsubr (&Sset_default); | 2886 defsubr (&Sset_default); |
2800 defsubr (&Ssetq_default); | 2887 defsubr (&Ssetq_default); |
2801 defsubr (&Smake_variable_buffer_local); | 2888 defsubr (&Smake_variable_buffer_local); |
2802 defsubr (&Smake_local_variable); | 2889 defsubr (&Smake_local_variable); |
2803 defsubr (&Skill_local_variable); | 2890 defsubr (&Skill_local_variable); |
2891 defsubr (&Smake_variable_frame_local); | |
2804 defsubr (&Slocal_variable_p); | 2892 defsubr (&Slocal_variable_p); |
2805 defsubr (&Slocal_variable_if_set_p); | 2893 defsubr (&Slocal_variable_if_set_p); |
2806 defsubr (&Saref); | 2894 defsubr (&Saref); |
2807 defsubr (&Saset); | 2895 defsubr (&Saset); |
2808 defsubr (&Snumber_to_string); | 2896 defsubr (&Snumber_to_string); |