samcarter
After reading https://www.texdev.net/2020/08/19/the-good-the-bad-and-the-ugly-creating-document-commands I'm now looking for an example how I would use \NewDocumentCommand to create an overlay-aware macro for beamer.

samcarter
Here an example with both the classic \newcommand syntax and \NewDocumentCommand. The key difference is that within the macro definition the #1 needs to be surrounded by <>.


\documentclass{beamer}

\newcommand<>{\makered}[1]{{\color#2{red}#1}}

\renewenvironment<>{makegreen}{%
\color#1{green}%
}{}

\usepackage{xparse}
\NewDocumentCommand{\makeblue}{D<>{1-} m}{{\color<#1>{blue}#2}}

\NewDocumentEnvironment{makeyellow}{ D<>{1-} }{
\color<#1>{yellow}%
}{}

\begin{document}

\begin{frame}

\makered<2>{test}

\makeblue<2>{test}

\begin{makegreen}<2>
content...
\end{makegreen}

\begin{makeyellow}<2>
content...
\end{makeyellow}

\end{frame}

\end{document}


Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.