Mercurial > emacs
changeset 59610:14875395f75b
(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.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 18 Jan 2005 00:13:24 +0000 |
parents | ebe61bf4c2a3 |
children | 2595b97b13bd |
files | src/xdisp.c |
diffstat | 1 files changed, 39 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xdisp.c Tue Jan 18 00:13:00 2005 +0000 +++ b/src/xdisp.c Tue Jan 18 00:13:24 2005 +0000 @@ -4573,51 +4573,52 @@ 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) - { - visible_p = 1; + while (IT_CHARPOS (*it) > BEGV) + { + 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; - - /* Check the newline before point for invisibility. */ - prop = Fget_char_property (make_number (IT_CHARPOS (*it) - 1), + continue; + + /* 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 - - /* Back one more newline if the current one is invisible. */ - if (!visible_p) - back_to_previous_line_start (it); + if (TEXT_PROP_MEANS_INVISIBLE (prop)) + continue; + } + + /* 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);