Taylor, P P.Taylor at rhul.ac.uk
Wed Oct 2 23:14:37 CEST 2019

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.

Many thanks for your comments/analysis, David — much appreciated.  It 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20191002/17fc0034/attachment-0001.html>