Mercurial > emacs
comparison src/data.c @ 27294:b62412c9ab2a
(set_internal): New arg BUF.
(Fset): Pass new arg to set_internal.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 11 Jan 2000 22:18:09 +0000 |
parents | 234be1721197 |
children | 77048c4b6fb0 |
comparison
equal
deleted
inserted
replaced
27293:d94d421ca521 | 27294:b62412c9ab2a |
---|---|
832 else | 832 else |
833 XSYMBOL (symbol)->value = newval; | 833 XSYMBOL (symbol)->value = newval; |
834 } | 834 } |
835 } | 835 } |
836 | 836 |
837 /* Set up the buffer-local symbol SYMBOL for validity in the current | 837 /* Set up the buffer-local symbol SYMBOL for validity in the current buffer. |
838 buffer. VALCONTENTS is the contents of its value cell. | 838 VALCONTENTS is the contents of its value cell. |
839 Return the value forwarded one step past the buffer-local indicator. */ | 839 Return the value forwarded one step past the buffer-local indicator. */ |
840 | 840 |
841 static Lisp_Object | 841 static Lisp_Object |
842 swap_in_symval_forwarding (symbol, valcontents) | 842 swap_in_symval_forwarding (symbol, valcontents) |
843 Lisp_Object symbol, valcontents; | 843 Lisp_Object symbol, valcontents; |
908 CHECK_SYMBOL (symbol, 0); | 908 CHECK_SYMBOL (symbol, 0); |
909 valcontents = XSYMBOL (symbol)->value; | 909 valcontents = XSYMBOL (symbol)->value; |
910 | 910 |
911 if (BUFFER_LOCAL_VALUEP (valcontents) | 911 if (BUFFER_LOCAL_VALUEP (valcontents) |
912 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 912 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
913 valcontents = swap_in_symval_forwarding (symbol, valcontents); | 913 valcontents = swap_in_symval_forwarding (symbol, valcontents, |
914 current_buffer); | |
914 | 915 |
915 if (MISCP (valcontents)) | 916 if (MISCP (valcontents)) |
916 { | 917 { |
917 switch (XMISCTYPE (valcontents)) | 918 switch (XMISCTYPE (valcontents)) |
918 { | 919 { |
956 DEFUN ("set", Fset, Sset, 2, 2, 0, | 957 DEFUN ("set", Fset, Sset, 2, 2, 0, |
957 "Set SYMBOL's value to NEWVAL, and return NEWVAL.") | 958 "Set SYMBOL's value to NEWVAL, and return NEWVAL.") |
958 (symbol, newval) | 959 (symbol, newval) |
959 register Lisp_Object symbol, newval; | 960 register Lisp_Object symbol, newval; |
960 { | 961 { |
961 return set_internal (symbol, newval, 0); | 962 return set_internal (symbol, newval, current_buffer, 0); |
962 } | 963 } |
963 | 964 |
964 /* Store the value NEWVAL into SYMBOL. | 965 /* Store the value NEWVAL into SYMBOL. |
966 If buffer-locality is an issue, BUF specifies which buffer to use. | |
967 (0 stands for the current buffer.) | |
968 | |
965 If BINDFLAG is zero, then if this symbol is supposed to become | 969 If BINDFLAG is zero, then if this symbol is supposed to become |
966 local in every buffer where it is set, then we make it local. | 970 local in every buffer where it is set, then we make it local. |
967 If BINDFLAG is nonzero, we don't do that. */ | 971 If BINDFLAG is nonzero, we don't do that. */ |
968 | 972 |
969 Lisp_Object | 973 Lisp_Object |
970 set_internal (symbol, newval, bindflag) | 974 set_internal (symbol, newval, buf, bindflag) |
971 register Lisp_Object symbol, newval; | 975 register Lisp_Object symbol, newval; |
976 struct buffer *buf; | |
972 int bindflag; | 977 int bindflag; |
973 { | 978 { |
974 int voide = EQ (newval, Qunbound); | 979 int voide = EQ (newval, Qunbound); |
975 | 980 |
976 register Lisp_Object valcontents, tem1, current_alist_element; | 981 register Lisp_Object valcontents, tem1, current_alist_element; |
982 | |
983 if (buf == 0) | |
984 buf = current_buffer; | |
985 | |
986 /* If restoring in a dead buffer, do nothing. */ | |
987 if (NILP (buf->name)) | |
988 return newval; | |
977 | 989 |
978 CHECK_SYMBOL (symbol, 0); | 990 CHECK_SYMBOL (symbol, 0); |
979 if (NILP (symbol) || EQ (symbol, Qt) | 991 if (NILP (symbol) || EQ (symbol, Qt) |
980 || (XSYMBOL (symbol)->name->data[0] == ':' | 992 || (XSYMBOL (symbol)->name->data[0] == ':' |
981 && EQ (XSYMBOL (symbol)->obarray, initial_obarray) | 993 && EQ (XSYMBOL (symbol)->obarray, initial_obarray) |
987 { | 999 { |
988 register int idx = XBUFFER_OBJFWD (valcontents)->offset; | 1000 register int idx = XBUFFER_OBJFWD (valcontents)->offset; |
989 register int mask = XINT (*((Lisp_Object *) | 1001 register int mask = XINT (*((Lisp_Object *) |
990 (idx + (char *)&buffer_local_flags))); | 1002 (idx + (char *)&buffer_local_flags))); |
991 if (mask > 0 && ! bindflag) | 1003 if (mask > 0 && ! bindflag) |
992 current_buffer->local_var_flags |= mask; | 1004 buf->local_var_flags |= mask; |
993 } | 1005 } |
994 | 1006 |
995 else if (BUFFER_LOCAL_VALUEP (valcontents) | 1007 else if (BUFFER_LOCAL_VALUEP (valcontents) |
996 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1008 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
997 { | 1009 { |
1029 | 1041 |
1030 /* If the current buffer is not the buffer whose binding is | 1042 /* If the current buffer is not the buffer whose binding is |
1031 currently cached, or if it's a Lisp_Buffer_Local_Value and | 1043 currently cached, or if it's a Lisp_Buffer_Local_Value and |
1032 we're looking at the default value, the cache is invalid; we | 1044 we're looking at the default value, the cache is invalid; we |
1033 need to write it out, and find the new CURRENT-ALIST-ELEMENT. */ | 1045 need to write it out, and find the new CURRENT-ALIST-ELEMENT. */ |
1034 if (current_buffer != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer) | 1046 if (buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer) |
1035 || !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame) | 1047 || !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame) |
1036 || (BUFFER_LOCAL_VALUEP (valcontents) | 1048 || (BUFFER_LOCAL_VALUEP (valcontents) |
1037 && EQ (XCAR (current_alist_element), | 1049 && EQ (XCAR (current_alist_element), |
1038 current_alist_element))) | 1050 current_alist_element))) |
1039 { | 1051 { |
1042 buffer only sees the default value, too. */ | 1054 buffer only sees the default value, too. */ |
1043 Fsetcdr (current_alist_element, | 1055 Fsetcdr (current_alist_element, |
1044 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); | 1056 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); |
1045 | 1057 |
1046 /* Find the new value for CURRENT-ALIST-ELEMENT. */ | 1058 /* Find the new value for CURRENT-ALIST-ELEMENT. */ |
1047 tem1 = Fassq (symbol, current_buffer->local_var_alist); | 1059 tem1 = Fassq (symbol, buf->local_var_alist); |
1048 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; | 1060 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; |
1049 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; | 1061 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; |
1050 | 1062 |
1051 if (NILP (tem1)) | 1063 if (NILP (tem1)) |
1052 { | 1064 { |
1073 give this buffer a new assoc for a local value and set | 1085 give this buffer a new assoc for a local value and set |
1074 CURRENT-ALIST-ELEMENT to point to that. */ | 1086 CURRENT-ALIST-ELEMENT to point to that. */ |
1075 else | 1087 else |
1076 { | 1088 { |
1077 tem1 = Fcons (symbol, Fcdr (current_alist_element)); | 1089 tem1 = Fcons (symbol, Fcdr (current_alist_element)); |
1078 current_buffer->local_var_alist | 1090 buf->local_var_alist |
1079 = Fcons (tem1, current_buffer->local_var_alist); | 1091 = Fcons (tem1, buf->local_var_alist); |
1080 } | 1092 } |
1081 } | 1093 } |
1082 | 1094 |
1083 /* Cache the new buffer's assoc in CURRENT-ALIST-ELEMENT. */ | 1095 /* Cache the new buffer's assoc in CURRENT-ALIST-ELEMENT. */ |
1084 XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr) | 1096 XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr) |
1085 = tem1; | 1097 = tem1; |
1086 | 1098 |
1087 /* Set BUFFER and FRAME for binding now loaded. */ | 1099 /* Set BUFFER and FRAME for binding now loaded. */ |
1088 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, | 1100 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf); |
1089 current_buffer); | |
1090 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; | 1101 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; |
1091 } | 1102 } |
1092 valcontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; | 1103 valcontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; |
1093 } | 1104 } |
1094 | 1105 |