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

From: Jim <[email-masked]>
Date: Tue, 7 May 2024 08:43:10 -0300

Hi Ikumi,

On Tue, May  7, 2024 at 14:22 (+0900), Ikumi Keita wrote:

>>>>>> Jim <[email-masked]> writes:
>> ConTeXt mode has the defun ConTeXt-mode-cleanup which is the :after-hook
>> of ConTeXt-mode.  In this cleanup defun, paragraph-start is re-set.
>> Unfortunately, this over-writes my choice of paragraph-start which I set
>> in my ConTeXt-mode hook.  Unless there is some ":after-after-hook" or
>> ":really-after-hook" or ":my-after-hook" or some other (unknown to me)
>> way of doing something after ConTeXt-mode-cleanup, I have to
>> handraulically (re-)setq paragraph-start after loading my file.

>> This is not a good thing.

>> The comment in context.el mentions doing this for reasons similar to the
>> same part of latex.el,
>>       ;; Don't do locally-bound test for `LaTeX-paragraph-commands-regexp'
>>       ;; and `paragraph-start'.  See comments in similar part in latex.el.
>> but not being a latex user I don't understand why this is desired for latex
>> users, and so I can't transmogrify that to why context users might want
>> this.

>> In any case,
>> (a) do we really need the paragraph-start setting code in context.el, and
>> (b) if so, could there be some user option which tells ConTeXt-mode-cleanup
>> to *not* setq paragraph-start ?

>> (Or perhaps there is already a way which I don't have enough emacs-fu to
>> know.  I am happy to be enlightened.)

> Thank you for the report. The reason for LaTeX mode is that this
> treatment enables AUCTeX to add flexibly new commands afterwards as
> paragraph starters through sub files supporting various LaTeX packages
> ("style files" in AUCTeX terminology). AUCTeX style files overwrites
> `paragraph-start' casually in LaTeX mode, so users who want to customize
> it in the LaTeX mode hook should actually set `LaTeX-paragraph-commands'
> instead.

> In principle, ConTeXt mode should have similar framework, although the
> current AUCTeX style files have no support for ConTeXt modules except
> TikZ.

> 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.

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.

                                Jim