Subject: bug#52163: 28.0.60; visual-line-mode breaks C-a and C-e in extreme case

From: Phil Sainty <[email-masked]>
Date: Sun, 16 Jan 2022 11:53:21 +1300

> Eli Zaretskii <[email-masked]> writes:
> 
>>> * Reproducing
>>> - Case 1:
>>>    emacs -Q
>>>    C-u 999 a
>>>    visual-line-mode
>>>    C-p C-a
>>>    C-e C-a
>> 
>> What are the problems you see in this recipe?  Please be specific,
>> because it could be that what you see on your system we cannot see
>> on ours.

I just tried that recipe, and with visual-line-mode (and
line-move-visual) enabled C-e certainly doesn't behave how I'd expect.

Rather than C-e moving to the end of the current visual line, if the
current visual line wraps then it moves to the beginning of the next
visual line.  If I repeatedly press C-e, the cursor moves vertically
down the first column of all those visual lines.  Only the final
visual line of the logical line will it move to the end.

I'm seeing this in both 27.2 and GNU Emacs 28.0.90.

Further testing indicates that the lack of any spaces in the wrapped
visual lines is a factor.  In a visual line with a space, the visual
line will *end* with a space, and C-a will move to that.

In this recipe there are no such spaces, and the problem arises.

-Phil