GNU bug report logs - #70811
ConTeXt-mode-cleanup clobbers my paragraph-start

Previous Next

Package: auctex;

Reported by: Jim <zlists+auctex <at> jdvb.ca>

Date: Tue, 7 May 2024 04:13:01 UTC

Severity: normal

Done: Ikumi Keita <ikumi <at> ikumi.que.jp>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 70811 in the body.
You can then email your comments to 70811 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#70811; Package auctex. (Tue, 07 May 2024 04:13:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jim <zlists+auctex <at> jdvb.ca>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Tue, 07 May 2024 04:13:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jim <zlists+auctex <at> jdvb.ca>
To: bug-auctex <at> gnu.org
Subject: ConTeXt-mode-cleanup clobbers my paragraph-start
Date: Mon, 6 May 2024 15:52:15 -0300
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.)

Thanks.
                                Jim

Emacs  : GNU Emacs 27.2 (build 1, x86_64-slackware-linux-gnu, GTK+ Version 3.24.27)
 of 2021-03-25
Package: 14.0.3.2024-03-17

current state:
==============
(setq
 AUCTeX-date "2024-03-17"
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("~/.emacs.d/auctex"
		  "/home/zsd/.emacs.d/elpa/auctex-14.0.4/style"
		  "/home/zsd/.emacs.d/auctex/auto"
		  "/home/zsd/.emacs.d/auctex/style" "auto" "style")
 TeX-auto-save nil
 TeX-parse-self t
 TeX-master t
 a-bunch-of-other-stuff nil
)




Information forwarded to bug-auctex <at> gnu.org:
bug#70811; Package auctex. (Tue, 07 May 2024 05:24:01 GMT) Full text and rfc822 format available.

Message #8 received at 70811 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Jim <zlists+auctex <at> jdvb.ca>
Cc: 70811 <at> debbugs.gnu.org
Subject: Re: bug#70811: ConTeXt-mode-cleanup clobbers my paragraph-start
Date: Tue, 07 May 2024 14:22:47 +0900
Hi Jim,

>>>>> Jim <zlists+auctex <at> jdvb.ca> 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?

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW




Information forwarded to bug-auctex <at> gnu.org:
bug#70811; Package auctex. (Tue, 07 May 2024 11:44:01 GMT) Full text and rfc822 format available.

Message #11 received at 70811 <at> debbugs.gnu.org (full text, mbox):

From: Jim <zlists+auctex <at> jdvb.ca>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 70811 <at> debbugs.gnu.org
Subject: Re: bug#70811: ConTeXt-mode-cleanup clobbers my paragraph-start
Date: Tue, 7 May 2024 08:43:10 -0300
Hi Ikumi,

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

>>>>>> Jim <zlists+auctex <at> jdvb.ca> 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





Information forwarded to bug-auctex <at> gnu.org:
bug#70811; Package auctex. (Thu, 09 May 2024 06:15:01 GMT) Full text and rfc822 format available.

Message #14 received at 70811 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Jim <zlists+auctex <at> jdvb.ca>
Cc: 70811 <at> debbugs.gnu.org
Subject: Re: bug#70811: ConTeXt-mode-cleanup clobbers my paragraph-start
Date: Thu, 09 May 2024 15:14:00 +0900
[Message part 1 (text/plain, inline)]
Hi Jim,

>>>>> Jim <zlists+auctex <at> jdvb.ca> 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).

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW

[0001-Improve-paragraph-commands-management-for-ConTeXt-mo.patch (text/x-diff, attachment)]

Information forwarded to bug-auctex <at> gnu.org:
bug#70811; Package auctex. (Sun, 12 May 2024 19:41:01 GMT) Full text and rfc822 format available.

Message #17 received at 70811 <at> debbugs.gnu.org (full text, mbox):

From: Jim <zlists+auctex <at> jdvb.ca>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 70811 <at> debbugs.gnu.org
Subject: Re: bug#70811: ConTeXt-mode-cleanup clobbers my paragraph-start
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 <zlists+auctex <at> jdvb.ca> 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




Information forwarded to bug-auctex <at> gnu.org:
bug#70811; Package auctex. (Mon, 13 May 2024 15:35:02 GMT) Full text and rfc822 format available.

Message #20 received at 70811 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Jim <zlists+auctex <at> jdvb.ca>
Cc: 70811 <at> debbugs.gnu.org
Subject: Re: bug#70811: ConTeXt-mode-cleanup clobbers my paragraph-start
Date: Tue, 14 May 2024 00:34:11 +0900
[Message part 1 (text/plain, inline)]
Hi Jim,

>>>>> Jim <zlists+auctex <at> jdvb.ca> writes:
> 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.

Thanks for your report. I'm sorry, I was wrong at altering regexp
generation code. Can you try the attached patch? (Undo the last patch
and apply the attached patch to the fresh source, please.)

> I wonder if the default definition should (could?) somehow capture all
> of them.

I expect the revised patch fills that bill.

> Given that the (interactive) customization doesn't want the leading
> '\',

Do you mean that `ConTeXt-paragraph-commands' doesn't include the
leading backslash? Then it isn't specific to interactive customization.
It is desgined after LaTeX counterpart, which also doesn't include the
leading backslash.

> is there any way to add that to paragraph-start with the code you
> recently added?

You can use
(add-hook 'LaTeX-mode-hook
  (lambda ()
     (add-hook 'find-file-hook
        (lambda ()
           (setq paragraph-start "abc")) <-- Set whatever you like
        nil t)))
in your init file if you really need, but I'd like you to try the patch
below first.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW

[0001-Improve-paragraph-commands-management-for-ConTeXt-mo.patch (text/x-diff, attachment)]

Information forwarded to bug-auctex <at> gnu.org:
bug#70811; Package auctex. (Mon, 13 May 2024 16:59:01 GMT) Full text and rfc822 format available.

Message #23 received at 70811 <at> debbugs.gnu.org (full text, mbox):

From: Jim <zlists+auctex <at> jdvb.ca>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 70811 <at> debbugs.gnu.org
Subject: Re: bug#70811: ConTeXt-mode-cleanup clobbers my paragraph-start
Date: Mon, 13 May 2024 13:57:56 -0300
Hi Ikumi,

On Tue, May 14, 2024 at 00:34 (+0900), Ikumi Keita wrote:

>>>>>> Jim <zlists+auctex <at> jdvb.ca> writes:
>> 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.

> Thanks for your report. I 'm sorry, I was wrong at altering regexp
> generation code.  Can you try the attached patch?  (Undo the last patch
> and apply the attached patch to the fresh source, please.)

In the interest of getting you an answer quickly, I only tested it for
about 5 minutes, but in all of those tests, I can happily say that it did
what I wanted it to do.

>> I wonder if the default definition should (could?) somehow capture all
>> of them.

> I expect the revised patch fills that bill.

It certainly did in my brief tests.

>> Given that the (interactive) customization doesn't want the leading
>> '\',

> Do you mean that `ConTeXt-paragraph-commands' doesn't include the leading
> backslash?  Then it isn't specific to interactive customization.  It is
> designed after LaTeX counterpart, which also doesn't include the leading
> backslash.

Indeed, I assumed that restriction was not from the interactive
customization, but instead from the auctex code.

>> is there any way to add that to paragraph-start with the code you
>> recently added?

> You can use
> (add-hook 'LaTeX-mode-hook
>   (lambda ()
>      (add-hook 'find-file-hook
>         (lambda ()
>            (setq paragraph-start "abc")) <-- Set whatever you like
> nil t)))
> in your init file if you really need, but I'd like you to try the patch
> below first.

Thanks for that emacs-fu.  (Although I wonder if I want 'ConTeXt-mode-hook'
intead of 'LaTeX-mode-hook'.)

Regardless of what hook I should use, this version of your patch seems to
work very nicely.  Thank you for all the time you have put into this.

                                      Jim




Information forwarded to bug-auctex <at> gnu.org:
bug#70811; Package auctex. (Tue, 14 May 2024 11:33:02 GMT) Full text and rfc822 format available.

Message #26 received at 70811 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Jim <zlists+auctex <at> jdvb.ca>
Cc: 70811 <at> debbugs.gnu.org
Subject: Re: bug#70811: ConTeXt-mode-cleanup clobbers my paragraph-start
Date: Tue, 14 May 2024 20:32:39 +0900
Hi Jim,

>>>>> Jim <zlists+auctex <at> jdvb.ca> writes:
> In the interest of getting you an answer quickly, I only tested it for
> about 5 minutes, but in all of those tests, I can happily say that it did
> what I wanted it to do.

Thanks for testing. I pushed the fix to the git repository.

>> You can use
>> (add-hook 'LaTeX-mode-hook
>> (lambda ()
>> (add-hook 'find-file-hook
>> (lambda ()
>> (setq paragraph-start "abc")) <-- Set whatever you like
>> nil t)))
>> in your init file if you really need, but I'd like you to try the patch
>> below first.

> Thanks for that emacs-fu.  (Although I wonder if I want 'ConTeXt-mode-hook'
> intead of 'LaTeX-mode-hook'.)

You are right. That's `ConTeXt-mode-hook'. 💦

> Regardless of what hook I should use, this version of your patch seems to
> work very nicely.  Thank you for all the time you have put into this.

You're welcome. I'll close this bug.

Best regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW




bug closed, send any further explanations to 70811 <at> debbugs.gnu.org and Jim <zlists+auctex <at> jdvb.ca> Request was from Ikumi Keita <ikumi <at> ikumi.que.jp> to control <at> debbugs.gnu.org. (Tue, 14 May 2024 11:34:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 12 Jun 2024 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 5 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.