This very helpful answer led me to define my own starred commands. However, in order to use my commands in, for example, headings, after a round of strange almost frightening thoughts, I managed to arrive at the following (MWE):
\documentclass{article}
\makeatletter
\def\testone{\@ifstar\@dothis\@@dothat}
\def\testtwo{\protect\@ifstar\protect\@dothis\protect\@@dothat}
\def\@dothis#1{#1}
\def\@@dothat#1{#1}
\makeatother
\begin{document}
\section{\testone{abc}} % does not work
\testone{abc} % works
\section{\testtwo{abc}} % works
\testtwo{abc} % works
\end{document}
I am still struggling to percolate TeX's expansion mechanisms and, hence, would be thankful for an answer about why my definition \test... requires these \protects to work in headings? Thanks.
\NewDocumentCommandor\NewExpandableDocumentCommandand friends with ans-type (starred) argument?usrguide.pdfcurrent version for more information.