The texio
library provided by luatex
provides more control over message formatting and does not insert a space:
\def\mymessage#1{\directlua{texio.write("\luaescapestring{#1}")}}
\mymessage{.}\mymessage{.}\mymessage{.}
\bye
The result is:
grendel:io sharpie$ luatex io.tex
This is LuaTeX, Version beta-0.60.2-2010071218 (TeX Live 2010) (rev 3736)
(./io.tex... )
No pages of output.
David has explained this one way, I will take a slightly different tack.
First, what is going on? When e-TeX finds a protected macro, it will not expand it inside an \edef
, \write
and some similar circumstances, which usually exhaustively expand everything. That is to ensure you can see the protected token in the result. For example,
\protected\def\a{}
\typeout{%
\a%
b%
}
will show \a b
, even though there is no space between \a
and b
as far as TeX is concerned. That's because the alternative is \ab
, which as we can't see the tokens would be misleading (does it mean \a
followed by b
or a different macro \ab
?).
You can 'force' expansion of a protected macro by using the fact that they do respect \expandafter
:
\protected\def\a{b}
\edef\test{\expandafter\empty\a}
\show\a
using \empty
as something to expand after which will not result in anything remaining behind.
Second, why do you need protection? Some operations in TeX simply will not work within an \edef
as they use TeX primitives which are not 'expandable'. The classic ones here are assignments (\def
, \let
and so on). If you try
\let\a\undefined
\def\b{a}
\edef\test{\let\a\b}
you will not find that \a
ends up defined to give a
. Instead, you'll get an error: in this case 'Undefined control sequence
'. That is because \let
is not expandable. So TeX simply 'leaves it alone' inside the \edef
, and tries to expand \a
. That's not possible, and so an error arises. Thus in general it is not a good idea to try to expand protected macros.
Best Answer
will typeout the character with character code 97