[latex3-commits] [git/LaTeX3-latex3-latex2e] gh963: Correct output of \ShowEnvironment (e29afaf0)

PhelypeOleinik phelype.oleinik at latex-project.org
Tue Nov 29 04:35:30 CET 2022


Repository : https://github.com/latex3/latex2e
On branch  : gh963
Link       : https://github.com/latex3/latex2e/commit/e29afaf0aff22ef383b05627f258ca57a91b8edf

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

commit e29afaf0aff22ef383b05627f258ca57a91b8edf
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Tue Nov 29 00:35:30 2022 -0300

    Correct output of \ShowEnvironment


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

e29afaf0aff22ef383b05627f258ca57a91b8edf
 base/ltcmd.dtx   | 11 +++++--
 base/ltdefns.dtx | 97 +++++++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 79 insertions(+), 29 deletions(-)

diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 14d6756f..03cfb829 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -34,8 +34,8 @@
 %%% From File: ltcmd.dtx
 %
 %    \begin{macrocode}
-\def\ltcmdversion{v1.1a}
-\def\ltcmddate{2022-08-16}
+\def\ltcmdversion{v1.1b}
+\def\ltcmddate{2022-11-29}
 %    \end{macrocode}
 %
 %<*driver>
@@ -2473,10 +2473,15 @@
 %    \end{macrocode}
 %
 %   And, of course, add \cs{__kernel_cmd_if_xparse:NTF} and
-%   \cs{@@_show:N} to \cs{@showcommandlisthook}:
+%   \cs{@@_show:N} to \cs{@showcommandlisthook} and to
+%   \cs{@showenvironmentlisthook} (\cs{@@_show:N} takes care of the
+%   environment case as well, so both entries are identical):
+%  \changes{v1.1b}{2022-11-29}{Add \cs{@showenvironmentlisthook}}
 %    \begin{macrocode}
 \tl_gput_right:Nn \@showcommandlisthook
   { { \__kernel_cmd_if_xparse:NTF \@@_show:N } }
+\tl_gput_right:Nn \@showenvironmentlisthook
+  { { \__kernel_cmd_if_xparse:NTF \@@_show:N } }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/base/ltdefns.dtx b/base/ltdefns.dtx
index 8d758a44..9062b09a 100644
--- a/base/ltdefns.dtx
+++ b/base/ltdefns.dtx
@@ -1740,27 +1740,6 @@
     {\ExpandArgs{cc}\declare at commandcopy@do{#3}{#4}%
      \ExpandArgs{cc}\declare at commandcopy@do{end#3}{end#4}}}
 %    \end{macrocode}
-%    \emph{this needs fixing because \cs{ShowCommand} already shows
-%    the env definition if defined by \cs{NewDocumentEnvironment} so
-%    we get it twice (but not if 2e envs are used)}
-% \changes{v1.5s}{2022/11/24}{Add \cs{ShowEnvironment}}
-%    \begin{macrocode}
-\def\ShowEnvironment#1{%
-  \expandafter\@show at environment\csname #1\endcsname}
-\long\def\@show at environment#1{%
-  \robust at command@act
-    \@showcommandlisthook#1%
-    \@normal at showenv#1}
-\long\def\@normal at showenv#1{%
-  \typeout{> \string\begin{\@expl at cs@to at str@@N#1}=environment:}%
-  \@normal at showenv@meaning#1%
-  \typeout{> \string\end{\@expl at cs@to at str@@N#1}:}%
-  \expandafter\@normal at showenv@meaning\csname end\@expl at cs@to at str@@N#1\endcsname}
-\def\@normal at showenv@meaning#1{%
-  \edef\reserved at a{%
-    \@expl at cs@argument at spec@@N#1->\@expl at cs@replacement at spec@@N#1}%
-  \showtokens\expandafter\expandafter\expandafter{\expandafter\reserved at a}}
-%    \end{macrocode}
 %
 %   Now the rollback code.
 %    \begin{macrocode}
@@ -1771,7 +1750,6 @@
 %<latexrelease>\let\NewEnvironmentCopy\@undefined
 %<latexrelease>\let\RenewEnvironmentCopy\@undefined
 %<latexrelease>\let\DeclareEnvironmentCopy\@undefined
-%<latexrelease>\let\ShowEnvironment\@undefined
 %<latexrelease>\EndIncludeInRelease
 %<*2ekernel>
 %    \end{macrocode}
@@ -1780,10 +1758,6 @@
 % \end{macro}
 %
 %
-%
-%
-%
-%
 % \subsubsection{Showing robust commands}
 %
 % \begin{macro}{\ShowCommand}
@@ -1837,6 +1811,77 @@
 %    \end{macrocode}
 % \end{macro}
 %
+%    \begin{macrocode}
+%</2ekernel>
+%<latexrelease>\IncludeInRelease{2023-06-01}{\ShowEnvironment}
+%<latexrelease>  {Add \ShowEnvironment}%
+%<*2ekernel|latexrelease>
+%    \end{macrocode}
+%
+% \begin{macro}{\ShowEnvironment}
+%  \changes{v1.5s}{2022/11/24}{Add \cs{ShowEnvironment}}
+%    \begin{macrocode}
+\def\ShowEnvironment#1{%
+  \expandafter\@show at environment\csname #1\endcsname}
+\long\def\@show at environment#1{%
+  \robust at command@act
+    \@showenvironmentlisthook#1%
+    \@show at normalenv#1}
+%    \end{macrocode}
+%
+% \begin{macro}{\@showenvironmentlisthook}
+%   The initial definition of \cs{@showenvironmentlisthook} contains the same tests
+%   as used for copying, but \cs{@show at ...} commands instead of \cs{@copy at ..}.
+%   Same as before, it is initialized to cope with \cs{DeclareRobustCommand} and
+%   \cs{newcommand} with optional arguments.
+%    \begin{macrocode}
+\def\@showenvironmentlisthook{%
+  {\@if at newcommand \@show at environment@opt}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@showenvironmentlisthook}
+%   The initial definition of \cs{@showenvironmentlisthook} contains the same tests
+%   as used for copying, but \cs{@show at ...} commands instead of \cs{@copy at ..}.
+%   Same as before, it is initialized to cope with \cs{DeclareRobustCommand} and
+%   \cs{newcommand} with optional arguments.
+%    \begin{macrocode}
+\long\def\@show at environment@opt#1{%
+  \typeout{> \string\begin{\@expl at cs@to at str@@N#1}=environment:}%
+  \typeout{->\@expl at cs@replacement at spec@@N#1.^^J}%
+  \expandafter\@show at newcommand@aux
+    \csname\@backslashchar\@expl at cs@to at str@@N#1\expandafter\endcsname
+    \expandafter{#1}%
+  \@show at environment@end#1}
+\long\def\@show at environment@end#1{%
+  \expandafter\@show at normalenv@meaning
+    \csname end\@expl at cs@to at str@@N#1\endcsname
+    {\string\end{\@expl at cs@to at str@@N#1}:}}
+%    \end{macrocode}
+% \end{macro}
+%
+%    \begin{macrocode}
+\long\def\@show at normalenv#1{%
+  \@show at normalenv@meaning#1%
+    {\string\begin{\@expl at cs@to at str@@N#1}=environment:}%
+  \@show at environment@end#1}
+\def\@show at normalenv@meaning#1#2{%
+  \edef\reserved at a{#2^^J%
+    \@expl at cs@argument at spec@@N#1->\@expl at cs@replacement at spec@@N#1}%
+  \showtokens\expandafter\expandafter\expandafter{\expandafter\reserved at a}}
+%    \end{macrocode}
+%
+%   Now the rollback code.
+%    \begin{macrocode}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000-00-00}{\ShowEnvironment}
+%<latexrelease>  {Undefine \ShowEnvironment}%
+%<latexrelease>\let\ShowEnvironment\@undefined
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
+%    \end{macrocode}
+% \end{macro}
 %
 %    \begin{macrocode}
 %</2ekernel>





More information about the latex3-commits mailing list.