diff options
| author | Karl Heuer | 1994-11-11 07:35:27 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-11-11 07:35:27 +0000 |
| commit | 8d4afcac1ef371a0d8ee2e075a10430f2fce402b (patch) | |
| tree | 3e309f6d40f9dd499ba426e724de43f259b19326 | |
| parent | 677ad7fec7e121f4f1eecfa4fb92246b543fcb4c (diff) | |
| download | emacs-8d4afcac1ef371a0d8ee2e075a10430f2fce402b.tar.gz emacs-8d4afcac1ef371a0d8ee2e075a10430f2fce402b.zip | |
(store_symval_forwarding, swap_in_symval_forwarding, Fset, default_value,
Fset_default, Fkill_local_variable): Use XBUFFER_LOCAL_VALUE, not XCONS.
(Fmake_variable_buffer_local, Fmake_local_variable): Use the new substructure.
| -rw-r--r-- | src/data.c | 100 |
1 files changed, 58 insertions, 42 deletions
diff --git a/src/data.c b/src/data.c index 56c9ad2f7ad..f444dad403a 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -695,7 +695,7 @@ store_symval_forwarding (sym, valcontents, newval) | |||
| 695 | valcontents = XSYMBOL (sym)->value; | 695 | valcontents = XSYMBOL (sym)->value; |
| 696 | if (BUFFER_LOCAL_VALUEP (valcontents) | 696 | if (BUFFER_LOCAL_VALUEP (valcontents) |
| 697 | || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 697 | || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 698 | XCONS (XSYMBOL (sym)->value)->car = newval; | 698 | XBUFFER_LOCAL_VALUE (valcontents)->car = newval; |
| 699 | else | 699 | else |
| 700 | XSYMBOL (sym)->value = newval; | 700 | XSYMBOL (sym)->value = newval; |
| 701 | } | 701 | } |
| @@ -727,20 +727,23 @@ swap_in_symval_forwarding (sym, valcontents) | |||
| 727 | Note that REALVALUE can be a forwarding pointer. */ | 727 | Note that REALVALUE can be a forwarding pointer. */ |
| 728 | 728 | ||
| 729 | register Lisp_Object tem1; | 729 | register Lisp_Object tem1; |
| 730 | tem1 = XCONS (XCONS (valcontents)->cdr)->car; | 730 | tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; |
| 731 | 731 | ||
| 732 | if (NILP (tem1) || current_buffer != XBUFFER (tem1)) | 732 | if (NILP (tem1) || current_buffer != XBUFFER (tem1)) |
| 733 | { | 733 | { |
| 734 | tem1 = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car; | 734 | tem1 = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; |
| 735 | Fsetcdr (tem1, do_symval_forwarding (XCONS (valcontents)->car)); | 735 | Fsetcdr (tem1, |
| 736 | do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car)); | ||
| 736 | tem1 = assq_no_quit (sym, current_buffer->local_var_alist); | 737 | tem1 = assq_no_quit (sym, current_buffer->local_var_alist); |
| 737 | if (NILP (tem1)) | 738 | if (NILP (tem1)) |
| 738 | tem1 = XCONS (XCONS (valcontents)->cdr)->cdr; | 739 | tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr; |
| 739 | XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car = tem1; | 740 | XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car = tem1; |
| 740 | XSETBUFFER (XCONS (XCONS (valcontents)->cdr)->car, current_buffer); | 741 | XSETBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car, |
| 741 | store_symval_forwarding (sym, XCONS (valcontents)->car, Fcdr (tem1)); | 742 | current_buffer); |
| 743 | store_symval_forwarding (sym, XBUFFER_LOCAL_VALUE (valcontents)->car, | ||
| 744 | Fcdr (tem1)); | ||
| 742 | } | 745 | } |
| 743 | return XCONS (valcontents)->car; | 746 | return XBUFFER_LOCAL_VALUE (valcontents)->car; |
| 744 | } | 747 | } |
| 745 | 748 | ||
| 746 | /* Find the value of a symbol, returning Qunbound if it's not bound. | 749 | /* Find the value of a symbol, returning Qunbound if it's not bound. |
| @@ -825,7 +828,8 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, | |||
| 825 | else if (BUFFER_LOCAL_VALUEP (valcontents) | 828 | else if (BUFFER_LOCAL_VALUEP (valcontents) |
| 826 | || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 829 | || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 827 | { | 830 | { |
| 828 | /* valcontents is actually a pointer to a cons heading something like: | 831 | /* valcontents is actually a pointer to a struct resembling a cons, |
| 832 | with contents something like: | ||
| 829 | (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE). | 833 | (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE). |
| 830 | 834 | ||
| 831 | BUFFER is the last buffer for which this symbol's value was | 835 | BUFFER is the last buffer for which this symbol's value was |
| @@ -854,14 +858,14 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, | |||
| 854 | 858 | ||
| 855 | /* What value are we caching right now? */ | 859 | /* What value are we caching right now? */ |
| 856 | current_alist_element = | 860 | current_alist_element = |
| 857 | XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car; | 861 | XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; |
| 858 | 862 | ||
| 859 | /* If the current buffer is not the buffer whose binding is | 863 | /* If the current buffer is not the buffer whose binding is |
| 860 | currently cached, or if it's a Lisp_Buffer_Local_Value and | 864 | currently cached, or if it's a Lisp_Buffer_Local_Value and |
| 861 | we're looking at the default value, the cache is invalid; we | 865 | we're looking at the default value, the cache is invalid; we |
| 862 | need to write it out, and find the new CURRENT-ALIST-ELEMENT. */ | 866 | need to write it out, and find the new CURRENT-ALIST-ELEMENT. */ |
| 863 | if ((current_buffer | 867 | if ((current_buffer |
| 864 | != XBUFFER (XCONS (XCONS (valcontents)->cdr)->car)) | 868 | != XBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car)) |
| 865 | || (BUFFER_LOCAL_VALUEP (valcontents) | 869 | || (BUFFER_LOCAL_VALUEP (valcontents) |
| 866 | && EQ (XCONS (current_alist_element)->car, | 870 | && EQ (XCONS (current_alist_element)->car, |
| 867 | current_alist_element))) | 871 | current_alist_element))) |
| @@ -870,7 +874,7 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, | |||
| 870 | back to its alist element. This works if the current | 874 | back to its alist element. This works if the current |
| 871 | buffer only sees the default value, too. */ | 875 | buffer only sees the default value, too. */ |
| 872 | Fsetcdr (current_alist_element, | 876 | Fsetcdr (current_alist_element, |
| 873 | do_symval_forwarding (XCONS (valcontents)->car)); | 877 | do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car)); |
| 874 | 878 | ||
| 875 | /* Find the new value for CURRENT-ALIST-ELEMENT. */ | 879 | /* Find the new value for CURRENT-ALIST-ELEMENT. */ |
| 876 | tem1 = Fassq (sym, current_buffer->local_var_alist); | 880 | tem1 = Fassq (sym, current_buffer->local_var_alist); |
| @@ -882,7 +886,7 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, | |||
| 882 | make CURRENT-ALIST-ELEMENT point to itself, | 886 | make CURRENT-ALIST-ELEMENT point to itself, |
| 883 | indicating that we're seeing the default value. */ | 887 | indicating that we're seeing the default value. */ |
| 884 | if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 888 | if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 885 | tem1 = XCONS (XCONS (valcontents)->cdr)->cdr; | 889 | tem1 = XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr; |
| 886 | 890 | ||
| 887 | /* If it's a Lisp_Buffer_Local_Value, give this buffer a | 891 | /* If it's a Lisp_Buffer_Local_Value, give this buffer a |
| 888 | new assoc for a local value and set | 892 | new assoc for a local value and set |
| @@ -895,12 +899,14 @@ DEFUN ("set", Fset, Sset, 2, 2, 0, | |||
| 895 | } | 899 | } |
| 896 | } | 900 | } |
| 897 | /* Cache the new buffer's assoc in CURRENT-ALIST-ELEMENT. */ | 901 | /* Cache the new buffer's assoc in CURRENT-ALIST-ELEMENT. */ |
| 898 | XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car = tem1; | 902 | XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car |
| 903 | = tem1; | ||
| 899 | 904 | ||
| 900 | /* Set BUFFER, now that CURRENT-ALIST-ELEMENT is accurate. */ | 905 | /* Set BUFFER, now that CURRENT-ALIST-ELEMENT is accurate. */ |
| 901 | XSETBUFFER (XCONS (XCONS (valcontents)->cdr)->car, current_buffer); | 906 | XSETBUFFER (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car, |
| 907 | current_buffer); | ||
| 902 | } | 908 | } |
| 903 | valcontents = XCONS (valcontents)->car; | 909 | valcontents = XBUFFER_LOCAL_VALUE (valcontents)->car; |
| 904 | } | 910 | } |
| 905 | 911 | ||
| 906 | /* If storing void (making the symbol void), forward only through | 912 | /* If storing void (making the symbol void), forward only through |
| @@ -947,12 +953,12 @@ default_value (sym) | |||
| 947 | ordinary setq stores just that slot. So use that. */ | 953 | ordinary setq stores just that slot. So use that. */ |
| 948 | Lisp_Object current_alist_element, alist_element_car; | 954 | Lisp_Object current_alist_element, alist_element_car; |
| 949 | current_alist_element | 955 | current_alist_element |
| 950 | = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car; | 956 | = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; |
| 951 | alist_element_car = XCONS (current_alist_element)->car; | 957 | alist_element_car = XCONS (current_alist_element)->car; |
| 952 | if (EQ (alist_element_car, current_alist_element)) | 958 | if (EQ (alist_element_car, current_alist_element)) |
| 953 | return do_symval_forwarding (XCONS (valcontents)->car); | 959 | return do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->car); |
| 954 | else | 960 | else |
| 955 | return XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->cdr; | 961 | return XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->cdr; |
| 956 | } | 962 | } |
| 957 | /* For other variables, get the current value. */ | 963 | /* For other variables, get the current value. */ |
| 958 | return do_symval_forwarding (valcontents); | 964 | return do_symval_forwarding (valcontents); |
| @@ -1024,13 +1030,15 @@ for this variable.") | |||
| 1024 | return Fset (sym, value); | 1030 | return Fset (sym, value); |
| 1025 | 1031 | ||
| 1026 | /* Store new value into the DEFAULT-VALUE slot */ | 1032 | /* Store new value into the DEFAULT-VALUE slot */ |
| 1027 | XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->cdr = value; | 1033 | XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->cdr = value; |
| 1028 | 1034 | ||
| 1029 | /* If that slot is current, we must set the REALVALUE slot too */ | 1035 | /* If that slot is current, we must set the REALVALUE slot too */ |
| 1030 | current_alist_element = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car; | 1036 | current_alist_element |
| 1037 | = XCONS (XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->cdr)->car; | ||
| 1031 | alist_element_buffer = Fcar (current_alist_element); | 1038 | alist_element_buffer = Fcar (current_alist_element); |
| 1032 | if (EQ (alist_element_buffer, current_alist_element)) | 1039 | if (EQ (alist_element_buffer, current_alist_element)) |
| 1033 | store_symval_forwarding (sym, XCONS (valcontents)->car, value); | 1040 | store_symval_forwarding (sym, XBUFFER_LOCAL_VALUE (valcontents)->car, |
| 1041 | value); | ||
| 1034 | 1042 | ||
| 1035 | return value; | 1043 | return value; |
| 1036 | } | 1044 | } |
| @@ -1087,7 +1095,7 @@ The function `default-value' gets the default value and `set-default' sets it.") | |||
| 1087 | (sym) | 1095 | (sym) |
| 1088 | register Lisp_Object sym; | 1096 | register Lisp_Object sym; |
| 1089 | { | 1097 | { |
| 1090 | register Lisp_Object tem, valcontents; | 1098 | register Lisp_Object tem, valcontents, newval; |
| 1091 | 1099 | ||
| 1092 | CHECK_SYMBOL (sym, 0); | 1100 | CHECK_SYMBOL (sym, 0); |
| 1093 | 1101 | ||
| @@ -1099,15 +1107,18 @@ The function `default-value' gets the default value and `set-default' sets it.") | |||
| 1099 | return sym; | 1107 | return sym; |
| 1100 | if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1108 | if (SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 1101 | { | 1109 | { |
| 1102 | XSETTYPE (XSYMBOL (sym)->value, Lisp_Buffer_Local_Value); | 1110 | XMISC (XSYMBOL (sym)->value)->type = Lisp_Misc_Buffer_Local_Value; |
| 1103 | return sym; | 1111 | return sym; |
| 1104 | } | 1112 | } |
| 1105 | if (EQ (valcontents, Qunbound)) | 1113 | if (EQ (valcontents, Qunbound)) |
| 1106 | XSYMBOL (sym)->value = Qnil; | 1114 | XSYMBOL (sym)->value = Qnil; |
| 1107 | tem = Fcons (Qnil, Fsymbol_value (sym)); | 1115 | tem = Fcons (Qnil, Fsymbol_value (sym)); |
| 1108 | XCONS (tem)->car = tem; | 1116 | XCONS (tem)->car = tem; |
| 1109 | XSYMBOL (sym)->value = Fcons (XSYMBOL (sym)->value, Fcons (Fcurrent_buffer (), tem)); | 1117 | newval = allocate_misc (); |
| 1110 | XSETTYPE (XSYMBOL (sym)->value, Lisp_Buffer_Local_Value); | 1118 | XMISC (newval)->type = Lisp_Misc_Buffer_Local_Value; |
| 1119 | XBUFFER_LOCAL_VALUE (newval)->car = XSYMBOL (sym)->value; | ||
| 1120 | XBUFFER_LOCAL_VALUE (newval)->cdr = Fcons (Fcurrent_buffer (), tem); | ||
| 1121 | XSYMBOL (sym)->value = newval; | ||
| 1111 | return sym; | 1122 | return sym; |
| 1112 | } | 1123 | } |
| 1113 | 1124 | ||
| @@ -1147,28 +1158,31 @@ Use `make-local-hook' instead.") | |||
| 1147 | /* Make sure sym is set up to hold per-buffer values */ | 1158 | /* Make sure sym is set up to hold per-buffer values */ |
| 1148 | if (!SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1159 | if (!SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 1149 | { | 1160 | { |
| 1161 | Lisp_Object newval; | ||
| 1150 | tem = Fcons (Qnil, do_symval_forwarding (valcontents)); | 1162 | tem = Fcons (Qnil, do_symval_forwarding (valcontents)); |
| 1151 | XCONS (tem)->car = tem; | 1163 | XCONS (tem)->car = tem; |
| 1152 | XSYMBOL (sym)->value = Fcons (XSYMBOL (sym)->value, Fcons (Qnil, tem)); | 1164 | newval = allocate_misc (); |
| 1153 | XSETTYPE (XSYMBOL (sym)->value, Lisp_Some_Buffer_Local_Value); | 1165 | XMISC (newval)->type = Lisp_Misc_Some_Buffer_Local_Value; |
| 1166 | XBUFFER_LOCAL_VALUE (newval)->car = XSYMBOL (sym)->value; | ||
| 1167 | XBUFFER_LOCAL_VALUE (newval)->cdr = Fcons (Qnil, tem); | ||
| 1168 | XSYMBOL (sym)->value = newval; | ||
| 1154 | } | 1169 | } |
| 1155 | /* Make sure this buffer has its own value of sym */ | 1170 | /* Make sure this buffer has its own value of sym */ |
| 1156 | tem = Fassq (sym, current_buffer->local_var_alist); | 1171 | tem = Fassq (sym, current_buffer->local_var_alist); |
| 1157 | if (NILP (tem)) | 1172 | if (NILP (tem)) |
| 1158 | { | 1173 | { |
| 1159 | current_buffer->local_var_alist | 1174 | current_buffer->local_var_alist |
| 1160 | = Fcons (Fcons (sym, XCONS (XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->cdr)->cdr), | 1175 | = Fcons (Fcons (sym, XCONS (XCONS (XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->cdr)->cdr)->cdr), |
| 1161 | current_buffer->local_var_alist); | 1176 | current_buffer->local_var_alist); |
| 1162 | 1177 | ||
| 1163 | /* Make sure symbol does not think it is set up for this buffer; | 1178 | /* Make sure symbol does not think it is set up for this buffer; |
| 1164 | force it to look once again for this buffer's value */ | 1179 | force it to look once again for this buffer's value */ |
| 1165 | { | 1180 | { |
| 1166 | /* This local variable avoids "expression too complex" on IBM RT. */ | 1181 | Lisp_Object *pvalbuf; |
| 1167 | Lisp_Object xs; | 1182 | valcontents = XSYMBOL (sym)->value; |
| 1168 | 1183 | pvalbuf = &XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; | |
| 1169 | xs = XSYMBOL (sym)->value; | 1184 | if (current_buffer == XBUFFER (*pvalbuf)) |
| 1170 | if (current_buffer == XBUFFER (XCONS (XCONS (xs)->cdr)->car)) | 1185 | *pvalbuf = Qnil; |
| 1171 | XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->car = Qnil; | ||
| 1172 | } | 1186 | } |
| 1173 | } | 1187 | } |
| 1174 | 1188 | ||
| @@ -1176,7 +1190,7 @@ Use `make-local-hook' instead.") | |||
| 1176 | variable for this buffer immediately. If C code modifies the | 1190 | variable for this buffer immediately. If C code modifies the |
| 1177 | variable before we swap in, then that new value will clobber the | 1191 | variable before we swap in, then that new value will clobber the |
| 1178 | default value the next time we swap. */ | 1192 | default value the next time we swap. */ |
| 1179 | valcontents = XCONS (XSYMBOL (sym)->value)->car; | 1193 | valcontents = XBUFFER_LOCAL_VALUE (XSYMBOL (sym)->value)->car; |
| 1180 | if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents)) | 1194 | if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents)) |
| 1181 | swap_in_symval_forwarding (sym, XSYMBOL (sym)->value); | 1195 | swap_in_symval_forwarding (sym, XSYMBOL (sym)->value); |
| 1182 | 1196 | ||
| @@ -1219,15 +1233,17 @@ From now on the default value will apply in this buffer.") | |||
| 1219 | 1233 | ||
| 1220 | tem = Fassq (sym, current_buffer->local_var_alist); | 1234 | tem = Fassq (sym, current_buffer->local_var_alist); |
| 1221 | if (!NILP (tem)) | 1235 | if (!NILP (tem)) |
| 1222 | current_buffer->local_var_alist = Fdelq (tem, current_buffer->local_var_alist); | 1236 | current_buffer->local_var_alist |
| 1237 | = Fdelq (tem, current_buffer->local_var_alist); | ||
| 1223 | 1238 | ||
| 1224 | /* Make sure symbol does not think it is set up for this buffer; | 1239 | /* Make sure symbol does not think it is set up for this buffer; |
| 1225 | force it to look once again for this buffer's value */ | 1240 | force it to look once again for this buffer's value */ |
| 1226 | { | 1241 | { |
| 1227 | Lisp_Object sv; | 1242 | Lisp_Object *pvalbuf; |
| 1228 | sv = XSYMBOL (sym)->value; | 1243 | valcontents = XSYMBOL (sym)->value; |
| 1229 | if (current_buffer == XBUFFER (XCONS (XCONS (sv)->cdr)->car)) | 1244 | pvalbuf = &XCONS (XBUFFER_LOCAL_VALUE (valcontents)->cdr)->car; |
| 1230 | XCONS (XCONS (sv)->cdr)->car = Qnil; | 1245 | if (current_buffer == XBUFFER (*pvalbuf)) |
| 1246 | *pvalbuf = Qnil; | ||
| 1231 | } | 1247 | } |
| 1232 | 1248 | ||
| 1233 | return sym; | 1249 | return sym; |