Mercurial > emacs
changeset 40046:5858ea32e564
(text_property_stickiness): Really fix it this time.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 19 Oct 2001 07:45:58 +0000 |
parents | 887dd5ab45c3 |
children | db75937886de |
files | src/editfns.c |
diffstat | 1 files changed, 29 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/editfns.c Fri Oct 19 07:08:29 2001 +0000 +++ b/src/editfns.c Fri Oct 19 07:45:58 2001 +0000 @@ -352,28 +352,22 @@ Lisp_Object prop; Lisp_Object pos; { - Lisp_Object front_sticky; + Lisp_Object prev_pos, front_sticky; + int is_rear_sticky = 1, is_front_sticky = 0; /* defaults */ if (XINT (pos) > BEGV) /* Consider previous character. */ { - Lisp_Object prev_pos = make_number (XINT (pos) - 1); - - if (! NILP (Fget_text_property (prev_pos, prop, Qnil))) - /* Non-rear-non-stickiness only takes precedence if the - preceding property value is non-nil. */ - { - Lisp_Object rear_non_sticky - = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil); - - if (EQ (rear_non_sticky, Qnil) - || (CONSP (rear_non_sticky) - && NILP (Fmemq (prop, rear_non_sticky)))) - /* PROP is not rear-non-sticky, and since this takes - precedence over any front-stickiness, PROP is inherited - from before. */ - return -1; - } + Lisp_Object rear_non_sticky; + + prev_pos = make_number (XINT (pos) - 1); + rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil); + + if (CONSP (rear_non_sticky) + ? Fmemq (prop, rear_non_sticky) + : !NILP (rear_non_sticky)) + /* PROP is rear-non-sticky. */ + is_rear_sticky = 0; } /* Consider following character. */ @@ -383,10 +377,24 @@ || (CONSP (front_sticky) && !NILP (Fmemq (prop, front_sticky)))) /* PROP is inherited from after. */ + is_front_sticky = 1; + + /* Simple cases, where the properties are consistent. */ + if (is_rear_sticky && !is_front_sticky) + return -1; + else if (!is_rear_sticky && is_front_sticky) return 1; - - /* PROP is not inherited from either side. */ - return 0; + else if (!is_rear_sticky && !is_front_sticky) + return 0; + + /* The stickiness properties are inconsistent, so we have to + disambiguate. Basically, rear-sticky wins, _except_ if the + property that would be inherited has a value of nil, in which case + front-sticky wins. */ + if (XINT (pos) == BEGV || NILP (Fget_text_property (prev_pos, prop, Qnil))) + return 1; + else + return -1; }