On Fri, Mar 27, 2026 at 10:31 (+0100), Arash Esbati wrote:

> Hi Jim,

> Jim <[email protected]> writes:

>> Finally, on a (possibly) related note, I see that after the above change
>>         (ConTeXt-trailer-start)
>> is still only "\\\\stoptext", and does not include \stopcomponent
>> \stopTEXpage (and others); would a full patch need that,is it safe to
>> assume that a full patch needs these other things in
>> (ConTeXt-trailer-start) ?  I'm not sure what purpose is served by
>> copying material *after* the \stop<...> to _region_.tex.

> Yes, you're right.  The patch should look like this:

> --8<---------------cut here---------------start------------->8---
> diff --git a/context.el b/context.el
> index 64f1179a..9b7d0c44 100644
> --- a/context.el
> +++ b/context.el
> @@ -1257,14 +1257,14 @@ header is at the start of a line."
>    (concat
>     (regexp-quote TeX-esc)
>     (ConTeXt-environment-start-name)
> -   ConTeXt-text))
> +   (regexp-opt `(,ConTeXt-text "TEXpage" "component"))))

>  (defun ConTeXt-trailer-start ()
>    "Default start of trailer marker for ConTeXt documents."
>    (concat
>     (regexp-quote TeX-esc)
>     (ConTeXt-environment-stop-name)
> -   ConTeXt-text))
> +   (regexp-opt `(,ConTeXt-text "TEXpage" "component"))))

>  (defun ConTeXt-outline-offset ()
>    "Offset to add to `ConTeXt-section-list' levels to get outline level."
> --8<---------------cut here---------------end--------------->8---

> Should I install it?

Arash, almost, but not quite on two points (I was still investigating, and
hadn't yet followed up).

(1) According to more experienced people than me, there are not one, not
    two, but six (!) different ways to start the content after the preamble.
    So we want (something like) this:

    (regexp-opt `(,ConTeXt-text "component" "document" "MPpage" "product"
                               "TEXpage"))))

(2) When building _region_.tex, a bit is included (in some cases) that
    should not be.  For example, suppose I have in my chapter file
        \environment introCTX_env.tex

        \startcomponent b08_Lists.tex

        <content>
    and
        \environment introCTX_env

        \startproduct introCTX
    in my master file.

    In this case, when I C-c C-b to compile the current file, _region_.tex
    ends up with

        \environment introCTX_env

        \startproduct introCTX

        \message{ !name(01_BodyMatter/b08_Lists.tex) !offset(2) }
         b08_Lists.tex

    which has the (somewhat minor) flaw that the text
        \startproduct introCTX
    shouldn't be there.  Since this is only a "preview" compile, it isn't a
    show-stopper, but it is a minor flaw that I think should be fixed.

    \starttext is the only one that doesn't take an argument.
    The others have either mandatory or optional arguments, and the
    arguments can be like
        \startXYZ singleWord
    or
        \startXYZ[various stuff]
    with optional spaces or tabs before the [.

    I (blindly!) tried adding a .* like this
     (regexp-opt `(,ConTeXt-text "component.*" "document.*" "MPpage.*"
                                 "product.*" "TEXpage.*"))))
    but that caused AUCTeX to *not* include anything from the master file
    in _region_.tex.

        \message{ !name(../introCTX_eng.tex)}
        \message{ !name(01_BodyMatter/b08_Lists.tex) !offset(-2) }
        <contents of b08_Lists.tex>

So...

If you know (with little or no effort on your part) how to get AUCTeX to
not include the argument to \startcomponent or \startproduct or
\startdocument or \startTEXpage or \startMPpage that would be an
improvement.  If it isn't immediately obvious to you and you don't want to
look right now (or can't look right now), I could start poking around and
investigate more of the AUCTeX code that I haven't yet looked at.
(So please let me know.)


And there is one more nasty problem, which my .* would not have taken care
of.  When the argument is the   [...]   version, it can extend over
multiple lines.  So someone could say (for example)
        \startdocument[title={Blah blah},
                before=<something>,
                after=<someOtherThing>]
So it may need something a bit more complex to skip a   [...]  argument.

Having said that, a solution that works in most cases is nicer than no
solution at all.

Cheers.
                               Jim

Reply via email to