I'm interested in defining a macro to deprecate other macros. The system on which we are working goes through a lot of refactorings and is used by more than a couple people, so we want to be able to mark a command as deprecated before it is removed from the macros file entirely. Specifically, I'd like to generalize
\let\fooDeprecated\foo
\renewcommand{\foo}{\warn{Deprecated command used}\fooDeprecated}
or, for that matter, anything else that will work as a simple LaTeX proxy macro (in the design pattern sense of the word "proxy"). Unfortunately, I can't seem to figure out where to stick the \expandafter
magic to make this work. That is,
\newcommand{\deprecate}[1]{%
\let\csname #1Deprecated\endcsname\csname #1\endcsname%
\renewcommand{\csname #1\endcsname}{\warn{Deprecated command used}\csname #1Deprecated\endcsname}%
}
clearly doesn't work. Is there a better way to do this? If not, how do I figure out how to expand these things?
Thanks!