Subject: 13.0.12; Paragraph filling with line that ends in % followed by comment

From: Gustavo Barros <[email-masked]>
Date: Wed, 09 Jun 2021 11:58:46 -0300

Hi All,

When a paragraph containing a line whose text ends with a "legit" `\%' 
and is followed by a comment, paragraph filling joins the following 
paragraph content into the comment, when it shouldn't.

An ECM to reproduce the issue is: start `emacs -Q'.

Do an initial setup:
#+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/elpa/auctex-13.0.12")
(load "auctex.el" nil t t)
(setq TeX-parse-self t)
(setq TeX-auto-save t)
#+end_src

Visit a `.tex' file with contents ("|" represents point position):

#+begin_src latex
\documentclass{article}

\begin{document}

|Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Ut purus 
 elit,
vestibulum ut, placerat ac, adipiscing vitae, felis.  Curabitur dictum 
gravida
mauris.  Nam arcu libero, nonummy eget, consectetuer id, vulputate a, 
magna.
Donec vehicula augue eu neque.  Pellentesque habitant morbi tristique 
senectus
et netus et malesuada fames ac turpis egestas. 35\% % FIXME check this 
number
Mauris ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus 
vestibulum
urna fringilla ultrices.

\end{document}
#+end_src

and call `M-q'. The result is:

#+begin_src latex
\documentclass{article}

\begin{document}

|Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Ut purus
elit, vestibulum ut, placerat ac, adipiscing vitae, felis.  Curabitur
dictum gravida mauris.  Nam arcu libero, nonummy eget, consectetuer
id, vulputate a, magna.  Donec vehicula augue eu neque.  Pellentesque
habitant morbi tristique senectus et netus et malesuada fames ac
turpis egestas.
35\% % FIXME check this number Mauris ut leo.  Cras viverra metus 
rhoncus sem.  Nulla et lectus vestibulum urna fringilla ultrices.

\end{document}
#+end_src

Resulting in the undesired effect of the rest of the paragraph being 
joined into the comment, of which it was not part before the filling.

(Note that this message may get filled (format-flowed) by the MUA, so 
that the examples might not be immediately displayed as expected. Please 
take that into consideration. I do hope it is still 
understandable/reproducible.)

Best regards,
Gustavo.