]> git.eshelyaron.com Git - emacs.git/commitdiff
* xdisp.c (redisplay_window): After redisplay, check if point is
authorChong Yidong <cyd@stupidchicken.com>
Thu, 27 May 2010 15:42:50 +0000 (11:42 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Thu, 27 May 2010 15:42:50 +0000 (11:42 -0400)
still valid before setting it (Bug#6177).

src/ChangeLog
src/xdisp.c

index ddf73eaf3c5b572b8af5114e7f1e99039ea17b10..a4a9e04187929654edc369989be7c3fd73240081 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-27  Chong Yidong  <cyd@stupidchicken.com>
+
+       * xdisp.c (redisplay_window): After redisplay, check if point is
+       still valid before setting it (Bug#6177).
+
 2010-05-20  enami tsugutomo  <tsugutomo.enami@jp.sony.com>
 
        * s/netbsd.h: If terminfo is found, use it in preference to
index 734b60bc1dd716aefa9d0aa07c1579cd1bae2641..7dcdf19431a62ec7a3f42c9a7bc92c6fb55d1d55 100644 (file)
@@ -13936,8 +13936,16 @@ redisplay_window (window, just_this_one_p)
         (*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*. */