comparison src/textprop.c @ 70129:af8798ce814c

(Fremove_list_of_text_properties): Ensure modify_region is called only when buffer is modified and that signal_after_change is allways called in that case.
author Lars Hansen <larsh@soem.dk>
date Thu, 20 Apr 2006 11:36:50 +0000
parents 3bd95f4f2941
children 182680a57573 72dea2ff0142
comparison
equal deleted inserted replaced
70128:404967fdf7c4 70129:af8798ce814c
1600 i = split_interval_right (unchanged, s - unchanged->position); 1600 i = split_interval_right (unchanged, s - unchanged->position);
1601 copy_properties (unchanged, i); 1601 copy_properties (unchanged, i);
1602 } 1602 }
1603 } 1603 }
1604 1604
1605 if (BUFFERP (object)) 1605 /* We are at the beginning of an interval, with len to scan.
1606 modify_region (XBUFFER (object), XINT (start), XINT (end)); 1606 The flag `modified' records if changes have been made.
1607 1607 When object is a buffer, we must call modify_region before changes are
1608 /* We are at the beginning of an interval, with len to scan */ 1608 made and signal_after_change when we are done.
1609 We call modify_region before calling remove_properties iff modified == 0,
1610 and we call signal_after_change before returning iff modified != 0. */
1609 for (;;) 1611 for (;;)
1610 { 1612 {
1611 if (i == 0) 1613 if (i == 0)
1612 abort (); 1614 abort ();
1613 1615
1614 if (LENGTH (i) >= len) 1616 if (LENGTH (i) >= len)
1615 { 1617 {
1616 if (! interval_has_some_properties_list (properties, i)) 1618 if (! interval_has_some_properties_list (properties, i))
1617 return modified ? Qt : Qnil; 1619 if (modified)
1620 {
1621 if (BUFFERP (object))
1622 signal_after_change (XINT (start), XINT (end) - XINT (start),
1623 XINT (end) - XINT (start));
1624 return Qt;
1625 }
1626 else
1627 return Qnil;
1618 1628
1619 if (LENGTH (i) == len) 1629 if (LENGTH (i) == len)
1620 { 1630 {
1631 if (!modified && BUFFERP (object))
1632 modify_region (XBUFFER (object), XINT (start), XINT (end));
1621 remove_properties (Qnil, properties, i, object); 1633 remove_properties (Qnil, properties, i, object);
1622 if (BUFFERP (object)) 1634 if (BUFFERP (object))
1623 signal_after_change (XINT (start), XINT (end) - XINT (start), 1635 signal_after_change (XINT (start), XINT (end) - XINT (start),
1624 XINT (end) - XINT (start)); 1636 XINT (end) - XINT (start));
1625 return Qt; 1637 return Qt;
1627 1639
1628 /* i has the properties, and goes past the change limit */ 1640 /* i has the properties, and goes past the change limit */
1629 unchanged = i; 1641 unchanged = i;
1630 i = split_interval_left (i, len); 1642 i = split_interval_left (i, len);
1631 copy_properties (unchanged, i); 1643 copy_properties (unchanged, i);
1644 if (!modified && BUFFERP (object))
1645 modify_region (XBUFFER (object), XINT (start), XINT (end));
1632 remove_properties (Qnil, properties, i, object); 1646 remove_properties (Qnil, properties, i, object);
1633 if (BUFFERP (object)) 1647 if (BUFFERP (object))
1634 signal_after_change (XINT (start), XINT (end) - XINT (start), 1648 signal_after_change (XINT (start), XINT (end) - XINT (start),
1635 XINT (end) - XINT (start)); 1649 XINT (end) - XINT (start));
1636 return Qt; 1650 return Qt;
1637 } 1651 }
1638 1652
1653 if (interval_has_some_properties_list (properties, i))
1654 {
1655 if (!modified && BUFFERP (object))
1656 modify_region (XBUFFER (object), XINT (start), XINT (end));
1657 remove_properties (Qnil, properties, i, object);
1658 modified = 1;
1659 }
1639 len -= LENGTH (i); 1660 len -= LENGTH (i);
1640 modified += remove_properties (Qnil, properties, i, object);
1641 i = next_interval (i); 1661 i = next_interval (i);
1642 } 1662 }
1643 } 1663 }
1644 1664
1645 DEFUN ("text-property-any", Ftext_property_any, 1665 DEFUN ("text-property-any", Ftext_property_any,