Mercurial > emacs
comparison src/intervals.c @ 42365:3af09e7320c0
(set_point_both): The position after an invisible, intangible
character is not an acceptable stopping point.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 28 Dec 2001 05:12:42 +0000 |
parents | 52fc7b74e8a1 |
children | 8b2a2bd229c3 |
comparison
equal
deleted
inserted
replaced
42364:c66f34e7d2cd | 42365:3af09e7320c0 |
---|---|
1973 || have_overlays) | 1973 || have_overlays) |
1974 /* Intangibility never stops us from positioning at the beginning | 1974 /* Intangibility never stops us from positioning at the beginning |
1975 or end of the buffer, so don't bother checking in that case. */ | 1975 or end of the buffer, so don't bother checking in that case. */ |
1976 && charpos != BEGV && charpos != ZV) | 1976 && charpos != BEGV && charpos != ZV) |
1977 { | 1977 { |
1978 Lisp_Object intangible_propval; | 1978 Lisp_Object intangible_propval, invisible_propval; |
1979 Lisp_Object pos; | 1979 Lisp_Object pos; |
1980 int invis_p; | |
1980 | 1981 |
1981 XSETINT (pos, charpos); | 1982 XSETINT (pos, charpos); |
1982 | 1983 |
1983 if (backwards) | 1984 if (backwards) |
1984 { | 1985 { |
1985 intangible_propval = Fget_char_property (make_number (charpos), | 1986 /* If the preceding char is both invisible and intangible, |
1986 Qintangible, Qnil); | 1987 start backing up from just before that one. */ |
1988 | |
1989 intangible_propval | |
1990 = Fget_char_property (make_number (charpos - 1), | |
1991 Qintangible, Qnil); | |
1992 invisible_propval | |
1993 = Fget_char_property (make_number (charpos - 1), Qinvisible, Qnil); | |
1994 invis_p = TEXT_PROP_MEANS_INVISIBLE (invisible_propval); | |
1995 | |
1996 if (! NILP (intangible_propval) && invis_p) | |
1997 XSETINT (pos, --charpos); | |
1987 | 1998 |
1988 /* If following char is intangible, | 1999 /* If following char is intangible, |
1989 skip back over all chars with matching intangible property. */ | 2000 skip back over all chars with matching intangible property. */ |
2001 | |
2002 intangible_propval = Fget_char_property (pos, Qintangible, Qnil); | |
2003 | |
1990 if (! NILP (intangible_propval)) | 2004 if (! NILP (intangible_propval)) |
1991 while (XINT (pos) > BUF_BEGV (buffer) | 2005 { |
1992 && EQ (Fget_char_property (make_number (XINT (pos) - 1), | 2006 while (XINT (pos) > BUF_BEGV (buffer) |
1993 Qintangible, Qnil), | 2007 && EQ (Fget_char_property (make_number (XINT (pos) - 1), |
1994 intangible_propval)) | 2008 Qintangible, Qnil), |
1995 pos = Fprevious_char_property_change (pos, Qnil); | 2009 intangible_propval)) |
2010 pos = Fprevious_char_property_change (pos, Qnil); | |
2011 } | |
1996 } | 2012 } |
1997 else | 2013 else |
1998 { | 2014 { |
2015 /* If preceding char is intangible, | |
2016 skip forward over all chars with matching intangible property. */ | |
2017 | |
1999 intangible_propval = Fget_char_property (make_number (charpos - 1), | 2018 intangible_propval = Fget_char_property (make_number (charpos - 1), |
2000 Qintangible, Qnil); | 2019 Qintangible, Qnil); |
2001 | 2020 |
2002 /* If following char is intangible, | |
2003 skip forward over all chars with matching intangible property. */ | |
2004 if (! NILP (intangible_propval)) | 2021 if (! NILP (intangible_propval)) |
2005 while (XINT (pos) < BUF_ZV (buffer) | 2022 { |
2006 && EQ (Fget_char_property (pos, Qintangible, Qnil), | 2023 while (XINT (pos) < BUF_ZV (buffer) |
2007 intangible_propval)) | 2024 && EQ (Fget_char_property (pos, Qintangible, Qnil), |
2008 pos = Fnext_char_property_change (pos, Qnil); | 2025 intangible_propval)) |
2009 | 2026 pos = Fnext_char_property_change (pos, Qnil); |
2027 | |
2028 /* Is the last one invisible as well as intangible? */ | |
2029 | |
2030 invisible_propval | |
2031 = Fget_char_property (make_number (XINT (pos) - 1), | |
2032 Qinvisible, Qnil); | |
2033 invis_p = TEXT_PROP_MEANS_INVISIBLE (invisible_propval); | |
2034 | |
2035 /* If so, advance one character more: | |
2036 don't stop after an invisible, intangible character. */ | |
2037 | |
2038 if (invis_p && XINT (pos) < BUF_ZV (buffer)) | |
2039 XSETINT (pos, XINT (pos) + 1); | |
2040 } | |
2010 } | 2041 } |
2011 | 2042 |
2012 charpos = XINT (pos); | 2043 charpos = XINT (pos); |
2013 bytepos = buf_charpos_to_bytepos (buffer, charpos); | 2044 bytepos = buf_charpos_to_bytepos (buffer, charpos); |
2014 } | 2045 } |