Subject: bug#51762: 13.0.14; environment formating

From: Ikumi Keita <[email-masked]>
Date: Fri, 19 Nov 2021 12:08:37 +0900

Hi Arash,

> Thanks for the update.  I have a question, though: You have also
> expanded the `LaTeX-filling' ert test.
[...]
> I would have expected something like this:
> % bug#51762-5 "\\" before code comment shouldn't be skipped.
> Mauris ac felis vel velit tristique imperdiet.  Vestibulum convallis,
> lorem a tempus semper, dui dui euismod elit, vitae placerat urna
> tortor vitae lacus.\\
> Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor,
> at vulputate neque nulla lacinia eros.  Aliquam posuere.  Cum sociis
> natoque penatibus et magnis dis parturient montes, nascetur ridiculus
> mus.%
> Am I missing something?  I works fine if I replace \\ with \par.

I agree it looks odd, but it seems an intended behavior. In
`LaTeX-fill-region-as-paragraph', we have:
----------------------------------------------------------------------
                  ;; Code comments and lines ending with `\par' are
                  ;; included in filling.  Lines ending with `\\' are
                  ;; skipped.
                  (if (or has-code-comment
                          (match-beginning 1))
                      (LaTeX-fill-region-as-para-do from (point) justify-flag)
                    (LaTeX-fill-region-as-para-do
                     from (line-beginning-position 0) justify-flag)
                    ;; At least indent the line ending with `\\'.
                    (indent-according-to-mode)))
----------------------------------------------------------------------
According to the comment, lines ending with `\\' are excluded from
filling on purpose, though I'm not sure why. Perhaps for the cases
inside environments like tabular, array, align etc.?

By the way, detection of code comments still needs revision to mimic the
regexp search.
----------------------------------------------------------------------
          ;; Code comments.
          (when (setq has-code-comment
                      (TeX-search-forward-comment-start end-marker))
            ;; See if there is at least one non-whitespace
            ;; character before the comment starts.
            (goto-char has-code-comment)
            (skip-chars-backward " \t" (line-beginning-position))
            (if (bolp)
                ;; Not a code comment.
                (setq has-code-comment nil)))
----------------------------------------------------------------------
It's OK to skip when `TeX-search-forward-comment-start' finds no match,
but we must continue searching when the found candidate turns out to be
non code comment. That's what regexp search would have done.

I'll fix this later.

Regards,
Ikumi Keita