aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorMiles Bader2007-12-06 09:51:45 +0000
committerMiles Bader2007-12-06 09:51:45 +0000
commit0bd508417142ff377f34aec8dcec9438d9175c2c (patch)
tree4d60fe09e5cebf7d79766b11e9cda8cc1c9dbb9b /src/data.c
parent98fe991da804a42f53f6a5e84cd5eab18a82e181 (diff)
parent9fb1ba8090da3528de56158a79bd3527d31c7f2f (diff)
downloademacs-0bd508417142ff377f34aec8dcec9438d9175c2c.tar.gz
emacs-0bd508417142ff377f34aec8dcec9438d9175c2c.zip
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c102
1 files changed, 30 insertions, 72 deletions
diff --git a/src/data.c b/src/data.c
index e02e22aa0e3..88a665b3cf8 100644
--- a/src/data.c
+++ b/src/data.c
@@ -864,7 +864,6 @@ do_symval_forwarding (valcontents)
864 register Lisp_Object valcontents; 864 register Lisp_Object valcontents;
865{ 865{
866 register Lisp_Object val; 866 register Lisp_Object val;
867 int offset;
868 if (MISCP (valcontents)) 867 if (MISCP (valcontents))
869 switch (XMISCTYPE (valcontents)) 868 switch (XMISCTYPE (valcontents))
870 { 869 {
@@ -879,11 +878,10 @@ do_symval_forwarding (valcontents)
879 return *XOBJFWD (valcontents)->objvar; 878 return *XOBJFWD (valcontents)->objvar;
880 879
881 case Lisp_Misc_Buffer_Objfwd: 880 case Lisp_Misc_Buffer_Objfwd:
882 offset = XBUFFER_OBJFWD (valcontents)->offset; 881 return PER_BUFFER_VALUE (current_buffer,
883 return PER_BUFFER_VALUE (current_buffer, offset); 882 XBUFFER_OBJFWD (valcontents)->offset);
884 883
885 case Lisp_Misc_Kboard_Objfwd: 884 case Lisp_Misc_Kboard_Objfwd:
886 offset = XKBOARD_OBJFWD (valcontents)->offset;
887 /* We used to simply use current_kboard here, but from Lisp 885 /* We used to simply use current_kboard here, but from Lisp
888 code, it's value is often unexpected. It seems nicer to 886 code, it's value is often unexpected. It seems nicer to
889 allow constructions like this to work as intuitively expected: 887 allow constructions like this to work as intuitively expected:
@@ -895,7 +893,8 @@ do_symval_forwarding (valcontents)
895 last-command and real-last-command, and people may rely on 893 last-command and real-last-command, and people may rely on
896 that. I took a quick look at the Lisp codebase, and I 894 that. I took a quick look at the Lisp codebase, and I
897 don't think anything will break. --lorentey */ 895 don't think anything will break. --lorentey */
898 return *(Lisp_Object *)(offset + (char *)FRAME_KBOARD (SELECTED_FRAME ())); 896 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
897 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
899 } 898 }
900 return valcontents; 899 return valcontents;
901} 900}
@@ -922,13 +921,15 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
922 case Lisp_Misc_Intfwd: 921 case Lisp_Misc_Intfwd:
923 CHECK_NUMBER (newval); 922 CHECK_NUMBER (newval);
924 *XINTFWD (valcontents)->intvar = XINT (newval); 923 *XINTFWD (valcontents)->intvar = XINT (newval);
925 if (*XINTFWD (valcontents)->intvar != XINT (newval)) 924 /* This can never happen since intvar points to an EMACS_INT
926 error ("Value out of range for variable `%s'", 925 which is at least large enough to hold a Lisp_Object.
927 SDATA (SYMBOL_NAME (symbol))); 926 if (*XINTFWD (valcontents)->intvar != XINT (newval))
927 error ("Value out of range for variable `%s'",
928 SDATA (SYMBOL_NAME (symbol))); */
928 break; 929 break;
929 930
930 case Lisp_Misc_Boolfwd: 931 case Lisp_Misc_Boolfwd:
931 *XBOOLFWD (valcontents)->boolvar = NILP (newval) ? 0 : 1; 932 *XBOOLFWD (valcontents)->boolvar = !NILP (newval);
932 break; 933 break;
933 934
934 case Lisp_Misc_Objfwd: 935 case Lisp_Misc_Objfwd:
@@ -968,12 +969,11 @@ store_symval_forwarding (symbol, valcontents, newval, buf)
968 case Lisp_Misc_Buffer_Objfwd: 969 case Lisp_Misc_Buffer_Objfwd:
969 { 970 {
970 int offset = XBUFFER_OBJFWD (valcontents)->offset; 971 int offset = XBUFFER_OBJFWD (valcontents)->offset;
971 Lisp_Object type; 972 Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype;
972 973
973 type = PER_BUFFER_TYPE (offset);
974 if (! NILP (type) && ! NILP (newval) 974 if (! NILP (type) && ! NILP (newval)
975 && XTYPE (newval) != XINT (type)) 975 && XTYPE (newval) != XINT (type))
976 buffer_slot_type_mismatch (offset); 976 buffer_slot_type_mismatch (symbol, XINT (type));
977 977
978 if (buf == NULL) 978 if (buf == NULL)
979 buf = current_buffer; 979 buf = current_buffer;
@@ -1011,26 +1011,23 @@ void
1011swap_in_global_binding (symbol) 1011swap_in_global_binding (symbol)
1012 Lisp_Object symbol; 1012 Lisp_Object symbol;
1013{ 1013{
1014 Lisp_Object valcontents, cdr; 1014 Lisp_Object valcontents = SYMBOL_VALUE (symbol);
1015 1015 struct Lisp_Buffer_Local_Value *blv = XBUFFER_LOCAL_VALUE (valcontents);
1016 valcontents = SYMBOL_VALUE (symbol); 1016 Lisp_Object cdr = blv->cdr;
1017 if (!BUFFER_LOCAL_VALUEP (valcontents))
1018 abort ();
1019 cdr = XBUFFER_LOCAL_VALUE (valcontents)->cdr;
1020 1017
1021 /* Unload the previously loaded binding. */ 1018 /* Unload the previously loaded binding. */
1022 Fsetcdr (XCAR (cdr), 1019 Fsetcdr (XCAR (cdr),
1023 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); 1020 do_symval_forwarding (blv->realvalue));
1024 1021
1025 /* Select the global binding in the symbol. */ 1022 /* Select the global binding in the symbol. */
1026 XSETCAR (cdr, cdr); 1023 XSETCAR (cdr, cdr);
1027 store_symval_forwarding (symbol, valcontents, XCDR (cdr), NULL); 1024 store_symval_forwarding (symbol, blv->realvalue, XCDR (cdr), NULL);
1028 1025
1029 /* Indicate that the global binding is set up now. */ 1026 /* Indicate that the global binding is set up now. */
1030 XBUFFER_LOCAL_VALUE (valcontents)->frame = Qnil; 1027 blv->frame = Qnil;
1031 XBUFFER_LOCAL_VALUE (valcontents)->buffer = Qnil; 1028 blv->buffer = Qnil;
1032 XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame = 0; 1029 blv->found_for_frame = 0;
1033 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; 1030 blv->found_for_buffer = 0;
1034} 1031}
1035 1032
1036/* Set up the buffer-local symbol SYMBOL for validity in the current buffer. 1033/* Set up the buffer-local symbol SYMBOL for validity in the current buffer.
@@ -1106,31 +1103,7 @@ find_symbol_value (symbol)
1106 if (BUFFER_LOCAL_VALUEP (valcontents)) 1103 if (BUFFER_LOCAL_VALUEP (valcontents))
1107 valcontents = swap_in_symval_forwarding (symbol, valcontents); 1104 valcontents = swap_in_symval_forwarding (symbol, valcontents);
1108 1105
1109 if (MISCP (valcontents)) 1106 return do_symval_forwarding (valcontents);
1110 {
1111 switch (XMISCTYPE (valcontents))
1112 {
1113 case Lisp_Misc_Intfwd:
1114 XSETINT (val, *XINTFWD (valcontents)->intvar);
1115 return val;
1116
1117 case Lisp_Misc_Boolfwd:
1118 return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil);
1119
1120 case Lisp_Misc_Objfwd:
1121 return *XOBJFWD (valcontents)->objvar;
1122
1123 case Lisp_Misc_Buffer_Objfwd:
1124 return PER_BUFFER_VALUE (current_buffer,
1125 XBUFFER_OBJFWD (valcontents)->offset);
1126
1127 case Lisp_Misc_Kboard_Objfwd:
1128 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
1129 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
1130 }
1131 }
1132
1133 return valcontents;
1134} 1107}
1135 1108
1136DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0, 1109DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0,
@@ -1240,9 +1213,9 @@ set_internal (symbol, newval, buf, bindflag)
1240 || buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer) 1213 || buf != XBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer)
1241 || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame 1214 || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame
1242 && !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame)) 1215 && !EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame))
1243 || (BUFFER_LOCAL_VALUEP (valcontents) 1216 /* Also unload a global binding (if the var is local_if_set). */
1244 && EQ (XCAR (current_alist_element), 1217 || (EQ (XCAR (current_alist_element),
1245 current_alist_element))) 1218 current_alist_element)))
1246 { 1219 {
1247 /* The currently loaded binding is not necessarily valid. 1220 /* The currently loaded binding is not necessarily valid.
1248 We need to unload it, and choose a new binding. */ 1221 We need to unload it, and choose a new binding. */
@@ -1260,7 +1233,7 @@ set_internal (symbol, newval, buf, bindflag)
1260 { 1233 {
1261 /* This buffer still sees the default value. */ 1234 /* This buffer still sees the default value. */
1262 1235
1263 /* If the variable is a Lisp_Some_Buffer_Local_Value, 1236 /* If the variable is not local_if_set,
1264 or if this is `let' rather than `set', 1237 or if this is `let' rather than `set',
1265 make CURRENT-ALIST-ELEMENT point to itself, 1238 make CURRENT-ALIST-ELEMENT point to itself,
1266 indicating that we're seeing the default value. 1239 indicating that we're seeing the default value.
@@ -1301,6 +1274,9 @@ set_internal (symbol, newval, buf, bindflag)
1301 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; 1274 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame;
1302 } 1275 }
1303 innercontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue; 1276 innercontents = XBUFFER_LOCAL_VALUE (valcontents)->realvalue;
1277
1278 /* Store the new value in the cons-cell. */
1279 XSETCDR (XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr), newval);
1304 } 1280 }
1305 1281
1306 /* If storing void (making the symbol void), forward only through 1282 /* If storing void (making the symbol void), forward only through
@@ -1310,24 +1286,6 @@ set_internal (symbol, newval, buf, bindflag)
1310 else 1286 else
1311 store_symval_forwarding (symbol, innercontents, newval, buf); 1287 store_symval_forwarding (symbol, innercontents, newval, buf);
1312 1288
1313 /* If we just set a variable whose current binding is frame-local,
1314 store the new value in the frame parameter too. */
1315
1316 if (BUFFER_LOCAL_VALUEP (valcontents))
1317 {
1318 /* What binding is loaded right now? */
1319 current_alist_element
1320 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr);
1321
1322 /* If the current buffer is not the buffer whose binding is
1323 loaded, or if there may be frame-local bindings and the frame
1324 isn't the right one, or if it's a Lisp_Buffer_Local_Value and
1325 the default binding is loaded, the loaded binding may be the
1326 wrong one. */
1327 if (XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame)
1328 XSETCDR (current_alist_element, newval);
1329 }
1330
1331 return newval; 1289 return newval;
1332} 1290}
1333 1291
@@ -2320,7 +2278,7 @@ NUMBER may be an integer or a floating point number. */)
2320 } 2278 }
2321 2279
2322 if (sizeof (int) == sizeof (EMACS_INT)) 2280 if (sizeof (int) == sizeof (EMACS_INT))
2323 sprintf (buffer, "%d", XINT (number)); 2281 sprintf (buffer, "%d", (int) XINT (number));
2324 else if (sizeof (long) == sizeof (EMACS_INT)) 2282 else if (sizeof (long) == sizeof (EMACS_INT))
2325 sprintf (buffer, "%ld", (long) XINT (number)); 2283 sprintf (buffer, "%ld", (long) XINT (number));
2326 else 2284 else