showstream

David Carlisle d.p.carlisle at gmail.com
Mon May 8 15:48:27 CEST 2023


On Mon, 8 May 2023 at 13:56, Martin Münch <Martin.Muench at uni-bonn.de> wrote:

> When compiling the code
>
>      \documentclass{minimal}
>      \newwrite\teststream
>      \immediate\openout\teststream="teststream"
>      %\showstream=\teststream
>      \def\example{\message{This}\message{is}\message{a}\message{test.}}
>      \show\example
>      \AddToHook{begindocument}[foobar]{\message{Hi!}}
>      \ShowHook{begindocument}
>      \begin{document}
>      \end{document}
>
> the log-file contains:
>
>      > \example=macro:
>      ->\message {This}\message {is}\message {a}\message {test.}.
>      l.6 \show\example
>
>      ?
>
>      -> The hook 'begindocument':
>      > Code chunks:
>      >     foobar -> \message {Hi!}
>      > Document-level (top-level) code (executed last):
>      >     ---
>      > Extra code for next invocation:
>      >     ---
>      > Rules:
>      >     ---
>      > Execution order:
>      >     foobar.
>      <recently read> }
>
>      l.8 \ShowHook{begindocument}
>
>      ?
>
> and the `teststream.tex` file is empty.
>
> When the `%` before `\showstream=\teststream` is removed and the code is
> compiled, in the log-file (and on screen) it is
>
>      -> The hook 'begindocument':
>      > Code chunks:
>      >     foobar -> \message {Hi!}
>      > Document-level (top-level) code (executed last):
>      >     ---
>      > Extra code for next invocation:
>      >     ---
>      > Rules:
>      >     ---
>      > Execution order:
>
> and the `teststream.tex` contains:
>
>      > \example=macro:
>      ->\message {This}\message {is}\message {a}\message {test.}
>
>      >     foobar
>
> i.e. the output from `\show` is moved from log and screen to
> `teststream.tex` (as expected), but `\ShowHook` only removes
>
>      >     foobar.
>      <recently read> }
>
>      l.8 \ShowHook{begindocument}
>
>      ?
> from screen and log and except `>     foobar` neither writes it into
> `teststream.tex`.
>
> My expectation was: Either
> - showstream also working for `\ShowHook`: Everything from `\ShowHook`
> is removed from screen and log and printed in `teststream.tex`
> or
> - showstream not working for `\ShowHook`: Nothing from `\ShowHook` is
> removed from screen and log and printed in `teststream.tex`.
>
> Is my expectation wrong or is the behaviour of `showstream` strange?
>


\ShowHook is a mixture of (essentially) \wlog and \show to output  some
latex
information then finally give the \show interaction,

\showstream (which I have never seen used before:-) only affects the parts
using \show, so the message preamble using \write still goes to the log.

Latex could (I suppose) check every time if \showstream is an open stream
and if so write to there, or perhaps always write to \showstream and rely
on tex's behaviour of writing to the log for unopened stream numbers.

You could make an enhancement request at github

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20230508/d0474458/attachment.html>


More information about the texhax mailing list.