Subject: Re: bug#14780: Regression: C-n doesn't go to next line under simple circumstances

From: Eli Zaretskii <[email-masked]>
Date: Sat, 20 Jul 2013 11:33:07 +0300

Does the following fix the problem for you?

=== modified file 'src/xdisp.c'
--- src/xdisp.c	2013-07-16 21:35:45 +0000
+++ src/xdisp.c	2013-07-20 08:21:36 +0000
@@ -15592,7 +15592,8 @@ redisplay_window (Lisp_Object window, in
 	     Move it back to a fully-visible line.  */
 	  new_vpos = window_box_height (w);
 	}
-      else if (w->cursor.vpos >=0)
+      else if (w->cursor.vpos >=0
+	       && PT >= BEGV && PT < ZV)
 	{
 	  /* Some people insist on not letting point enter the scroll
 	     margin, even though this part handles windows that didn't
@@ -15619,7 +15620,16 @@ redisplay_window (Lisp_Object window, in
 	      if (header_line)
 		window_height += CURRENT_HEADER_LINE_HEIGHT (w);
 	      if (w->cursor.y >= window_height - pixel_margin)
-		new_vpos = window_height - pixel_margin;
+		{
+		  struct text_pos pos;
+
+		  SET_TEXT_POS (pos, PT, PT_BYTE);
+		  start_display (&it, w, pos);
+		  it.current_y = it.vpos = 0;
+		  move_it_to (&it, ZV, -1, -1, -1, MOVE_TO_POS);
+		  if (it.vpos > margin)
+		    new_vpos = window_height - pixel_margin;
+		}
 	    }
 	}