# HG changeset patch # User Richard M. Stallman # Date 1009516362 0 # Node ID 3af09e7320c005b0afbcbb2b351b97eeff93de67 # Parent c66f34e7d2cd94b278b0879de8e727208c1d9af6 (set_point_both): The position after an invisible, intangible character is not an acceptable stopping point. diff -r c66f34e7d2cd -r 3af09e7320c0 src/intervals.c --- a/src/intervals.c Fri Dec 28 03:10:33 2001 +0000 +++ b/src/intervals.c Fri Dec 28 05:12:42 2001 +0000 @@ -1975,38 +1975,69 @@ or end of the buffer, so don't bother checking in that case. */ && charpos != BEGV && charpos != ZV) { - Lisp_Object intangible_propval; + Lisp_Object intangible_propval, invisible_propval; Lisp_Object pos; + int invis_p; XSETINT (pos, charpos); if (backwards) { - intangible_propval = Fget_char_property (make_number (charpos), - Qintangible, Qnil); + /* If the preceding char is both invisible and intangible, + start backing up from just before that one. */ + + intangible_propval + = Fget_char_property (make_number (charpos - 1), + Qintangible, Qnil); + invisible_propval + = Fget_char_property (make_number (charpos - 1), Qinvisible, Qnil); + invis_p = TEXT_PROP_MEANS_INVISIBLE (invisible_propval); + + if (! NILP (intangible_propval) && invis_p) + XSETINT (pos, --charpos); /* If following char is intangible, skip back over all chars with matching intangible property. */ + + intangible_propval = Fget_char_property (pos, Qintangible, Qnil); + if (! NILP (intangible_propval)) - while (XINT (pos) > BUF_BEGV (buffer) - && EQ (Fget_char_property (make_number (XINT (pos) - 1), - Qintangible, Qnil), - intangible_propval)) - pos = Fprevious_char_property_change (pos, Qnil); + { + while (XINT (pos) > BUF_BEGV (buffer) + && EQ (Fget_char_property (make_number (XINT (pos) - 1), + Qintangible, Qnil), + intangible_propval)) + pos = Fprevious_char_property_change (pos, Qnil); + } } else { + /* If preceding char is intangible, + skip forward over all chars with matching intangible property. */ + intangible_propval = Fget_char_property (make_number (charpos - 1), Qintangible, Qnil); - /* If following char is intangible, - skip forward over all chars with matching intangible property. */ if (! NILP (intangible_propval)) - while (XINT (pos) < BUF_ZV (buffer) - && EQ (Fget_char_property (pos, Qintangible, Qnil), - intangible_propval)) - pos = Fnext_char_property_change (pos, Qnil); + { + while (XINT (pos) < BUF_ZV (buffer) + && EQ (Fget_char_property (pos, Qintangible, Qnil), + intangible_propval)) + pos = Fnext_char_property_change (pos, Qnil); + + /* Is the last one invisible as well as intangible? */ + invisible_propval + = Fget_char_property (make_number (XINT (pos) - 1), + Qinvisible, Qnil); + invis_p = TEXT_PROP_MEANS_INVISIBLE (invisible_propval); + + /* If so, advance one character more: + don't stop after an invisible, intangible character. */ + + if (invis_p && XINT (pos) < BUF_ZV (buffer)) + XSETINT (pos, XINT (pos) + 1); + } } charpos = XINT (pos);