Hi Ikumi,

Thanks for the reply.

For (1), I think either way you proposed should address the issue. Maybe 
tree-sitter integration in Emacs 29 can help with faster parsing of latex files 
in the future, but I don’t know if that is feasible or in auctex’s roadmap. 
Denis’ workaround works fine, but as the list of "LaTeX-paragraph-commands” 
goes longer, I guess it still has some impact on the speed.

For (2), I am not sure how well filling works with macros like \newenvironment. 
It seems these are more like code than text, so manual line break and auto 
indentation makes more sense to me.

Best,
Ruiyang

> On Mar 14, 2023, at 3:19 AM, Ikumi Keita <ik...@ikumi.que.jp> wrote:
> 
> Hi Ruiyang,
> 
>>>>>> Ruiyang Wu <ywwr...@gmail.com> writes:
>> Currently, using "LaTeX-fill-paragraph” when point is in latex
>> preamble will cause unintended result, e.g., merging multiple
>> “\usepackage” commands into one line. IMHO, preamble should not be
>> filled just like those in the "LaTeX-indent-environment-list”. Is it
>> possible to make "LaTeX-fill-paragraph” skip preamble by default?
> 
> There was once a similar suggestion before[1], but didn't get attention
> at that time. :-(
> 
> I think there are at least two difficulties for this idea.
> (1) `LaTeX-fill-paragraph' is called repeatedly in `LaTeX-fill-region',
> which is called from most of `LaTeX-fill-*' functions. Thus it can slow
> down the family if `LaTeX-fill-paragraph' checks every time whether the
> point is in preamble or not.
> 
> (2) Even in preamble, users still want filling inside some arguments,
> say, \newcommand and \newenvironment.
> 
> My preliminary idea to address (1) is either to add an optional argument
> to `LaTeX-fill-paragraph' which is non-nil only when called
> interactively, or to make a new function
> `LaTeX-fill-paragraph-interactive' and assign it in the keymap instead
> of `LaTeX-fill-paragraph'. In either way, we can check the preamble just
> once only when called interactively.
> 
> However, I don't have a good idea to work consistently with the issue
> (2) yet.
> 
> Does anyone see a good solution?
> 
> Regards,
> Ikumi Keita
> #StandWithUkraine #StopWarInUkraine
> 
> [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30704

Reply via email to