I defined a macro which is essentially a wrapper for \meaning
to check macro definitions
\def\whatis#1{{\ttfamily\string#1: \meaning#1}}
(The actual form I'm using goes one step further and checks whether the command is robust, but this is irrelevant here.) More often than not, the result involves some internal macro containing the token @
. If I want to check this macro, I must then write something like
\makeatletter
\whatis\MacroNameWith@InIt
\makeatother
As I'm very lazy :-)
I would like to activate \makeatletter
within the scope of \whatis
, so I tried
\def\whatis#1{{\makeatletter\ttfamily\string#1: \meaning#1\makeatother}}
(Actually I'd guess that \makeatother
isn't necessary because of the grouping.) Needless to say, this isn't working, otherwise I wouldn't be posting this question :-)
My questions:
- Why is this not working?
- How can I define
\whatis
such that\whatis{\MacroNameWith@InIt}
behaves as I wish?
\verb
and can not be used in the argument of any other macro.\makeatletter
(which is\catcode`@=11
) affect the catcode table which is only used to convert input characters into tokens. By the time you are in the replacement text of a macro the argument passed as#1
has already been tokenized so the catcode change has no effect (unless you use\scantokens
which is the same as writing it out to a file and then reading the characters back in, but uses an internal buffer for efficiency.