=== modified file 'src/xdisp.c' --- src/xdisp.c 2012-11-30 09:23:15 +0000 +++ src/xdisp.c 2012-11-30 15:45:36 +0000 @@ -10906,6 +10906,7 @@ static int window_outdated (struct window *w) { + eassert (XBUFFER (w->buffer) == current_buffer); return (w->last_modified < MODIFF || w->last_overlay_modified < OVERLAY_MODIFF); } @@ -12917,6 +12918,8 @@ static void reconsider_clip_changes (struct window *w, struct buffer *b) { + eassert (XBUFFER (w->buffer) == b); + if (b->clip_changed && !NILP (w->window_end_valid) && w->current_matrix->buffer == b @@ -12924,13 +12927,11 @@ && w->current_matrix->begv == BUF_BEGV (b)) b->clip_changed = 0; - /* If display wasn't paused, and W is not a tool bar window, see if - point has been moved into or out of a composition. In that case, - we set b->clip_changed to 1 to force updating the screen. If - b->clip_changed has already been set to 1, we can skip this - check. */ - if (!b->clip_changed - && BUFFERP (w->buffer) && !NILP (w->window_end_valid)) + /* If display wasn't paused, see if point has been moved into or + out of a composition. In that case, we set b->clip_changed + to 1 to force updating the screen. If b->clip_changed has + already been set to 1, we can skip this check. */ + if (!b->clip_changed && !NILP (w->window_end_valid)) { ptrdiff_t pt; @@ -13079,6 +13080,10 @@ may need to run Elisp code (via prepare_menu_bars). */ ensure_selected_frame (old_frame); + if (XBUFFER (w->buffer) != current_buffer) + /* Out of sync, do nothing. */ + goto end_of_redisplay; + pending = 0; reconsider_clip_changes (w, current_buffer); last_escape_glyph_frame = NULL; @@ -13136,10 +13141,7 @@ /* do_pending_window_change could change the selected_window due to frame resizing which makes the selected window too small. */ if (WINDOWP (selected_window) && (w = XWINDOW (selected_window)) != sw) - { - sw = w; - reconsider_clip_changes (w, current_buffer); - } + goto retry; /* Clear frames marked as garbaged. */ clear_garbaged_frames ();