[latex3-commits] [git/LaTeX3-latex3-latex2e] gh239: First (failed so far) attempt at defaults (8945b1ba)

PhelypeOleinik tex.phelype at gmail.com
Thu Jun 4 07:10:14 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : gh239
Link       : https://github.com/latex3/latex2e/commit/8945b1ba21a1f7d69d0e62bd0d2682a0b45133a7

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

commit 8945b1ba21a1f7d69d0e62bd0d2682a0b45133a7
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Thu Jun 4 02:10:14 2020 -0300

    First (failed so far) attempt at defaults


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

8945b1ba21a1f7d69d0e62bd0d2682a0b45133a7
 base/ltoutenc.dtx | 40 +++++++++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/base/ltoutenc.dtx b/base/ltoutenc.dtx
index 334396fa..dfd1de3e 100644
--- a/base/ltoutenc.dtx
+++ b/base/ltoutenc.dtx
@@ -1239,6 +1239,8 @@
 % \begin{macro}{\@copy at DeclareTextCommand}
 % \begin{macro}{\@copy at declaretextcommand}
 % \begin{macro}{\@copy at declaretextcommand@enc}
+% \begin{macro}{\@copy at declaretextcommand@defaults}
+% \begin{macro}{\@unexpanded at cdrcar}
 % \changes{v1.5h}{2020/05/09}{Added \cs{DeclareCommandCopy} (gh/239)}
 %
 %   With the generic \cs{NewCommandCopy} macro defined earlier in
@@ -1355,20 +1357,42 @@
 %    \begin{macrocode}
   \noexpand\@for\noexpand\@elt:=\@loaded at encoding@list\noexpand\do
     {\unexpanded{%
-      \expandafter\@copy at declaretextcommand\expandafter{\@elt}}%
+      \expandafter\@copy at declaretextcommand\expandafter{\@elt}#1#2}%
         {\@expl at cs@to at str@@N#1}{\@expl at cs@to at str@@N#2}%
     }%
   }\x}
 %    \end{macrocode}
 %
 %   Now \cs{@copy at declaretextcommand} just checks if |\<enc>\#2| exists,
-%   and then copies it:
+%   and then prepares the arguments for
+%   \cs{@copy at declaretextcommand@defaults}, which will examine if the
+%   command has an encoding default, and define it accordingly, or will
+%   simply copy the command:
 %    \begin{macrocode}
-\def\@copy at declaretextcommand#1#2#3{%
-  \@ifundefined{#1\@backslashchar#3}{}{%
-    \expandafter\declare at command@copy at let
-      \csname#1\@backslashchar#2\expandafter\endcsname
-      \csname#1\@backslashchar#3\endcsname}}
+\def\@copy at declaretextcommand#1#2#3#4#5{%
+  \@ifundefined{#1\@backslashchar#5}{}{%
+    \begingroup\edef\x{\endgroup
+    \noexpand\@copy at declaretextcommand@defaults
+      \expandafter\expandafter\expandafter\@unexpanded at cdrcar
+        \csname#1\@backslashchar#5\endcsname XXX\@nil
+      \noexpand#2%
+      \noexpand#3%
+      \expandafter\noexpand\csname#1\@backslashchar#4\endcsname
+      \expandafter\noexpand\csname#1\@backslashchar#5\endcsname
+    }\x}}
+\def\@unexpanded at cdrcar#1#2#3#4\@nil{\unexpanded{{#2}}}
+\def\@copy at declaretextcommand@defaults#1#2#3#4#5{%
+  \def\reserved at a{\UseTextSymbol{#1}#3}%
+  \ifx\reserved at a#5%
+    \def#4{\UseTextSymbol{#1}#2}%
+  \else
+    \def\reserved at a{\UseTextAccent{#1}#3}%
+    \ifx\reserved at a#5%
+      \def#4{\UseTextAccent{#1}#2}%
+    \else
+      \declare at command@copy at let#4#5%
+    \fi
+  \fi}
 %    \end{macrocode}
 %
 %   Here's the \cs{@copy at declaretextcommand@enc} auxiliary:
@@ -1403,6 +1427,8 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \subsubsection{Hyphenation}
 %





More information about the latex3-commits mailing list.