josephwright / etoolbox

Tool-box for LaTeX programmers using e-TeX
LaTeX Project Public License v1.3c
41 stars 7 forks source link

\robustify doesn't undefine \foo[space] #9

Closed josephwright closed 7 years ago

josephwright commented 7 years ago

With the example

\RequirePackage{etoolbox}
\DeclareRobustCommand\foo[2][]{}
\expandafter\show\csname foo \endcsname
\robustify\foo
\expandafter\show\csname foo \endcsname

the robustify procedure makes \foo a \protected version of the LaTeX kernel \foo[space]. The code in etoolbox has

        \if@tempswa
          \ifcsdef{\string#1 }
            {}
            {\csundef{\expandafter\@gobble\string#1 }}%

but the logic here seems odd/wrong.

Need to check exactly what the LaTeX kernel does in all cases and make sure we leave only the 'required' parts about.

lstonys commented 10 months ago

It does undefine. Just \show\csname it makes as a \relax

\let \fee\etb@undefined

\show\fee
> \fee=undefined.
l.22 \show\fee

\expandafter\show \csname fee\endcsname
> \fee=\relax.
<recently read> \fee