Hi Werner,
>>>>> Werner LEMBERG <[email protected]> writes:
> Consider the following input while being in LaTeX/P mode.
> ```
> test test test test test test test test
> \emph{test test test test test test test test}
> test test test test test test test test
> ```
> If I execute `fill-paragraph`, I get the desired result:
> ```
> test test test test test test test test \emph{test test test test test
> test test test} test test test test test test test test
> ```
> However, if I mark the paragraph as a region and apply
> `fill-paragraph` to that region, I get the following:
> ```
> test test test test test test test test \emph{test test test test test
> test test test} test test test test test test test test
> ```
> As can be seen, the indentation of the second line is missing.
Indeed.
> Why is this so, and how can I get the 'correct' behaviour for regions
> (i.e., as if I apply `fill-paragraph` manually paragraph by
> paragraph)? Please advise.
An unsatisfactory workaround is to use C-c C-q C-p
(LaTeX-fill-paragraph) instead of M-q (fill-paragraph).
The reason of the reported behavior is that `fill-paragraph' ignores
`fill-paragraph-function', set to `LaTeX-fill-paragraph' in LaTeX mode
buffer, when the following condition stated in the doc string of
`fill-paragraph' is met:
,----
| The REGION argument is non-nil if called interactively; in that
| case, if Transient Mark mode is enabled and the mark is active,
| call `fill-region' to fill each of the paragraphs in the active
| region, instead of just filling the current paragraph.
`----
Unfortunately `fill-region' (more precisely, `fill-region-as-paragraph'
called in `fill-region') doesn't pay attention to the variable
`fill-paragraph-function' and performs filling with Emacs standard
generic filling algorithm. That's the reason why the indentation you
are talking about was lost.
I'm not sure whether this is an Emacs bug or not. Maybe LaTeX mode
should remap `fill-paragraph' to `LaTeX-fill-paragraph' directly. What
do other developers think?
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopGenocide #CeasefireNOW
#IProtestAgainstTrumpAndNetanyahu'sAttackOnIran,WhichViolatesInternationalLaw