Mercurial > emacs
comparison src/data.c @ 39973:579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
with lisp system changes.
| author | Ken Raeburn <raeburn@raeburn.org> |
|---|---|
| date | Tue, 16 Oct 2001 09:09:51 +0000 |
| parents | 280975f8c65e |
| children | 528dd5f565ba |
comparison
equal
deleted
inserted
replaced
| 39972:b2479b43184b | 39973:579177964efa |
|---|---|
| 580 { | 580 { |
| 581 if (!CONSP (cell)) | 581 if (!CONSP (cell)) |
| 582 cell = wrong_type_argument (Qconsp, cell); | 582 cell = wrong_type_argument (Qconsp, cell); |
| 583 | 583 |
| 584 CHECK_IMPURE (cell); | 584 CHECK_IMPURE (cell); |
| 585 XCAR (cell) = newcar; | 585 XSETCAR (cell, newcar); |
| 586 return newcar; | 586 return newcar; |
| 587 } | 587 } |
| 588 | 588 |
| 589 DEFUN ("setcdr", Fsetcdr, Ssetcdr, 2, 2, 0, | 589 DEFUN ("setcdr", Fsetcdr, Ssetcdr, 2, 2, 0, |
| 590 "Set the cdr of CELL to be NEWCDR. Returns NEWCDR.") | 590 "Set the cdr of CELL to be NEWCDR. Returns NEWCDR.") |
| 593 { | 593 { |
| 594 if (!CONSP (cell)) | 594 if (!CONSP (cell)) |
| 595 cell = wrong_type_argument (Qconsp, cell); | 595 cell = wrong_type_argument (Qconsp, cell); |
| 596 | 596 |
| 597 CHECK_IMPURE (cell); | 597 CHECK_IMPURE (cell); |
| 598 XCDR (cell) = newcdr; | 598 XSETCDR (cell, newcdr); |
| 599 return newcdr; | 599 return newcdr; |
| 600 } | 600 } |
| 601 | 601 |
| 602 /* Extract and set components of symbols */ | 602 /* Extract and set components of symbols */ |
| 603 | 603 |
| 935 /* Unload the previously loaded binding. */ | 935 /* Unload the previously loaded binding. */ |
| 936 Fsetcdr (XCAR (cdr), | 936 Fsetcdr (XCAR (cdr), |
| 937 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); | 937 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); |
| 938 | 938 |
| 939 /* Select the global binding in the symbol. */ | 939 /* Select the global binding in the symbol. */ |
| 940 XCAR (cdr) = cdr; | 940 XSETCAR (cdr, cdr); |
| 941 store_symval_forwarding (symbol, valcontents, XCDR (cdr), NULL); | 941 store_symval_forwarding (symbol, valcontents, XCDR (cdr), NULL); |
| 942 | 942 |
| 943 /* Indicate that the global binding is set up now. */ | 943 /* Indicate that the global binding is set up now. */ |
| 944 XBUFFER_LOCAL_VALUE (valcontents)->frame = Qnil; | 944 XBUFFER_LOCAL_VALUE (valcontents)->frame = Qnil; |
| 945 XBUFFER_LOCAL_VALUE (valcontents)->buffer = Qnil; | 945 XBUFFER_LOCAL_VALUE (valcontents)->buffer = Qnil; |
| 989 } | 989 } |
| 990 else | 990 else |
| 991 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; | 991 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; |
| 992 | 992 |
| 993 /* Load the new binding. */ | 993 /* Load the new binding. */ |
| 994 XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr) = tem1; | 994 XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, tem1); |
| 995 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, current_buffer); | 995 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, current_buffer); |
| 996 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; | 996 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; |
| 997 store_symval_forwarding (symbol, | 997 store_symval_forwarding (symbol, |
| 998 XBUFFER_LOCAL_VALUE (valcontents)->realvalue, | 998 XBUFFER_LOCAL_VALUE (valcontents)->realvalue, |
| 999 Fcdr (tem1), NULL); | 999 Fcdr (tem1), NULL); |
| 1208 = Fcons (tem1, buf->local_var_alist); | 1208 = Fcons (tem1, buf->local_var_alist); |
| 1209 } | 1209 } |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 /* Record which binding is now loaded. */ | 1212 /* Record which binding is now loaded. */ |
| 1213 XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr) | 1213 XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, |
| 1214 = tem1; | 1214 tem1); |
| 1215 | 1215 |
| 1216 /* Set `buffer' and `frame' slots for thebinding now loaded. */ | 1216 /* Set `buffer' and `frame' slots for thebinding now loaded. */ |
| 1217 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf); | 1217 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf); |
| 1218 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; | 1218 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; |
| 1219 } | 1219 } |
| 1241 loaded, or if there may be frame-local bindings and the frame | 1241 loaded, or if there may be frame-local bindings and the frame |
| 1242 isn't the right one, or if it's a Lisp_Buffer_Local_Value and | 1242 isn't the right one, or if it's a Lisp_Buffer_Local_Value and |
| 1243 the default binding is loaded, the loaded binding may be the | 1243 the default binding is loaded, the loaded binding may be the |
| 1244 wrong one. */ | 1244 wrong one. */ |
| 1245 if (XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) | 1245 if (XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) |
| 1246 XCDR (current_alist_element) = newval; | 1246 XSETCDR (current_alist_element, newval); |
| 1247 } | 1247 } |
| 1248 | 1248 |
| 1249 return newval; | 1249 return newval; |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1360 if (!BUFFER_LOCAL_VALUEP (valcontents) | 1360 if (!BUFFER_LOCAL_VALUEP (valcontents) |
| 1361 && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1361 && !SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 1362 return Fset (symbol, value); | 1362 return Fset (symbol, value); |
| 1363 | 1363 |
| 1364 /* Store new value into the DEFAULT-VALUE slot. */ | 1364 /* Store new value into the DEFAULT-VALUE slot. */ |
| 1365 XCDR (XBUFFER_LOCAL_VALUE (valcontents)->cdr) = value; | 1365 XSETCDR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, value); |
| 1366 | 1366 |
| 1367 /* If the default binding is now loaded, set the REALVALUE slot too. */ | 1367 /* If the default binding is now loaded, set the REALVALUE slot too. */ |
| 1368 current_alist_element | 1368 current_alist_element |
| 1369 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); | 1369 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); |
| 1370 alist_element_buffer = Fcar (current_alist_element); | 1370 alist_element_buffer = Fcar (current_alist_element); |
| 1446 return variable; | 1446 return variable; |
| 1447 } | 1447 } |
| 1448 if (EQ (valcontents, Qunbound)) | 1448 if (EQ (valcontents, Qunbound)) |
| 1449 SET_SYMBOL_VALUE (variable, Qnil); | 1449 SET_SYMBOL_VALUE (variable, Qnil); |
| 1450 tem = Fcons (Qnil, Fsymbol_value (variable)); | 1450 tem = Fcons (Qnil, Fsymbol_value (variable)); |
| 1451 XCAR (tem) = tem; | 1451 XSETCAR (tem, tem); |
| 1452 newval = allocate_misc (); | 1452 newval = allocate_misc (); |
| 1453 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; | 1453 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; |
| 1454 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); | 1454 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); |
| 1455 XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer (); | 1455 XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer (); |
| 1456 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; | 1456 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; |
| 1503 /* Make sure symbol is set up to hold per-buffer values. */ | 1503 /* Make sure symbol is set up to hold per-buffer values. */ |
| 1504 if (!SOME_BUFFER_LOCAL_VALUEP (valcontents)) | 1504 if (!SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 1505 { | 1505 { |
| 1506 Lisp_Object newval; | 1506 Lisp_Object newval; |
| 1507 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); | 1507 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); |
| 1508 XCAR (tem) = tem; | 1508 XSETCAR (tem, tem); |
| 1509 newval = allocate_misc (); | 1509 newval = allocate_misc (); |
| 1510 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; | 1510 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; |
| 1511 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); | 1511 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); |
| 1512 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; | 1512 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; |
| 1513 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; | 1513 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; |
| 1642 } | 1642 } |
| 1643 | 1643 |
| 1644 if (EQ (valcontents, Qunbound)) | 1644 if (EQ (valcontents, Qunbound)) |
| 1645 SET_SYMBOL_VALUE (variable, Qnil); | 1645 SET_SYMBOL_VALUE (variable, Qnil); |
| 1646 tem = Fcons (Qnil, Fsymbol_value (variable)); | 1646 tem = Fcons (Qnil, Fsymbol_value (variable)); |
| 1647 XCAR (tem) = tem; | 1647 XSETCAR (tem, tem); |
| 1648 newval = allocate_misc (); | 1648 newval = allocate_misc (); |
| 1649 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; | 1649 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; |
| 1650 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); | 1650 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); |
| 1651 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; | 1651 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; |
| 1652 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; | 1652 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; |
