# HG changeset patch # User Chong Yidong # Date 1274974970 14400 # Node ID 4236cb683dbbeabb7f5275cad0f957c6eb972a52 # Parent c1945e85d4b95e3c56f6e0c66931db65097ee78b * xdisp.c (redisplay_window): After redisplay, check if point is still valid before setting it (Bug#6177). diff -r c1945e85d4b9 -r 4236cb683dbb src/ChangeLog --- a/src/ChangeLog Thu May 27 11:25:58 2010 -0400 +++ b/src/ChangeLog Thu May 27 11:42:50 2010 -0400 @@ -1,3 +1,8 @@ +2010-05-27 Chong Yidong + + * xdisp.c (redisplay_window): After redisplay, check if point is + still valid before setting it (Bug#6177). + 2010-05-20 enami tsugutomo * s/netbsd.h: If terminfo is found, use it in preference to diff -r c1945e85d4b9 -r 4236cb683dbb src/xdisp.c --- a/src/xdisp.c Thu May 27 11:25:58 2010 -0400 +++ b/src/xdisp.c Thu May 27 11:42:50 2010 -0400 @@ -13936,8 +13936,16 @@ (*FRAME_TERMINAL (f)->redeem_scroll_bar_hook) (w); } - /* Restore current_buffer and value of point in it. */ - TEMP_SET_PT_BOTH (CHARPOS (opoint), BYTEPOS (opoint)); + /* Restore current_buffer and value of point in it. The window + update may have changed the buffer, so first make sure `opoint' + is still valid (Bug#6177). */ + if (CHARPOS (opoint) < BEGV) + TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); + else if (CHARPOS (opoint) > ZV) + TEMP_SET_PT_BOTH (Z, Z_BYTE); + else + TEMP_SET_PT_BOTH (CHARPOS (opoint), BYTEPOS (opoint)); + set_buffer_internal_1 (old); /* Avoid an abort in TEMP_SET_PT_BOTH if the buffer has become shorter. This can be caused by log truncation in *Messages*. */