aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1996-12-15 04:58:53 +0000
committerRichard M. Stallman1996-12-15 04:58:53 +0000
commit580fae94036d113bdbbf83318221b91279061f09 (patch)
tree5da821f7e0fe20e62f0568a393b2ac51daa4836f /src
parentfcab51aabb2075da6edc18d91c221b23b77f5e8f (diff)
downloademacs-580fae94036d113bdbbf83318221b91279061f09.tar.gz
emacs-580fae94036d113bdbbf83318221b91279061f09.zip
(set_point): Check for intangible properties on overlays.
Diffstat (limited to 'src')
-rw-r--r--src/intervals.c97
1 files changed, 55 insertions, 42 deletions
diff --git a/src/intervals.c b/src/intervals.c
index 0cc28ac2751..cdfbc5a7e69 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1588,8 +1588,10 @@ set_point (position, buffer)
1588 register INTERVAL to, from, toprev, fromprev, target; 1588 register INTERVAL to, from, toprev, fromprev, target;
1589 int buffer_point; 1589 int buffer_point;
1590 register Lisp_Object obj; 1590 register Lisp_Object obj;
1591 int backwards = (position < BUF_PT (buffer)) ? 1 : 0;
1592 int old_position = BUF_PT (buffer); 1591 int old_position = BUF_PT (buffer);
1592 int backwards = (position < old_position ? 1 : 0);
1593 int have_overlays;
1594 int original_position;
1593 1595
1594 buffer->point_before_scroll = Qnil; 1596 buffer->point_before_scroll = Qnil;
1595 1597
@@ -1602,9 +1604,13 @@ set_point (position, buffer)
1602 if (position > BUF_Z (buffer) || position < BUF_BEG (buffer)) 1604 if (position > BUF_Z (buffer) || position < BUF_BEG (buffer))
1603 abort (); 1605 abort ();
1604 1606
1605 if (NULL_INTERVAL_P (BUF_INTERVALS (buffer))) 1607 have_overlays = (! NILP (buffer->overlays_before)
1608 || ! NILP (buffer->overlays_after));
1609
1610 /* If we have no text properties and overlays,
1611 then we can do it quickly. */
1612 if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) && ! have_overlays)
1606 { 1613 {
1607
1608 BUF_PT (buffer) = position; 1614 BUF_PT (buffer) = position;
1609 return; 1615 return;
1610 } 1616 }
@@ -1615,7 +1621,7 @@ set_point (position, buffer)
1615 to = find_interval (BUF_INTERVALS (buffer), position); 1621 to = find_interval (BUF_INTERVALS (buffer), position);
1616 if (position == BUF_BEGV (buffer)) 1622 if (position == BUF_BEGV (buffer))
1617 toprev = 0; 1623 toprev = 0;
1618 else if (to->position == position) 1624 else if (to && to->position == position)
1619 toprev = previous_interval (to); 1625 toprev = previous_interval (to);
1620 else 1626 else
1621 toprev = to; 1627 toprev = to;
@@ -1631,7 +1637,7 @@ set_point (position, buffer)
1631 from = find_interval (BUF_INTERVALS (buffer), buffer_point); 1637 from = find_interval (BUF_INTERVALS (buffer), buffer_point);
1632 if (buffer_point == BUF_BEGV (buffer)) 1638 if (buffer_point == BUF_BEGV (buffer))
1633 fromprev = 0; 1639 fromprev = 0;
1634 else if (from->position == BUF_PT (buffer)) 1640 else if (from && from->position == BUF_PT (buffer))
1635 fromprev = previous_interval (from); 1641 fromprev = previous_interval (from);
1636 else if (buffer_point != BUF_PT (buffer)) 1642 else if (buffer_point != BUF_PT (buffer))
1637 fromprev = from, from = 0; 1643 fromprev = from, from = 0;
@@ -1639,64 +1645,71 @@ set_point (position, buffer)
1639 fromprev = from; 1645 fromprev = from;
1640 1646
1641 /* Moving within an interval. */ 1647 /* Moving within an interval. */
1642 if (to == from && toprev == fromprev && INTERVAL_VISIBLE_P (to)) 1648 if (to == from && toprev == fromprev && INTERVAL_VISIBLE_P (to)
1649 && ! have_overlays)
1643 { 1650 {
1644 BUF_PT (buffer) = position; 1651 BUF_PT (buffer) = position;
1645 return; 1652 return;
1646 } 1653 }
1647 1654
1655 original_position = position;
1656
1648 /* If the new position is between two intangible characters 1657 /* If the new position is between two intangible characters
1649 with the same intangible property value, 1658 with the same intangible property value,
1650 move forward or backward until a change in that property. */ 1659 move forward or backward until a change in that property. */
1651 if (NILP (Vinhibit_point_motion_hooks) && ! NULL_INTERVAL_P (to) 1660 if (NILP (Vinhibit_point_motion_hooks)
1652 && ! NULL_INTERVAL_P (toprev)) 1661 && ((! NULL_INTERVAL_P (to) && ! NULL_INTERVAL_P (toprev))
1662 || have_overlays))
1653 { 1663 {
1664 Lisp_Object intangible_propval;
1665 Lisp_Object pos;
1666
1667 XSETINT (pos, position);
1668
1654 if (backwards) 1669 if (backwards)
1655 { 1670 {
1656 Lisp_Object intangible_propval; 1671 intangible_propval = Fget_char_property (make_number (position),
1657 intangible_propval = textget (to->plist, Qintangible); 1672 Qintangible, Qnil);
1658 1673
1659 /* If following char is intangible, 1674 /* If following char is intangible,
1660 skip back over all chars with matching intangible property. */ 1675 skip back over all chars with matching intangible property. */
1661 if (! NILP (intangible_propval)) 1676 if (! NILP (intangible_propval))
1662 while (to == toprev 1677 while (XINT (pos) > BUF_BEGV (buffer)
1663 || ((! NULL_INTERVAL_P (toprev) 1678 && EQ (Fget_char_property (make_number (XINT (pos) - 1),
1664 && EQ (textget (toprev->plist, Qintangible), 1679 Qintangible, Qnil),
1665 intangible_propval)))) 1680 intangible_propval))
1666 { 1681 pos = Fprevious_char_property_change (pos, Qnil);
1667 to = toprev;
1668 toprev = previous_interval (toprev);
1669 if (NULL_INTERVAL_P (toprev))
1670 position = BUF_BEGV (buffer);
1671 else
1672 /* This is the only line that's not
1673 dual to the following loop.
1674 That's because we want the position
1675 at the end of TOPREV. */
1676 position = to->position;
1677 }
1678 } 1682 }
1679 else 1683 else
1680 { 1684 {
1681 Lisp_Object intangible_propval; 1685 intangible_propval = Fget_char_property (make_number (position - 1),
1682 intangible_propval = textget (toprev->plist, Qintangible); 1686 Qintangible, Qnil);
1683 1687
1684 /* If previous char is intangible, 1688 /* If following char is intangible,
1685 skip fwd over all chars with matching intangible property. */ 1689 skip back over all chars with matching intangible property. */
1686 if (! NILP (intangible_propval)) 1690 if (! NILP (intangible_propval))
1687 while (to == toprev 1691 while (XINT (pos) < BUF_ZV (buffer)
1688 || ((! NULL_INTERVAL_P (to) 1692 && EQ (Fget_char_property (pos, Qintangible, Qnil),
1689 && EQ (textget (to->plist, Qintangible), 1693 intangible_propval))
1690 intangible_propval)))) 1694 pos = Fnext_char_property_change (pos, Qnil);
1691 { 1695
1692 toprev = to;
1693 to = next_interval (to);
1694 if (NULL_INTERVAL_P (to))
1695 position = BUF_ZV (buffer);
1696 else
1697 position = to->position;
1698 }
1699 } 1696 }
1697
1698 position = XINT (pos);
1699 }
1700
1701 if (position != original_position)
1702 {
1703 /* Set TO to the interval containing the char after POSITION,
1704 and TOPREV to the interval containing the char before POSITION.
1705 Either one may be null. They may be equal. */
1706 to = find_interval (BUF_INTERVALS (buffer), position);
1707 if (position == BUF_BEGV (buffer))
1708 toprev = 0;
1709 else if (to && to->position == position)
1710 toprev = previous_interval (to);
1711 else
1712 toprev = to;
1700 } 1713 }
1701 1714
1702 /* Here TO is the interval after the stopping point 1715 /* Here TO is the interval after the stopping point