[latex3-commits] [git/LaTeX3-latex3-latex2e] gh373: Add \ShowCommand (closes #373) (079958fc)

PhelypeOleinik tex.phelype at gmail.com
Thu Aug 20 04:20:26 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh373
Link       : https://github.com/latex3/latex2e/commit/079958fc6b2991abf7981e4205c4afd2eb48ac9f

>---------------------------------------------------------------

commit 079958fc6b2991abf7981e4205c4afd2eb48ac9f
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Wed Aug 19 22:37:37 2020 -0300

    Add \ShowCommand (closes #373)


>---------------------------------------------------------------

079958fc6b2991abf7981e4205c4afd2eb48ac9f
 base/ltdefns.dtx | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/base/ltdefns.dtx b/base/ltdefns.dtx
index cb319331..501f4539 100644
--- a/base/ltdefns.dtx
+++ b/base/ltdefns.dtx
@@ -1512,10 +1512,58 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+%
+%
+% \subsubsection{Showing robust commands}
+%
+% \begin{macro}{\ShowCommand}
+% \changes{v1.5k}{2020/08/19}{Added \cs{ShowCommand} (gh/373)}
+%
+%   Most of the machinery defined for \cs{NewCommandCopy} can be used to show
+%   the definition of a robust command, in a similar fashion to \texttt{texdef}.
+%   The difference is that after the command's is detected to has a given type
+%   of robustness, rather than making a copy, we use a separate routine to show
+%   its definition.
+%
+%   With all the machinery in place, \cs{ShowCommand} itself is quite simple:
+%   use \cs{robust at command@act} to iterate through the \cs{@showcommandlisthook}
+%   list, and if nothing is found, fallback to \cs{show}.
+%    \begin{macrocode}
+%</2ekernel>
+%<latexrelease>\IncludeInRelease{2020-10-01}{\ShowCommand}%
+%<latexrelease>  {Add \ShowCommand}%
+%<*2ekernel|latexrelease>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\def\ShowCommand#1{%
+  \robust at command@act
+    \@showcommandlisthook#1%
+    \show#1}
+%    \end{macrocode}
+%
+% \begin{macro}{\@showcommandlisthook}
+%   The initial definition of \cs{@showcommandlisthook} contains the same tests
+%   as used for copying, but \cs{@show at ...} commands instead of \cs{@copy at ..}.
+%   Same as before, it is initialised to cope with \cs{DeclareRobustCommand} and
+%   \cs{newcommand} with optional arguments.
+%    \begin{macrocode}
+\def\@showcommandlisthook{%
+  {\@if at DeclareRobustCommand \@show at DeclareRobustCommand}%
+  {\@if at newcommand \@show at newcommand}}
+%    \end{macrocode}
 % \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
+%
+%   Now the rollback code.
+%    \begin{macrocode}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000-00-00}{\ShowCommand}
+%<latexrelease>  {Undefine \ShowCommand}%
+%<latexrelease>\let\ShowCommand\@undefined
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
+%    \end{macrocode}
 % \end{macro}
 %
 %





More information about the latex3-commits mailing list.