# HG changeset patch # User Gerd Moellmann # Date 934850294 0 # Node ID 096b78b6cc2e29f410895cb7803a6a7c574bcdd7 # Parent 8df4e1dd92d731885620f376f29eec10278b2b84 (Fpos_visible_in_window_p): Rewritten. diff -r 8df4e1dd92d7 -r 096b78b6cc2e src/window.c --- a/src/window.c Tue Aug 17 00:37:45 1999 +0000 +++ b/src/window.c Tue Aug 17 00:38:14 1999 +0000 @@ -269,9 +269,10 @@ Lisp_Object pos, window; { register struct window *w; - struct text_pos top; register int posint; register struct buffer *buf; + struct text_pos top; + Lisp_Object in_window; if (NILP (pos)) posint = PT; @@ -282,39 +283,35 @@ } w = decode_window (window); + buf = XBUFFER (w->buffer); SET_TEXT_POS_FROM_MARKER (top, w->start); /* If position above window, it's not visible. */ if (posint < CHARPOS (top)) - return Qnil; - - buf = XBUFFER (w->buffer); - if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf) - && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf)) - { - /* If frame is up to date, - use the info recorded about how much text fit on it. */ - if (posint < BUF_Z (buf) - XFASTINT (w->window_end_pos)) - return Qt; - return Qnil; - } + in_window = Qnil; + else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf) + && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf) + && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos)) + /* If frame is up to date, and POSINT is < window end pos, use + that info. This doesn't work for POSINT == end pos, because + the window end pos is actually the position _after_ the last + char in the window. */ + in_window = Qt; + else if (posint > BUF_ZV (buf)) + in_window = Qnil; + else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf)) + /* If window start is out of range, do something reasonable. */ + in_window = Qnil; else { struct it it; - - if (posint > BUF_ZV (buf)) - return Qnil; - - /* w->start can be out of range. If it is, do something reasonable. */ - if (CHARPOS (top) < BUF_BEGV (buf) - || CHARPOS (top) > BUF_ZV (buf)) - return Qnil; - start_display (&it, w, top); move_it_to (&it, posint, 0, it.last_visible_y, -1, - MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); - return IT_CHARPOS (it) == posint ? Qt : Qnil; + MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); + in_window = IT_CHARPOS (it) == posint ? Qt : Qnil; } + + return in_window; } static struct window *