Subject: bug#3396: next-line and previous-line do not work correctly near long lines

From: "Shannon Jones" <[email-masked]>
Date: 27 May 2009 01:13:30 -0000

This is similar to bug#3386 posted by Heinrich Rommerskirchen.  It's somewhat different, so I decided to post a new bug report.

* Emacs version: GNU Emacs 23.0.94.1 (i686-pc-linux-gnu, GTK+ Version 2.10.4) of 2009-05-26

Also reproduced on 23.0.94.1 on Windows.

* Compiled on CentOS 5.3.

* No options given to configure

* To reproduce:

Run: emacs -Q (happens with or without -nw)
C-x b *scratch*
C-u 1000 X
<RET>

This will put 1000 X's on the screen and the cursor will be on the line below them.  The line of X's should wrap over several lines of the screen with continuation marks at the end of each line.

Hit C-p. This *should* put the cursor at the beginning of the line of X's.  Instead, it puts the cursor at the left column on the screen, but somewhere in the middle of the line of X's.  Hitting C-p again a few times moves the cursor somewhere else on the line, but still at the left-most column. Hitting C-n now should move you to the beginning of the next physical line (the blank one after the X's), but instead moves you somewhere else on the line of X's (but still in the first column).

In other words, next-line and previous-line should move relative to physical lines in the file, but are instead moving relative to lines on the screen.  Changing the screen width changes the behavior of C-n and C-p when the lines are long enough to wrap.

This is different from Emacs 22.  I noticed this when writing macros that do something to one line, then move to the next line at the end macro to prepare for the next run.  The macro failed on lines that were longer than my screen width.