Subject: bug#35396: 12.1.2; wrong interaction between auto-fill and latex comments

From: [email-masked]
Date: Tue, 23 Apr 2019 17:14:24 +0200

Hi all.

– Problematic behaviour: When one is writing text in front of a comment '%' and auto-fill automatically inserts a newline, the point is suddenly moved to *within* the comment, ie on the right of '%'.

– Expected behaviour: The point in the new line should stay to the left of the comment, ie of '%'.

– Example:

1. Activate auto-fill-mode in a tex file where LaTeX mode is active.

2. Set fill-column to some value; here I use 20.

3. Suppose we have a line like this:

123456789% commented

4. Now we'd like to add some more text right before the "%", eg "-1234567890 abc".

Note that "123456789-1234567890" is twenty characters long, so auto-fill should automatically insert a newline as we type the space after "0". Expected result:

123456789-1234567890
abc% commented
[with point between 'c' and '%']

Instead we get this:

123456789-1234567890
% abccommented
[with point between 'c' and 'c']

That is, our text has been continued  *within* the comment, which wasn't our intention.

– Further info:

A. If the text before the comment is *already longer* than auto-fill-column when we type the space, and if auto-fill can carry some previous text to the new line, then everything works correctly. For example, If we have

123456789% commented

And now we type " 1234567890X abc" (note: space instead of "-") right before the "%", we get

123456789
1234567890X abc% commented

as desired.

B. The length of the text after "%" seems to be irrelevant for this issue.

Let me know what additional info to provide.

Cheers!
J

Emacs  : GNU Emacs 26.1 (build 1, i686-w64-mingw32)
  of 2018-05-30
Package: 12.1.2

  AUCTeX-date "2019-02-08"
  window-system 'w32
  LaTeX-version "2e"