[latex3-commits] [git/LaTeX3-latex3-latex3] xmarks: minor cleanup (3b29b7393)

Frank Mittelbach frank.mittelbach at latex-project.org
Fri Feb 14 21:44:14 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : xmarks
Link       : https://github.com/latex3/latex3/commit/3b29b7393eeac8e26bc688b878acff462590676e

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

commit 3b29b7393eeac8e26bc688b878acff462590676e
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Fri Feb 14 21:44:14 2020 +0100

    minor cleanup


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

3b29b7393eeac8e26bc688b878acff462590676e
 l3trial/xmarks/testfiles/xmarks-000.tlg |   1 -
 l3trial/xmarks/xmarks.ins               |   4 +-
 l3trial/xmarks/xmarks2.dtx              |  20 ++++--
 support/etoolbox.sty                    | 123 ++++++++++++++++++++++----------
 4 files changed, 99 insertions(+), 49 deletions(-)

diff --git a/l3trial/xmarks/testfiles/xmarks-000.tlg b/l3trial/xmarks/testfiles/xmarks-000.tlg
index 361b021d7..2d7fea2e5 100644
--- a/l3trial/xmarks/testfiles/xmarks-000.tlg
+++ b/l3trial/xmarks/testfiles/xmarks-000.tlg
@@ -5,7 +5,6 @@ Package: xparse ....-..-.. L3 Experimental document command parser
 \l__xparse_current_arg_int=\count...
 \g__xparse_grabber_int=\count...
 \l__xparse_m_args_int=\count...
-\l__xparse_mandatory_args_int=\count...
 \l__xparse_v_nesting_int=\count...
 )
 Package: xmarks2 ....-..-.. L3 Experimental marks
diff --git a/l3trial/xmarks/xmarks.ins b/l3trial/xmarks/xmarks.ins
index cae93177c..a9924405d 100644
--- a/l3trial/xmarks/xmarks.ins
+++ b/l3trial/xmarks/xmarks.ins
@@ -1,6 +1,6 @@
 \iffalse meta-comment
 
-File xmarks.ins Copyright (C) 2018 Frank Mittelbach, the LaTeX3 Project
+File xmarks.ins Copyright (C) 2018-2020 Frank Mittelbach, the LaTeX3 Project
 
 It may be distributed and/or modified under the conditions of the
 LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -32,7 +32,7 @@ license information is placed in the derived files.
 
 \preamble
 
-Copyright (C) 1999-2018 Frank Mittelbach, the LaTeX3 Project
+Copyright (C) 1999-2020 Frank Mittelbach, the LaTeX3 Project
 
 It may be distributed and/or modified under the conditions of
 the LaTeX Project Public License (LPPL), either version 1.3c of
diff --git a/l3trial/xmarks/xmarks2.dtx b/l3trial/xmarks/xmarks2.dtx
index 8d352245e..4e6bc0da3 100644
--- a/l3trial/xmarks/xmarks2.dtx
+++ b/l3trial/xmarks/xmarks2.dtx
@@ -1,6 +1,6 @@
 % \iffalse meta-comment
 %
-%% File: xmarks.dtx Copyright (C) 2018 Frank Mittelbach, The LaTeX3 Project
+%% File: xmarks.dtx Copyright (C) 2018-2020 Frank Mittelbach, The LaTeX3 Project
 %
 % It may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -241,6 +241,11 @@
 % These functions are tied to the output routine and used in the
 % interface to \LaTeXe{} and perhaps at some later time within an OR
 % for \LaTeX3. Not meant for general use, so made internal here.
+% Internal to this package means that \verb|@@| automatically gets
+%    replaced in the code (and in the documentation).
+%    \begin{macrocode}
+%<@@=marks>
+%    \end{macrocode}
 %
 % \begin{function}{\@@_update_structure:nnn}
 %   \begin{syntax}
@@ -378,13 +383,10 @@
 %<*package>
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-%<@@=marks>
-%    \end{macrocode}
 %
 %    \begin{macrocode}
 %<*package>
-\ProvidesExplPackage{xmarks2}{2018-12-06}{}
+\ProvidesExplPackage{xmarks2}{2020-02-06}{}
   {L3 Experimental marks}
 %</package>
 %    \end{macrocode}
@@ -837,8 +839,12 @@
 %  \begin{macro}{\markright}
 %    In addition to generating the legacy mark we output the
 %    individual ones as well at the very same point.
+%
+%    These days both macros are robust so patching needs to be done on
+%    the internal ones which is arkward. But then this is only
+%    temporary \dots
 %    \begin{macrocode}
-\patchcmd\markboth
+\expandafter\patchcmd\csname markboth\space \endcsname
     {\mark}
     {
       \marks_put:nn{ltxleft}{#1}
@@ -851,7 +857,7 @@
 %    \end{macrocode}
 %    Same game with \cs{markright} more or less \ldots
 %    \begin{macrocode}
-\patchcmd\markright
+\expandafter\patchcmd\csname markright\space \endcsname
     {\mark}
     {
      \marks_put:nn{ltxright}{#1}
diff --git a/support/etoolbox.sty b/support/etoolbox.sty
index 067d62b92..7d6f4502e 100644
--- a/support/etoolbox.sty
+++ b/support/etoolbox.sty
@@ -1,5 +1,5 @@
 % Copyright (c) 2007-2011 Philipp Lehman.
-%           (c) 2015-2018 Joseph Wright
+%           (c) 2015-2019 Joseph Wright
 %
 % Permission is granted to copy, distribute and/or modify this
 % software under the terms of the LaTeX Project Public License
@@ -12,7 +12,7 @@
 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{etoolbox}
-  [2018/08/19 v2.5f e-TeX tools for LaTeX (JAW)]
+  [2019/09/21 v2.5h e-TeX tools for LaTeX (JAW)]
 
 \begingroup
 \@ifundefined{eTeXversion}
@@ -268,8 +268,8 @@
     {\@secondoftwo}
     {\ifdefmacro{#1}
        {\ifdefparam{#1}
-	  {\@secondoftwo}
-	  {\etb at ifdefempty{#1}}}
+          {\@secondoftwo}
+          {\etb at ifdefempty{#1}}}
        {\@secondoftwo}}}
 
 \def\etb at ifdefempty#1{%
@@ -295,8 +295,8 @@
     {\@firstoftwo}
     {\ifdefmacro{#1}
        {\ifdefparam{#1}
-	  {\@secondoftwo}
-	  {\etb at ifdefempty{#1}}}
+          {\@secondoftwo}
+          {\etb at ifdefempty{#1}}}
        {\@secondoftwo}}}
 
 % {<csname>}{<true>}{<false>}
@@ -342,14 +342,14 @@
   \ifdefmacro{#1}
     {\ifdefmacro{#2}
        {\begingroup
-	\edef\etb at tempa{\expandafter\strip at prefix\meaning#1}%
-	\edef\etb at tempb{\expandafter\strip at prefix\meaning#2}%
-	\ifx\etb at tempa\etb at tempb
-	  \aftergroup\@firstoftwo
-	\else
-	  \aftergroup\@secondoftwo
-	\fi
-	\endgroup}
+        \edef\etb at tempa{\expandafter\strip at prefix\meaning#1}%
+        \edef\etb at tempb{\expandafter\strip at prefix\meaning#2}%
+        \ifx\etb at tempa\etb at tempb
+          \aftergroup\@firstoftwo
+        \else
+          \aftergroup\@secondoftwo
+        \fi
+        \endgroup}
        {\@secondoftwo}}
     {\@secondoftwo}}
 
@@ -362,7 +362,7 @@
        {\@secondoftwo}
        {\expandafter\ifdefstrequal
         \csname#1\expandafter\endcsname
-	\csname#2\endcsname}}}
+        \csname#2\endcsname}}}
 
 % {<cstoken>}{<string>}{<true>}{<false>}
 
@@ -888,6 +888,7 @@
 % {<cstoken>}
 
 \newrobustcmd{\undef}[1]{\let#1\etb at undefined}
+\newrobustcmd{\gundef}[1]{\global\let#1\etb at undefined}
 
 % {<csname>}
 
@@ -1520,7 +1521,7 @@
         {\noexpand\etb at listitem\noexpand\do{####1}%
          \expandafter\noexpand
          \csname etb at lst@\expandafter\@gobble\string#1\endcsname
-	 \noexpand\@nil}}}%
+         \noexpand\@nil}}}%
   \@tempa}
 
 \long\def\etb at lst@@notoken at do#1{%
@@ -1558,7 +1559,7 @@
         {\noexpand\etb at listitem{####1}{####2}%
          \expandafter\noexpand
          \csname etb at lst@\expandafter\@gobble\string#1\endcsname
-	        {####1}\noexpand\@nil}}}%
+                {####1}\noexpand\@nil}}}%
   \@tempa}
 
 \long\def\etb at lst@@notoken at arg#1#2{%
@@ -1751,20 +1752,41 @@
 \newrobustcmd{\AtBeginEnvironment}[1]{%
   \csgappto{@begin@#1 at hook}}
 
-\patchcmd\begin
-  {\csname #1\endcsname}
-  {\csuse{@begin@#1 at hook}%
-   \csname #1\endcsname}
-  {}
-  {\etb at warning{%
-     Patching '\string\begin' failed!\MessageBreak
-     '\string\AtBeginEnvironment' will not work\@gobble}}
+\ifcsname begin \endcsname
+  \expandafter\patchcmd\csname begin \endcsname
+    {\csname #1\endcsname}
+    {\csuse{@begin@#1 at hook}%
+     \csname #1\endcsname}
+    {}
+    {\etb at warning{%
+       Patching '\string\begin' failed!\MessageBreak
+       '\string\AtBeginEnvironment' will not work\@gobble}}
+\else
+  \patchcmd\begin
+    {\csname #1\endcsname}
+    {\csuse{@begin@#1 at hook}%
+     \csname #1\endcsname}
+    {}
+    {\etb at warning{%
+       Patching '\string\begin' failed!\MessageBreak
+       '\string\AtBeginEnvironment' will not work\@gobble}}
+\fi
 
 % {<environment>}{<code>}
 
 \newrobustcmd{\AtEndEnvironment}[1]{%
   \csgappto{@end@#1 at hook}}
 
+\ifcsname end \endcsname
+\expandafter\patchcmd\csname end \endcsname
+  {\csname end#1\endcsname}
+  {\csuse{@end@#1 at hook}%
+   \csname end#1\endcsname}
+  {}
+  {\etb at warning{%
+     Patching '\string\end' failed!\MessageBreak
+     '\string\AtEndEnvironment' will not work\@gobble}}
+\else
 \patchcmd\end
   {\csname end#1\endcsname}
   {\csuse{@end@#1 at hook}%
@@ -1773,31 +1795,54 @@
   {\etb at warning{%
      Patching '\string\end' failed!\MessageBreak
      '\string\AtEndEnvironment' will not work\@gobble}}
+\fi
 
 % {<environment>}{<code>}
 
 \newrobustcmd{\BeforeBeginEnvironment}[1]{%
   \csgappto{@beforebegin@#1 at hook}}
 
-\pretocmd\begin
-  {\csuse{@beforebegin@#1 at hook}}
-  {}
-  {\etb at warning{%
-     Patching '\string\begin' failed!\MessageBreak
-     '\string\BeforeBeginEnvironment' will not work\@gobble}}
+\ifcsname begin \endcsname
+  \expandafter\pretocmd\csname begin \endcsname
+    {\csuse{@beforebegin@#1 at hook}}
+    {}
+    {\etb at warning{%
+       Patching '\string\begin' failed!\MessageBreak
+       '\string\BeforeBeginEnvironment' will not work\@gobble}}
+\else
+  \pretocmd\begin
+    {\csuse{@beforebegin@#1 at hook}}
+    {}
+    {\etb at warning{%
+       Patching '\string\begin' failed!\MessageBreak
+       '\string\BeforeBeginEnvironment' will not work\@gobble}}
+\fi
 
 % {<environment>}{<code>}
 
 \newrobustcmd{\AfterEndEnvironment}[1]{%
   \csgappto{@afterend@#1 at hook}}
 
-\patchcmd\end
-  {\if at ignore}
-  {\csuse{@afterend@#1 at hook}%
-   \if at ignore}
-  {}
-  {\etb at warning{%
-     Patching '\string\end' failed!\MessageBreak
-     '\string\AfterEndEnvironment' will not work\@gobble}}
+\let\if at ignore\relax
+\ifcsname end \endcsname
+  \expandafter\patchcmd\csname end \endcsname
+    {\if at ignore}
+    {\csuse{@afterend@#1 at hook}%
+     \if at ignore}
+    {}
+    {\etb at warning{%
+       Patching '\string\end' failed!\MessageBreak
+       '\string\AfterEndEnvironment' will not work\@gobble}}
+\else
+  \patchcmd\end
+    {\if at ignore}
+    {\csuse{@afterend@#1 at hook}%
+     \if at ignore}
+    {}
+    {\etb at warning{%
+       Patching '\string\end' failed!\MessageBreak
+       '\string\AfterEndEnvironment' will not work\@gobble}}
+\fi
+\let\if at ignore\iffalse
 
 \endinput





More information about the latex3-commits mailing list.