diff --git a/src/window.c b/src/window.c index cb8fe5fcdb..a7ad4d5599 100644 --- a/src/window.c +++ b/src/window.c @@ -2172,6 +2172,10 @@ DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, first. POS defaults to point in WINDOW; WINDOW defaults to the selected window. +Do not pass nil as POS unless you are sure that WINDOW displays the +current buffer. This function will emit a warning when POS is neither a +marker, a number or t and WINDOW does not display the current buffer. + If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, the return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), where X and Y are the pixel coordinates relative to the top left corner @@ -2199,10 +2203,16 @@ DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, posint = -1; else if (!NILP (pos)) posint = fix_position (pos); - else if (w == XWINDOW (selected_window)) - posint = PT; else - posint = marker_position (w->pointm); + { + if (XBUFFER (w->contents) != current_buffer) + message ("`pos-visible-in-window' called with POS nil but WINDOW's buffer is not current"); + + if (w == XWINDOW (selected_window)) + posint = PT; + else + posint = marker_position (w->pointm); + } /* If position is above window start or outside buffer boundaries, or if window start is out of range, position is not visible. */