Subject: Re: bug#51762: 13.0.14; environment formating

From: Ikumi Keita <[email-masked]>
Date: Sat, 13 Nov 2021 00:28:08 +0900

>>>>> Ikumi Keita <[email-masked]> writes:
> It seems that the regexp in `LaTeX-fill-region-as-paragraph' to identify
> a code comment isn't wise enough:
> ----------------------------------------------------------------------
>           (if (re-search-forward
>                (concat "\\("
>                        ;; Code comments.
>                        "\\([^ \r\n%\\]\\|\\\\%\\)\\([ \t]\\|\\\\\\\\\\)*"
>                        TeX-comment-start-regexp
>                        "\\|"
> [...]
> ----------------------------------------------------------------------
> This doesn't match lines which end with "\ %%". I'll try to find
> something better.

I think the attached patch fixes the problem. Could you test whether it
works on your side?

I confirmed this fix passes regression test, but would appreciate if
others also could have a look to find any possible regression.

Regards,
Ikumi Keita

diff --git a/latex.el b/latex.el
index 05238344..6b464d50 100644
--- a/latex.el
+++ b/latex.el
@@ -4022,7 +4022,7 @@ performed in that case."
           (if (re-search-forward
                (concat "\\("
                        ;; Code comments.
-                       "\\([^ \r\n%\\]\\|\\\\%\\)\\([ \t]\\|\\\\\\\\\\)*"
+                       "\\([^ \r\n%\\]\\|\\\\[% ]\\)\\([ \t]\\|\\\\\\\\\\)*"
                        TeX-comment-start-regexp
                        "\\|"
                        ;; Lines ending with `\par'.