diff options
| author | Richard M. Stallman | 1998-03-12 05:50:33 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-12 05:50:33 +0000 |
| commit | b0c2d1c671bba15b84aac569dda425d95217504a (patch) | |
| tree | 2baf2410e61c80ccaf14d6e5c46b1790b1296210 /src/data.c | |
| parent | a9faeabee0005ac2065dbb315c23816561cb54be (diff) | |
| download | emacs-b0c2d1c671bba15b84aac569dda425d95217504a.tar.gz emacs-b0c2d1c671bba15b84aac569dda425d95217504a.zip | |
(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.
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 162 |
1 files changed, 125 insertions, 37 deletions
diff --git a/src/data.c b/src/data.c index 492b87e30b7..bf637585cd0 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 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" |
| @@ -811,7 +812,7 @@ store_symval_forwarding (symbol, valcontents, newval) | |||
| 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 | } |
| @@ -843,23 +844,37 @@ swap_in_symval_forwarding (symbol, valcontents) | |||
| 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) |
| 850 | || selected_frame != XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame)) | ||
| 849 | { | 851 | { |
| 850 | tem1 = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; | 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. |
| @@ -990,15 +1005,16 @@ set_internal (symbol, newval, bindflag) | |||
| 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))) |
| @@ -1007,10 +1023,13 @@ set_internal (symbol, newval, bindflag) | |||
| 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. */ |
| @@ -1020,27 +1039,39 @@ set_internal (symbol, newval, bindflag) | |||
| 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 | { |
| 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); | ||
| 1024 | 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 |
| @@ -1087,12 +1118,12 @@ default_value (symbol) | |||
| 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); |
| @@ -1167,14 +1198,14 @@ for this variable.") | |||
| 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; |
| @@ -1253,8 +1284,13 @@ The function `default-value' gets the default value and `set-default' sets it.") | |||
| 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 | } |
| @@ -1300,8 +1336,13 @@ Use `make-local-hook' instead.") | |||
| 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 */ |
| @@ -1314,7 +1355,7 @@ Use `make-local-hook' instead.") | |||
| 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; |
| @@ -1324,9 +1365,10 @@ Use `make-local-hook' instead.") | |||
| 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 | ||
| @@ -1334,7 +1376,7 @@ Use `make-local-hook' instead.") | |||
| 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 | ||
| @@ -1386,10 +1428,11 @@ From now on the default value will apply in this buffer.") | |||
| 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 | } |
| @@ -1397,6 +1440,50 @@ From now on the default value will apply in this buffer.") | |||
| 1397 | return variable; | 1440 | return variable; |
| 1398 | } | 1441 | } |
| 1399 | 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; | ||
| 1484 | return variable; | ||
| 1485 | } | ||
| 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, |
| 1402 | "Non-nil if VARIABLE has a local binding in buffer BUFFER.\n\ | 1489 | "Non-nil if VARIABLE has a local binding in buffer BUFFER.\n\ |
| @@ -2801,6 +2888,7 @@ syms_of_data () | |||
| 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); |