Subject: bug#70811: ConTeXt-mode-cleanup clobbers my paragraph-start

From: Jim <[email-masked]>
Date: Sun, 12 May 2024 16:39:50 -0300

Hi Ikumi,

sorry for the slow reply.  See below.

On Thu, May  9, 2024 at 15:14 (+0900), Ikumi Keita wrote:

>>>>>> Jim <[email-masked]> writes:
>>> I think I can implement `ConTeXt-paragraph-commands' like LaTeX mode and
>>> then you can set it instead of `paragraph-start'. What do you think
>>> about this idea?

>> I spent a few minutes looking at the code; I now have a glimmer of
>> understanding, thanks.

>> I still am unclear about why the setting of paragraph-start is done in
>> the after-hook, rather than before the user's hook is called. However,
>> it may well be that I don't need to understand this.

> Suppose that there is a file local variable entry for
> `LaTeX-paragraph-commands'. LaTeX mode uses after-hook so that its value
> is reflected to `paragraph-start'. In addition, AUCTeX style files
> casually overwrite `paragraph-start' to support various paragraph
> commands; in that procedure, they never care what the user set to
> `paragraph-start' in the mode hook and just overwrite. In other words,
> AUCTeX doesn't consider `paragraph-start' as a variable which is to be
> customized in the mode hook. The users are expected to use other
> variables to control `paragraph-start'.

>> I think your solution would work for me. My current paragraph-start
>> does not have "[ \t]*" and yet does what I want, but perhaps having "[
>> \t]*" won't hurt. Maybe it will make things better in some way I don't
>> see now. Time will tell.

>> In summary, thanks very much for the response, and if you are able to
>> implement that for ConTeXt-mode I would very much appreciate it.

> Thanks. Can you try the attached patch? If you customize the new option
> `ConTeXt-paragraph-commands', its value will be reflected to
> `paragraph-start' (for new buffers created after the customization).

Thank you very much for spending some time on this.  I tried it on this
section of code

\startitemize[yadda]
\item sslkdslkd lskdlskdls slkd slkdslk
sldk sldkl
lkslks d sldsldk s sldksldk slkdsldksd sldsldk s sldksldk slkdsldksd
sldsldk s sldksldk slkdsldksd
\item sldsldk s sldksldk slkdsldksd
\item fill this paragraph right here
fill this paragraph right here fill this paragraph right here
fill this paragraph right here
\stopitemize

and if I run fill-paragraph on the last item, I get

...
\item fill this paragraph right here fill this paragraph right here fill
  this paragraph right here fill this paragraph right here \stopitemize

(i.e., the \stopitemize has become "part of" the "\item" paragraph).  I
won't try to imagine what other ConTeXt users want, but I don't like this.

I customized Context-Paragraph-Commands by adding stopitemize, and that
fixed this particular issue.  But there are many built-in
        \stop<something>
commands, and I wonder if the default definition should (could?) somehow
capture all of them.  (My initial attempt was to add 'stop' to the
customization, but that did not work for me.)

At the risk of startling anyone reading this, I'll mention that for my
plain TeX usage, I use
        (setq paragraph-start "\\\\")
This does what I want in 99.5% of the cases, and I can live with the
incorrect thing happening 0.5% of the time.  Given that the (interactive)
customization doesn't want the leading '\', is there any way to add that to
paragraph-start with the code you recently added?

Thanks very much.

                                Jim