comparison src/data.c @ 27703:2ff09a66fbf1

(set_internal): Don't make variable buffer-local if within a let-binding for the same buffer. (let_shadows_buffer_binding_p): New function.
author Richard M. Stallman <rms@gnu.org>
date Tue, 15 Feb 2000 09:57:33 +0000
parents 38dfea505906
children 9400865ec7cf
comparison
equal deleted inserted replaced
27702:50df459c86d1 27703:2ff09a66fbf1
960 register Lisp_Object symbol, newval; 960 register Lisp_Object symbol, newval;
961 { 961 {
962 return set_internal (symbol, newval, current_buffer, 0); 962 return set_internal (symbol, newval, current_buffer, 0);
963 } 963 }
964 964
965 /* Return 1 if SYMBOL currently has a let-binding
966 which was made in the buffer that is now current. */
967
968 static int
969 let_shadows_buffer_binding_p (symbol)
970 Lisp_Object symbol;
971 {
972 struct specbinding *p;
973
974 for (p = specpdl_ptr - 1; p >= specpdl; p--)
975 if (p->func == 0 && CONSP (p->symbol)
976 && XBUFFER (XCDR (XCDR (p->symbol))) == current_buffer)
977 return 1;
978
979 return 0;
980 }
981
965 /* Store the value NEWVAL into SYMBOL. 982 /* Store the value NEWVAL into SYMBOL.
966 If buffer-locality is an issue, BUF specifies which buffer to use. 983 If buffer-locality is an issue, BUF specifies which buffer to use.
967 (0 stands for the current buffer.) 984 (0 stands for the current buffer.)
968 985
969 If BINDFLAG is zero, then if this symbol is supposed to become 986 If BINDFLAG is zero, then if this symbol is supposed to become
998 if (BUFFER_OBJFWDP (valcontents)) 1015 if (BUFFER_OBJFWDP (valcontents))
999 { 1016 {
1000 register int idx = XBUFFER_OBJFWD (valcontents)->offset; 1017 register int idx = XBUFFER_OBJFWD (valcontents)->offset;
1001 register int mask = XINT (*((Lisp_Object *) 1018 register int mask = XINT (*((Lisp_Object *)
1002 (idx + (char *)&buffer_local_flags))); 1019 (idx + (char *)&buffer_local_flags)));
1003 if (mask > 0 && ! bindflag) 1020 if (mask > 0 && ! bindflag
1021 && ! let_shadows_buffer_binding_p (symbol))
1004 buf->local_var_flags |= mask; 1022 buf->local_var_flags |= mask;
1005 } 1023 }
1006 1024
1007 else if (BUFFER_LOCAL_VALUEP (valcontents) 1025 else if (BUFFER_LOCAL_VALUEP (valcontents)
1008 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) 1026 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1066 /* This buffer still sees the default value. */ 1084 /* This buffer still sees the default value. */
1067 1085
1068 /* If the variable is a Lisp_Some_Buffer_Local_Value, 1086 /* If the variable is a Lisp_Some_Buffer_Local_Value,
1069 or if this is `let' rather than `set', 1087 or if this is `let' rather than `set',
1070 make CURRENT-ALIST-ELEMENT point to itself, 1088 make CURRENT-ALIST-ELEMENT point to itself,
1071 indicating that we're seeing the default value. */ 1089 indicating that we're seeing the default value.
1072 if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents)) 1090 Likewise if the variable has been let-bound
1091 in the current buffer. */
1092 if (bindflag || SOME_BUFFER_LOCAL_VALUEP (valcontents)
1093 || let_shadows_buffer_binding_p (symbol))
1073 { 1094 {
1074 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; 1095 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0;
1075 1096
1076 if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame) 1097 if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame)
1077 tem1 = Fassq (symbol, 1098 tem1 = Fassq (symbol,
1081 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 1; 1102 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 1;
1082 else 1103 else
1083 tem1 = XBUFFER_LOCAL_VALUE (valcontents)->cdr; 1104 tem1 = XBUFFER_LOCAL_VALUE (valcontents)->cdr;
1084 } 1105 }
1085 /* If it's a Lisp_Buffer_Local_Value, being set not bound, 1106 /* If it's a Lisp_Buffer_Local_Value, being set not bound,
1086 give this buffer a new assoc for a local value and set 1107 and we're not within a let that was made for this buffer,
1087 CURRENT-ALIST-ELEMENT to point to that. */ 1108 create a new buffer-local binding for the variable.
1109 That means, give this buffer a new assoc for a local value
1110 and set CURRENT-ALIST-ELEMENT to point to that. */
1088 else 1111 else
1089 { 1112 {
1090 tem1 = Fcons (symbol, Fcdr (current_alist_element)); 1113 tem1 = Fcons (symbol, Fcdr (current_alist_element));
1091 buf->local_var_alist 1114 buf->local_var_alist
1092 = Fcons (tem1, buf->local_var_alist); 1115 = Fcons (tem1, buf->local_var_alist);