[texhax] testing if a control sequence is primitive

Heiko Oberdiek heiko.oberdiek at googlemail.com
Sun Oct 9 03:27:53 CEST 2011

On Sat, Oct 08, 2011 at 09:48:54PM +0100, Philip TAYLOR (Webmaster, Ret'd) wrote:

> I am /seriously/ impressed, and was about to nominate you
> for the post of vice-Grand Wizard of TeX (no salary, I am
> afraid), 


> when I thought to try the following :
> \Test \newif

\newif is "outer" in plain TeX. Outer macros cannot be catched
as arguments. Thus \ifprimitivecs of my previous mail can be used
with any single token as argument except outer macros.

The following \ifprimitivecsname catches command names
(without backslash). The command tokens are internally
constructed by \csname. But this \ifprimitivecsname also
works with names of outer commands.


  \catcode`\|=0 %
  \catcode`\\=12 %

    \immediate\write16{\Backslash#1 is original primitive}%
    \immediate\write16{\Backslash#1 is something else}%
\Test{ }
  \immediate\write16{Redefine \string\par}%

\csname @@end\endcsname\end

Yours sincerely
  Heiko Oberdiek

More information about the texhax mailing list