From: Kim F. Storm Date: Tue, 18 Jan 2005 00:13:24 +0000 (+0000) Subject: (back_to_previous_visible_line_start): Undo 2004-12-28 X-Git-Tag: ttn-vms-21-2-B4~2696 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6512b56dff62bbbe8dffad58d7299a7f9e90653a;p=emacs.git (back_to_previous_visible_line_start): Undo 2004-12-28 change. If handle_display_prop indicates newline is replaced by image or text, move back to start of relevant overlay or interval and continue scan from there. Simplify. --- diff --git a/src/xdisp.c b/src/xdisp.c index 2facc873743..bf06bba7df3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4573,51 +4573,52 @@ static void back_to_previous_visible_line_start (it) struct it *it; { - int visible_p = 0; - - /* Go back one newline if not on BEGV already. */ - if (IT_CHARPOS (*it) > BEGV) - back_to_previous_line_start (it); - - /* Move over lines that are invisible because of selective display - or text properties. */ - while (IT_CHARPOS (*it) > BEGV - && !visible_p) + while (IT_CHARPOS (*it) > BEGV) { - visible_p = 1; + back_to_previous_line_start (it); + if (IT_CHARPOS (*it) <= BEGV) + break; /* If selective > 0, then lines indented more than that values are invisible. */ if (it->selective > 0 && indented_beyond_p (IT_CHARPOS (*it), IT_BYTEPOS (*it), (double) it->selective)) /* iftc */ - visible_p = 0; - else - { - Lisp_Object prop; + continue; - /* Check the newline before point for invisibility. */ - prop = Fget_char_property (make_number (IT_CHARPOS (*it) - 1), + /* Check the newline before point for invisibility. */ + { + Lisp_Object prop; + prop = Fget_char_property (make_number (IT_CHARPOS (*it) - 1), Qinvisible, it->window); - if (TEXT_PROP_MEANS_INVISIBLE (prop)) - visible_p = 0; - } - -#if 0 - /* Commenting this out fixes the bug described in - http://www.math.ku.dk/~larsh/emacs/emacs-loops-on-large-images/test-case.txt. */ - if (visible_p) - { - struct it it2 = *it; - - if (handle_display_prop (&it2) == HANDLED_RETURN) - visible_p = 0; - } -#endif + if (TEXT_PROP_MEANS_INVISIBLE (prop)) + continue; + } - /* Back one more newline if the current one is invisible. */ - if (!visible_p) - back_to_previous_line_start (it); + /* If newline has a display property that replaces the newline with something + else (image or text), find start of overlay or interval and continue search + from that point. */ + { + struct it it2 = *it; + int pos = IT_CHARPOS (*it); + int beg, end; + Lisp_Object val, overlay; + + if (handle_display_prop (&it2) == HANDLED_RETURN + && !NILP (val = get_char_property_and_overlay + (make_number (pos), Qdisplay, Qnil, &overlay)) + && (OVERLAYP (overlay) + ? (beg = OVERLAY_POSITION (OVERLAY_START (overlay))) + : get_property_and_range (pos, Qdisplay, &val, &beg, &end, Qnil))) + { + if (beg < BEGV) + beg = BEGV; + IT_CHARPOS (*it) = beg; + IT_BYTEPOS (*it) = buf_charpos_to_bytepos (current_buffer, beg); + continue; + } + } + break; } xassert (IT_CHARPOS (*it) >= BEGV);