1 |
/* Interface code for dealing with text properties. |
/* Interface code for dealing with text properties. |
2 |
Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001 |
Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002 |
3 |
Free Software Foundation, Inc. |
Free Software Foundation, Inc. |
4 |
|
|
5 |
This file is part of GNU Emacs. |
This file is part of GNU Emacs. |
1554 |
} |
} |
1555 |
return Qnil; |
return Qnil; |
1556 |
} |
} |
1557 |
|
|
1558 |
|
|
1559 |
|
/* Return the direction from which the text-property PROP would be |
1560 |
|
inherited by any new text inserted at POS: 1 if it would be |
1561 |
|
inherited from the char after POS, -1 if it would be inherited from |
1562 |
|
the char before POS, and 0 if from neither. */ |
1563 |
|
|
1564 |
|
int |
1565 |
|
text_property_stickiness (prop, pos) |
1566 |
|
Lisp_Object prop; |
1567 |
|
Lisp_Object pos; |
1568 |
|
{ |
1569 |
|
Lisp_Object prev_pos, front_sticky; |
1570 |
|
int is_rear_sticky = 1, is_front_sticky = 0; /* defaults */ |
1571 |
|
|
1572 |
|
if (XINT (pos) > BEGV) |
1573 |
|
/* Consider previous character. */ |
1574 |
|
{ |
1575 |
|
Lisp_Object rear_non_sticky; |
1576 |
|
|
1577 |
|
prev_pos = make_number (XINT (pos) - 1); |
1578 |
|
rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil); |
1579 |
|
|
1580 |
|
if (!NILP (CONSP (rear_non_sticky) |
1581 |
|
? Fmemq (prop, rear_non_sticky) |
1582 |
|
: rear_non_sticky)) |
1583 |
|
/* PROP is rear-non-sticky. */ |
1584 |
|
is_rear_sticky = 0; |
1585 |
|
} |
1586 |
|
|
1587 |
|
/* Consider following character. */ |
1588 |
|
front_sticky = Fget_text_property (pos, Qfront_sticky, Qnil); |
1589 |
|
|
1590 |
|
if (EQ (front_sticky, Qt) |
1591 |
|
|| (CONSP (front_sticky) |
1592 |
|
&& !NILP (Fmemq (prop, front_sticky)))) |
1593 |
|
/* PROP is inherited from after. */ |
1594 |
|
is_front_sticky = 1; |
1595 |
|
|
1596 |
|
/* Simple cases, where the properties are consistent. */ |
1597 |
|
if (is_rear_sticky && !is_front_sticky) |
1598 |
|
return -1; |
1599 |
|
else if (!is_rear_sticky && is_front_sticky) |
1600 |
|
return 1; |
1601 |
|
else if (!is_rear_sticky && !is_front_sticky) |
1602 |
|
return 0; |
1603 |
|
|
1604 |
|
/* The stickiness properties are inconsistent, so we have to |
1605 |
|
disambiguate. Basically, rear-sticky wins, _except_ if the |
1606 |
|
property that would be inherited has a value of nil, in which case |
1607 |
|
front-sticky wins. */ |
1608 |
|
if (XINT (pos) == BEGV || NILP (Fget_text_property (prev_pos, prop, Qnil))) |
1609 |
|
return 1; |
1610 |
|
else |
1611 |
|
return -1; |
1612 |
|
} |
1613 |
|
|
1614 |
|
|
1615 |
/* I don't think this is the right interface to export; how often do you |
/* I don't think this is the right interface to export; how often do you |
1616 |
want to do something like this, other than when you're copying objects |
want to do something like this, other than when you're copying objects |