From f475b75a5e9f2eb0fd6d83f502f98d1607b3e7a9 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 3 Nov 2002 08:58:49 +0000 Subject: [PATCH] (adjust_point_for_property): Handle `display' prop on overlays. Also handle `invisible' prop. --- src/keyboard.c | 62 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 726f8354156..c0afb84c3c4 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1785,47 +1785,67 @@ extern Lisp_Object Qcomposition, Qdisplay; /* Adjust point to a boundary of a region that has such a property that should be treated intangible. For the moment, we check - `composition' and `display' property. LAST_PT is the last position - of point. */ + `composition', `display' and `invisible' properties. + LAST_PT is the last position of point. */ static void adjust_point_for_property (last_pt) int last_pt; { - int start, end; - Lisp_Object val; - int check_composition = 1, check_display = 1; + int beg, end; + Lisp_Object val, overlay, tmp; + int check_composition = 1, check_display = 1, check_invisible = 1; - while (check_composition || check_display) + while (check_composition || check_display || check_invisible) { if (check_composition && PT > BEGV && PT < ZV - && get_property_and_range (PT, Qcomposition, &val, &start, &end, Qnil) - && COMPOSITION_VALID_P (start, end, val) - && start < PT && end > PT - && (last_pt <= start || last_pt >= end)) + && get_property_and_range (PT, Qcomposition, &val, &beg, &end, Qnil) + && COMPOSITION_VALID_P (beg, end, val) + && beg < PT /* && end > PT <- It's always the case. */ + && (last_pt <= beg || last_pt >= end)) { - if (PT < last_pt) - SET_PT (start); - else - SET_PT (end); + SET_PT (PT < last_pt ? beg : end); check_display = 1; + check_invisible = 1; } check_composition = 0; if (check_display && PT > BEGV && PT < ZV - && get_property_and_range (PT, Qdisplay, &val, &start, &end, Qnil) + && !NILP (val = get_char_property_and_overlay + (make_number (PT), Qdisplay, Qnil, &overlay)) && display_prop_intangible_p (val) - && start < PT && end > PT - && (last_pt <= start || last_pt >= end)) + && (!OVERLAYP (overlay) + ? get_property_and_range (PT, Qdisplay, &val, &beg, &end, Qnil) + : (beg = OVERLAY_POSITION (OVERLAY_START (overlay)), + end = OVERLAY_POSITION (OVERLAY_END (overlay)))) + && beg < PT /* && end > PT <- It's always the case. */ + && (last_pt <= beg || last_pt >= end)) { - if (PT < last_pt) - SET_PT (start); - else - SET_PT (end); + SET_PT (PT < last_pt ? beg : end); check_composition = 1; + check_invisible = 1; } check_display = 0; + if (check_invisible + && PT > BEGV && PT < ZV + && !NILP (val = get_char_property_and_overlay + (make_number (PT), Qinvisible, Qnil, &overlay)) + && TEXT_PROP_MEANS_INVISIBLE (val) + && (tmp = Fprevious_single_char_property_change + (make_number (PT + 1), Qinvisible, Qnil, Qnil), + beg = NILP (tmp) ? BEGV : XFASTINT (tmp), + beg < PT) + && (tmp = Fnext_single_char_property_change + (make_number (PT), Qinvisible, Qnil, Qnil), + end = NILP (tmp) ? BEGV : XFASTINT (tmp), + (last_pt <= beg || last_pt >= end))) + { + SET_PT (PT < last_pt ? beg : end); + check_composition = 1; + check_display = 1; + } + check_invisible = 0; } } -- 2.11.4.GIT