comparison src/data.c @ 95112:0835cb21d60e

* lisp.h (indirect_variable): * data.c (indirect_variable, let_shadows_buffer_binding_p): Use Lisp_Symbol pointers rather than Lisp_Object. Adjust callers. * buffer.c (buffer_slot_type_mismatch): Use wrong-type-argument. To this end, change calling-convention.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 19 May 2008 18:38:55 +0000
parents 8971ddf55736
children 8a703a3c84d7
comparison
equal deleted inserted replaced
95111:f3a094e70d91 95112:0835cb21d60e
811 811
812 /* Return the symbol holding SYMBOL's value. Signal 812 /* Return the symbol holding SYMBOL's value. Signal
813 `cyclic-variable-indirection' if SYMBOL's chain of variable 813 `cyclic-variable-indirection' if SYMBOL's chain of variable
814 indirections contains a loop. */ 814 indirections contains a loop. */
815 815
816 Lisp_Object 816 struct Lisp_Symbol *
817 indirect_variable (symbol) 817 indirect_variable (symbol)
818 Lisp_Object symbol; 818 struct Lisp_Symbol *symbol;
819 { 819 {
820 Lisp_Object tortoise, hare; 820 struct Lisp_Symbol *tortoise, *hare;
821 821
822 hare = tortoise = symbol; 822 hare = tortoise = symbol;
823 823
824 while (XSYMBOL (hare)->indirect_variable) 824 while (hare->indirect_variable)
825 { 825 {
826 hare = XSYMBOL (hare)->value; 826 hare = XSYMBOL (hare->value);
827 if (!XSYMBOL (hare)->indirect_variable) 827 if (!hare->indirect_variable)
828 break; 828 break;
829 829
830 hare = XSYMBOL (hare)->value; 830 hare = XSYMBOL (hare->value);
831 tortoise = XSYMBOL (tortoise)->value; 831 tortoise = XSYMBOL (tortoise->value);
832 832
833 if (EQ (hare, tortoise)) 833 if (hare == tortoise)
834 xsignal1 (Qcyclic_variable_indirection, symbol); 834 {
835 Lisp_Object tem;
836 XSETSYMBOL (tem, symbol);
837 xsignal1 (Qcyclic_variable_indirection, tem);
838 }
835 } 839 }
836 840
837 return hare; 841 return hare;
838 } 842 }
839 843
846 variable chain of symbols. */) 850 variable chain of symbols. */)
847 (object) 851 (object)
848 Lisp_Object object; 852 Lisp_Object object;
849 { 853 {
850 if (SYMBOLP (object)) 854 if (SYMBOLP (object))
851 object = indirect_variable (object); 855 XSETSYMBOL (object, indirect_variable (XSYMBOL (object)));
852 return object; 856 return object;
853 } 857 }
854 858
855 859
856 /* Given the raw contents of a symbol value cell, 860 /* Given the raw contents of a symbol value cell,
970 int offset = XBUFFER_OBJFWD (valcontents)->offset; 974 int offset = XBUFFER_OBJFWD (valcontents)->offset;
971 Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype; 975 Lisp_Object type = XBUFFER_OBJFWD (valcontents)->slottype;
972 976
973 if (! NILP (type) && ! NILP (newval) 977 if (! NILP (type) && ! NILP (newval)
974 && XTYPE (newval) != XINT (type)) 978 && XTYPE (newval) != XINT (type))
975 buffer_slot_type_mismatch (symbol, XINT (type)); 979 buffer_slot_type_mismatch (newval, XINT (type));
976 980
977 if (buf == NULL) 981 if (buf == NULL)
978 buf = current_buffer; 982 buf = current_buffer;
979 PER_BUFFER_VALUE (buf, offset) = newval; 983 PER_BUFFER_VALUE (buf, offset) = newval;
980 } 984 }
1047 if (NILP (tem1) 1051 if (NILP (tem1)
1048 || current_buffer != XBUFFER (tem1) 1052 || current_buffer != XBUFFER (tem1)
1049 || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame 1053 || (XBUFFER_LOCAL_VALUE (valcontents)->check_frame
1050 && ! EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame))) 1054 && ! EQ (selected_frame, XBUFFER_LOCAL_VALUE (valcontents)->frame)))
1051 { 1055 {
1052 if (XSYMBOL (symbol)->indirect_variable) 1056 struct Lisp_Symbol *sym = XSYMBOL (symbol);
1053 symbol = indirect_variable (symbol); 1057 if (sym->indirect_variable)
1058 {
1059 sym = indirect_variable (sym);
1060 XSETSYMBOL (symbol, sym);
1061 }
1054 1062
1055 /* Unload the previously loaded binding. */ 1063 /* Unload the previously loaded binding. */
1056 tem1 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); 1064 tem1 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr);
1057 Fsetcdr (tem1, 1065 Fsetcdr (tem1,
1058 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); 1066 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue));
1130 /* Return 1 if SYMBOL currently has a let-binding 1138 /* Return 1 if SYMBOL currently has a let-binding
1131 which was made in the buffer that is now current. */ 1139 which was made in the buffer that is now current. */
1132 1140
1133 static int 1141 static int
1134 let_shadows_buffer_binding_p (symbol) 1142 let_shadows_buffer_binding_p (symbol)
1135 Lisp_Object symbol; 1143 struct Lisp_Symbol *symbol;
1136 { 1144 {
1137 volatile struct specbinding *p; 1145 volatile struct specbinding *p;
1138 1146
1139 for (p = specpdl_ptr - 1; p >= specpdl; p--) 1147 for (p = specpdl_ptr - 1; p >= specpdl; p--)
1140 if (p->func == NULL 1148 if (p->func == NULL
1141 && CONSP (p->symbol)) 1149 && CONSP (p->symbol))
1142 { 1150 {
1143 Lisp_Object let_bound_symbol = XCAR (p->symbol); 1151 struct Lisp_Symbol *let_bound_symbol = XSYMBOL (XCAR (p->symbol));
1144 if ((EQ (symbol, let_bound_symbol) 1152 if ((symbol == let_bound_symbol
1145 || (XSYMBOL (let_bound_symbol)->indirect_variable 1153 || (let_bound_symbol->indirect_variable
1146 && EQ (symbol, indirect_variable (let_bound_symbol)))) 1154 && symbol == indirect_variable (let_bound_symbol)))
1147 && XBUFFER (XCDR (XCDR (p->symbol))) == current_buffer) 1155 && XBUFFER (XCDR (XCDR (p->symbol))) == current_buffer)
1148 break; 1156 break;
1149 } 1157 }
1150 1158
1151 return p >= specpdl; 1159 return p >= specpdl;
1195 } 1203 }
1196 else if (BUFFER_LOCAL_VALUEP (valcontents)) 1204 else if (BUFFER_LOCAL_VALUEP (valcontents))
1197 { 1205 {
1198 /* valcontents is a struct Lisp_Buffer_Local_Value. */ 1206 /* valcontents is a struct Lisp_Buffer_Local_Value. */
1199 if (XSYMBOL (symbol)->indirect_variable) 1207 if (XSYMBOL (symbol)->indirect_variable)
1200 symbol = indirect_variable (symbol); 1208 XSETSYMBOL (symbol, indirect_variable (XSYMBOL (symbol)));
1201 1209
1202 /* What binding is loaded right now? */ 1210 /* What binding is loaded right now? */
1203 current_alist_element 1211 current_alist_element
1204 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr); 1212 = XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr);
1205 1213
1237 make CURRENT-ALIST-ELEMENT point to itself, 1245 make CURRENT-ALIST-ELEMENT point to itself,
1238 indicating that we're seeing the default value. 1246 indicating that we're seeing the default value.
1239 Likewise if the variable has been let-bound 1247 Likewise if the variable has been let-bound
1240 in the current buffer. */ 1248 in the current buffer. */
1241 if (bindflag || !XBUFFER_LOCAL_VALUE (valcontents)->local_if_set 1249 if (bindflag || !XBUFFER_LOCAL_VALUE (valcontents)->local_if_set
1242 || let_shadows_buffer_binding_p (symbol)) 1250 || let_shadows_buffer_binding_p (XSYMBOL (symbol)))
1243 { 1251 {
1244 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; 1252 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0;
1245 1253
1246 if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame) 1254 if (XBUFFER_LOCAL_VALUE (valcontents)->check_frame)
1247 tem1 = Fassq (symbol, 1255 tem1 = Fassq (symbol,
1471 The function `default-value' gets the default value and `set-default' sets it. */) 1479 The function `default-value' gets the default value and `set-default' sets it. */)
1472 (variable) 1480 (variable)
1473 register Lisp_Object variable; 1481 register Lisp_Object variable;
1474 { 1482 {
1475 register Lisp_Object tem, valcontents, newval; 1483 register Lisp_Object tem, valcontents, newval;
1484 struct Lisp_Symbol *sym;
1476 1485
1477 CHECK_SYMBOL (variable); 1486 CHECK_SYMBOL (variable);
1478 variable = indirect_variable (variable); 1487 sym = indirect_variable (XSYMBOL (variable));
1479 1488
1480 valcontents = SYMBOL_VALUE (variable); 1489 valcontents = sym->value;
1481 if (XSYMBOL (variable)->constant || KBOARD_OBJFWDP (valcontents)) 1490 if (sym->constant || KBOARD_OBJFWDP (valcontents))
1482 error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); 1491 error ("Symbol %s may not be buffer-local", SDATA (sym->xname));
1483 1492
1484 if (BUFFER_OBJFWDP (valcontents)) 1493 if (BUFFER_OBJFWDP (valcontents))
1485 return variable; 1494 return variable;
1486 else if (BUFFER_LOCAL_VALUEP (valcontents)) 1495 else if (BUFFER_LOCAL_VALUEP (valcontents))
1487 newval = valcontents; 1496 newval = valcontents;
1488 else 1497 else
1489 { 1498 {
1490 if (EQ (valcontents, Qunbound)) 1499 if (EQ (valcontents, Qunbound))
1491 SET_SYMBOL_VALUE (variable, Qnil); 1500 sym->value = Qnil;
1492 tem = Fcons (Qnil, Fsymbol_value (variable)); 1501 tem = Fcons (Qnil, Fsymbol_value (variable));
1493 XSETCAR (tem, tem); 1502 XSETCAR (tem, tem);
1494 newval = allocate_misc (); 1503 newval = allocate_misc ();
1495 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; 1504 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
1496 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); 1505 XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value;
1497 XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer (); 1506 XBUFFER_LOCAL_VALUE (newval)->buffer = Fcurrent_buffer ();
1498 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; 1507 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
1499 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; 1508 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
1500 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; 1509 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
1501 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; 1510 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0;
1502 XBUFFER_LOCAL_VALUE (newval)->cdr = tem; 1511 XBUFFER_LOCAL_VALUE (newval)->cdr = tem;
1503 SET_SYMBOL_VALUE (variable, newval); 1512 sym->value = newval;
1504 } 1513 }
1505 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 1; 1514 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 1;
1506 return variable; 1515 return variable;
1507 } 1516 }
1508 1517
1528 Instead, use `add-hook' and specify t for the LOCAL argument. */) 1537 Instead, use `add-hook' and specify t for the LOCAL argument. */)
1529 (variable) 1538 (variable)
1530 register Lisp_Object variable; 1539 register Lisp_Object variable;
1531 { 1540 {
1532 register Lisp_Object tem, valcontents; 1541 register Lisp_Object tem, valcontents;
1542 struct Lisp_Symbol *sym;
1533 1543
1534 CHECK_SYMBOL (variable); 1544 CHECK_SYMBOL (variable);
1535 variable = indirect_variable (variable); 1545 sym = indirect_variable (XSYMBOL (variable));
1536 1546
1537 valcontents = SYMBOL_VALUE (variable); 1547 valcontents = sym->value;
1538 if (XSYMBOL (variable)->constant || KBOARD_OBJFWDP (valcontents)) 1548 if (sym->constant || KBOARD_OBJFWDP (valcontents))
1539 error ("Symbol %s may not be buffer-local", SDATA (SYMBOL_NAME (variable))); 1549 error ("Symbol %s may not be buffer-local", SDATA (sym->xname));
1540 1550
1541 if ((BUFFER_LOCAL_VALUEP (valcontents) 1551 if ((BUFFER_LOCAL_VALUEP (valcontents)
1542 && XBUFFER_LOCAL_VALUE (valcontents)->local_if_set) 1552 && XBUFFER_LOCAL_VALUE (valcontents)->local_if_set)
1543 || BUFFER_OBJFWDP (valcontents)) 1553 || BUFFER_OBJFWDP (valcontents))
1544 { 1554 {
1555 Lisp_Object newval; 1565 Lisp_Object newval;
1556 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); 1566 tem = Fcons (Qnil, do_symval_forwarding (valcontents));
1557 XSETCAR (tem, tem); 1567 XSETCAR (tem, tem);
1558 newval = allocate_misc (); 1568 newval = allocate_misc ();
1559 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; 1569 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
1560 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); 1570 XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value;
1561 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; 1571 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil;
1562 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; 1572 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
1563 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0; 1573 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0;
1564 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; 1574 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
1565 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; 1575 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
1566 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0; 1576 XBUFFER_LOCAL_VALUE (newval)->check_frame = 0;
1567 XBUFFER_LOCAL_VALUE (newval)->cdr = tem; 1577 XBUFFER_LOCAL_VALUE (newval)->cdr = tem;
1568 SET_SYMBOL_VALUE (variable, newval); 1578 sym->value = newval;
1569 } 1579 }
1570 /* Make sure this buffer has its own value of symbol. */ 1580 /* Make sure this buffer has its own value of symbol. */
1581 XSETSYMBOL (variable, sym); /* Propagate variable indirections. */
1571 tem = Fassq (variable, current_buffer->local_var_alist); 1582 tem = Fassq (variable, current_buffer->local_var_alist);
1572 if (NILP (tem)) 1583 if (NILP (tem))
1573 { 1584 {
1574 /* Swap out any local binding for some other buffer, and make 1585 /* Swap out any local binding for some other buffer, and make
1575 sure the current value is permanently recorded, if it's the 1586 sure the current value is permanently recorded, if it's the
1576 default value. */ 1587 default value. */
1577 find_symbol_value (variable); 1588 find_symbol_value (variable);
1578 1589
1579 current_buffer->local_var_alist 1590 current_buffer->local_var_alist
1580 = Fcons (Fcons (variable, XCDR (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (variable))->cdr)), 1591 = Fcons (Fcons (variable, XCDR (XBUFFER_LOCAL_VALUE (sym->value)->cdr)),
1581 current_buffer->local_var_alist); 1592 current_buffer->local_var_alist);
1582 1593
1583 /* Make sure symbol does not think it is set up for this buffer; 1594 /* Make sure symbol does not think it is set up for this buffer;
1584 force it to look once again for this buffer's value. */ 1595 force it to look once again for this buffer's value. */
1585 { 1596 {
1586 Lisp_Object *pvalbuf; 1597 Lisp_Object *pvalbuf;
1587 1598
1588 valcontents = SYMBOL_VALUE (variable); 1599 valcontents = sym->value;
1589 1600
1590 pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer; 1601 pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer;
1591 if (current_buffer == XBUFFER (*pvalbuf)) 1602 if (current_buffer == XBUFFER (*pvalbuf))
1592 *pvalbuf = Qnil; 1603 *pvalbuf = Qnil;
1593 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0; 1604 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 0;
1596 1607
1597 /* If the symbol forwards into a C variable, then load the binding 1608 /* If the symbol forwards into a C variable, then load the binding
1598 for this buffer now. If C code modifies the variable before we 1609 for this buffer now. If C code modifies the variable before we
1599 load the binding in, then that new value will clobber the default 1610 load the binding in, then that new value will clobber the default
1600 binding the next time we unload it. */ 1611 binding the next time we unload it. */
1601 valcontents = XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (variable))->realvalue; 1612 valcontents = XBUFFER_LOCAL_VALUE (sym->value)->realvalue;
1602 if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents)) 1613 if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents))
1603 swap_in_symval_forwarding (variable, SYMBOL_VALUE (variable)); 1614 swap_in_symval_forwarding (variable, sym->value);
1604 1615
1605 return variable; 1616 return variable;
1606 } 1617 }
1607 1618
1608 DEFUN ("kill-local-variable", Fkill_local_variable, Skill_local_variable, 1619 DEFUN ("kill-local-variable", Fkill_local_variable, Skill_local_variable,
1611 From now on the default value will apply in this buffer. Return VARIABLE. */) 1622 From now on the default value will apply in this buffer. Return VARIABLE. */)
1612 (variable) 1623 (variable)
1613 register Lisp_Object variable; 1624 register Lisp_Object variable;
1614 { 1625 {
1615 register Lisp_Object tem, valcontents; 1626 register Lisp_Object tem, valcontents;
1627 struct Lisp_Symbol *sym;
1616 1628
1617 CHECK_SYMBOL (variable); 1629 CHECK_SYMBOL (variable);
1618 variable = indirect_variable (variable); 1630 sym = indirect_variable (XSYMBOL (variable));
1619 1631
1620 valcontents = SYMBOL_VALUE (variable); 1632 valcontents = sym->value;
1621 1633
1622 if (BUFFER_OBJFWDP (valcontents)) 1634 if (BUFFER_OBJFWDP (valcontents))
1623 { 1635 {
1624 int offset = XBUFFER_OBJFWD (valcontents)->offset; 1636 int offset = XBUFFER_OBJFWD (valcontents)->offset;
1625 int idx = PER_BUFFER_IDX (offset); 1637 int idx = PER_BUFFER_IDX (offset);
1635 1647
1636 if (!BUFFER_LOCAL_VALUEP (valcontents)) 1648 if (!BUFFER_LOCAL_VALUEP (valcontents))
1637 return variable; 1649 return variable;
1638 1650
1639 /* Get rid of this buffer's alist element, if any. */ 1651 /* Get rid of this buffer's alist element, if any. */
1640 1652 XSETSYMBOL (variable, sym); /* Propagate variable indirection. */
1641 tem = Fassq (variable, current_buffer->local_var_alist); 1653 tem = Fassq (variable, current_buffer->local_var_alist);
1642 if (!NILP (tem)) 1654 if (!NILP (tem))
1643 current_buffer->local_var_alist 1655 current_buffer->local_var_alist
1644 = Fdelq (tem, current_buffer->local_var_alist); 1656 = Fdelq (tem, current_buffer->local_var_alist);
1645 1657
1646 /* If the symbol is set up with the current buffer's binding 1658 /* If the symbol is set up with the current buffer's binding
1647 loaded, recompute its value. We have to do it now, or else 1659 loaded, recompute its value. We have to do it now, or else
1648 forwarded objects won't work right. */ 1660 forwarded objects won't work right. */
1649 { 1661 {
1650 Lisp_Object *pvalbuf, buf; 1662 Lisp_Object *pvalbuf, buf;
1651 valcontents = SYMBOL_VALUE (variable); 1663 valcontents = sym->value;
1652 pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer; 1664 pvalbuf = &XBUFFER_LOCAL_VALUE (valcontents)->buffer;
1653 XSETBUFFER (buf, current_buffer); 1665 XSETBUFFER (buf, current_buffer);
1654 if (EQ (buf, *pvalbuf)) 1666 if (EQ (buf, *pvalbuf))
1655 { 1667 {
1656 *pvalbuf = Qnil; 1668 *pvalbuf = Qnil;
1683 Buffer-local bindings take precedence over frame-local bindings. */) 1695 Buffer-local bindings take precedence over frame-local bindings. */)
1684 (variable) 1696 (variable)
1685 register Lisp_Object variable; 1697 register Lisp_Object variable;
1686 { 1698 {
1687 register Lisp_Object tem, valcontents, newval; 1699 register Lisp_Object tem, valcontents, newval;
1700 struct Lisp_Symbol *sym;
1688 1701
1689 CHECK_SYMBOL (variable); 1702 CHECK_SYMBOL (variable);
1690 variable = indirect_variable (variable); 1703 sym = indirect_variable (XSYMBOL (variable));
1691 1704
1692 valcontents = SYMBOL_VALUE (variable); 1705 valcontents = sym->value;
1693 if (XSYMBOL (variable)->constant || KBOARD_OBJFWDP (valcontents) 1706 if (sym->constant || KBOARD_OBJFWDP (valcontents)
1694 || BUFFER_OBJFWDP (valcontents)) 1707 || BUFFER_OBJFWDP (valcontents))
1695 error ("Symbol %s may not be frame-local", SDATA (SYMBOL_NAME (variable))); 1708 error ("Symbol %s may not be frame-local", SDATA (sym->xname));
1696 1709
1697 if (BUFFER_LOCAL_VALUEP (valcontents)) 1710 if (BUFFER_LOCAL_VALUEP (valcontents))
1698 { 1711 {
1699 XBUFFER_LOCAL_VALUE (valcontents)->check_frame = 1; 1712 XBUFFER_LOCAL_VALUE (valcontents)->check_frame = 1;
1700 return variable; 1713 return variable;
1701 } 1714 }
1702 1715
1703 if (EQ (valcontents, Qunbound)) 1716 if (EQ (valcontents, Qunbound))
1704 SET_SYMBOL_VALUE (variable, Qnil); 1717 sym->value = Qnil;
1705 tem = Fcons (Qnil, Fsymbol_value (variable)); 1718 tem = Fcons (Qnil, Fsymbol_value (variable));
1706 XSETCAR (tem, tem); 1719 XSETCAR (tem, tem);
1707 newval = allocate_misc (); 1720 newval = allocate_misc ();
1708 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; 1721 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
1709 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); 1722 XBUFFER_LOCAL_VALUE (newval)->realvalue = sym->value;
1710 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil; 1723 XBUFFER_LOCAL_VALUE (newval)->buffer = Qnil;
1711 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil; 1724 XBUFFER_LOCAL_VALUE (newval)->frame = Qnil;
1712 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0; 1725 XBUFFER_LOCAL_VALUE (newval)->local_if_set = 0;
1713 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0; 1726 XBUFFER_LOCAL_VALUE (newval)->found_for_buffer = 0;
1714 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0; 1727 XBUFFER_LOCAL_VALUE (newval)->found_for_frame = 0;
1715 XBUFFER_LOCAL_VALUE (newval)->check_frame = 1; 1728 XBUFFER_LOCAL_VALUE (newval)->check_frame = 1;
1716 XBUFFER_LOCAL_VALUE (newval)->cdr = tem; 1729 XBUFFER_LOCAL_VALUE (newval)->cdr = tem;
1717 SET_SYMBOL_VALUE (variable, newval); 1730 sym->value = newval;
1718 return variable; 1731 return variable;
1719 } 1732 }
1720 1733
1721 DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p, 1734 DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p,
1722 1, 2, 0, 1735 1, 2, 0,
1725 (variable, buffer) 1738 (variable, buffer)
1726 register Lisp_Object variable, buffer; 1739 register Lisp_Object variable, buffer;
1727 { 1740 {
1728 Lisp_Object valcontents; 1741 Lisp_Object valcontents;
1729 register struct buffer *buf; 1742 register struct buffer *buf;
1743 struct Lisp_Symbol *sym;
1730 1744
1731 if (NILP (buffer)) 1745 if (NILP (buffer))
1732 buf = current_buffer; 1746 buf = current_buffer;
1733 else 1747 else
1734 { 1748 {
1735 CHECK_BUFFER (buffer); 1749 CHECK_BUFFER (buffer);
1736 buf = XBUFFER (buffer); 1750 buf = XBUFFER (buffer);
1737 } 1751 }
1738 1752
1739 CHECK_SYMBOL (variable); 1753 CHECK_SYMBOL (variable);
1740 variable = indirect_variable (variable); 1754 sym = indirect_variable (XSYMBOL (variable));
1741 1755 XSETSYMBOL (variable, sym);
1742 valcontents = SYMBOL_VALUE (variable); 1756
1757 valcontents = sym->value;
1743 if (BUFFER_LOCAL_VALUEP (valcontents)) 1758 if (BUFFER_LOCAL_VALUEP (valcontents))
1744 { 1759 {
1745 Lisp_Object tail, elt; 1760 Lisp_Object tail, elt;
1746 1761
1747 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) 1762 for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
1772 (variable, buffer) 1787 (variable, buffer)
1773 register Lisp_Object variable, buffer; 1788 register Lisp_Object variable, buffer;
1774 { 1789 {
1775 Lisp_Object valcontents; 1790 Lisp_Object valcontents;
1776 register struct buffer *buf; 1791 register struct buffer *buf;
1792 struct Lisp_Symbol *sym;
1777 1793
1778 if (NILP (buffer)) 1794 if (NILP (buffer))
1779 buf = current_buffer; 1795 buf = current_buffer;
1780 else 1796 else
1781 { 1797 {
1782 CHECK_BUFFER (buffer); 1798 CHECK_BUFFER (buffer);
1783 buf = XBUFFER (buffer); 1799 buf = XBUFFER (buffer);
1784 } 1800 }
1785 1801
1786 CHECK_SYMBOL (variable); 1802 CHECK_SYMBOL (variable);
1787 variable = indirect_variable (variable); 1803 sym = indirect_variable (XSYMBOL (variable));
1788 1804 XSETSYMBOL (variable, sym);
1789 valcontents = SYMBOL_VALUE (variable); 1805
1806 valcontents = sym->value;
1790 1807
1791 if (BUFFER_OBJFWDP (valcontents)) 1808 if (BUFFER_OBJFWDP (valcontents))
1792 /* All these slots become local if they are set. */ 1809 /* All these slots become local if they are set. */
1793 return Qt; 1810 return Qt;
1794 else if (BUFFER_LOCAL_VALUEP (valcontents)) 1811 else if (BUFFER_LOCAL_VALUEP (valcontents))
1814 If the current binding is global (the default), the value is nil. */) 1831 If the current binding is global (the default), the value is nil. */)
1815 (variable) 1832 (variable)
1816 register Lisp_Object variable; 1833 register Lisp_Object variable;
1817 { 1834 {
1818 Lisp_Object valcontents; 1835 Lisp_Object valcontents;
1836 struct Lisp_Symbol *sym;
1819 1837
1820 CHECK_SYMBOL (variable); 1838 CHECK_SYMBOL (variable);
1821 variable = indirect_variable (variable); 1839 sym = indirect_variable (XSYMBOL (variable));
1822 1840
1823 /* Make sure the current binding is actually swapped in. */ 1841 /* Make sure the current binding is actually swapped in. */
1824 find_symbol_value (variable); 1842 find_symbol_value (variable);
1825 1843
1826 valcontents = XSYMBOL (variable)->value; 1844 valcontents = sym->value;
1827 1845
1828 if (BUFFER_LOCAL_VALUEP (valcontents) 1846 if (BUFFER_LOCAL_VALUEP (valcontents)
1829 || BUFFER_OBJFWDP (valcontents)) 1847 || BUFFER_OBJFWDP (valcontents))
1830 { 1848 {
1831 /* For a local variable, record both the symbol and which 1849 /* For a local variable, record both the symbol and which