David Carlisle d.p.carlisle at gmail.com
Thu Oct 3 00:24:37 CEST 2019

On Wed, 2 Oct 2019 at 22:14, Taylor, P <P.Taylor at rhul.ac.uk> wrote:

> David Carlisle wrote:
>
> basically Phil you are doomed (unless you are tempted to try luatex which
> has more possibilities)
> you mention paragraphs ending with \par, \endgraf, a blank line or \vskip.
> blank lines and vskip are Ok really as they cause the \par token to be
> inserted, so if you have hooked some code into \par that will run.
> \endgraf or other commands let to the primitive are Ok if you give
> yourself access to the format early enough that you know that no one has
> taken  control.
> But there are two cases that you really can't easily  trap.
> In classic tex you can end a paragraph by ending a vbox, that does not
> insert a \par token: it just directly ends the paragraph with no
> macro-layer hook at all.
> In pdftex (and xetex) a paragraph can be ended with \primitive\par which
> is again pretty tricky to catch without breaking other uses of \primitive.
> partial paragraphs ended with  also make things interesting.
>
>
> would seem that you and I have reached the same (sad) conclusions, but you
> remind me that I have another obscure query — how (if at all) can I achieve
> the *intended *effect of :
>
> \def \par {\relax}
>
> \def \tmp {\let \foo = }
>
> \expandafter \tmp \primitive \par
>
> \message {\meaning \foo}
>
> \end
>
>
> That is, how can I \let a control sequence to a TeX primitive if that
> primitive has already been clobbered (e.g., overwritten by a macro) ?
> ** Phil.
>
>
\primitive isn't as useful as it could have been....

the safest way is to grab the saved primitive while building the format,