[latex3-commits] [git/LaTeX3-latex3-latex2e] gh239: Add check if command is a text composite (b47f1948)

PhelypeOleinik tex.phelype at gmail.com
Thu Jun 4 15:50:28 CEST 2020


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

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

commit b47f1948e097eefd3e2ebb2a45c17ffb9a99e240
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Thu Jun 4 10:50:28 2020 -0300

    Add check if command is a text composite


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

b47f1948e097eefd3e2ebb2a45c17ffb9a99e240
 base/ltoutenc.dtx | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/base/ltoutenc.dtx b/base/ltoutenc.dtx
index 1ed040f8..d95cfe99 100644
--- a/base/ltoutenc.dtx
+++ b/base/ltoutenc.dtx
@@ -1366,8 +1366,9 @@
 %   Now \cs{@copy at declaretextcommand} just checks if |\<enc>\#2| exists,
 %   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:
+%   command has an encoding default or is a composite command declared
+%   with \cs{DeclareTextCompositeCommand}, and define it accordingly,
+%   otherwise it will simply copy the command:
 %    \begin{macrocode}
 \def\@copy at declaretextcommand#1#2#3#4#5{%
   \@ifundefined{#1\@backslashchar#5}{}{%
@@ -1379,9 +1380,10 @@
       \noexpand#3%
       \expandafter\noexpand\csname#1\@backslashchar#4\endcsname
       \expandafter\noexpand\csname#1\@backslashchar#5\endcsname
+      {#1}%
     }\x}}
 \def\@unexpanded at cdr@car#1#2#3#4\@nil{\unexpanded{{#2}}}
-\def\@copy at declaretextcommand@defaults#1#2#3#4#5{%
+\def\@copy at declaretextcommand@defaults#1#2#3#4#5#6{%
   \long\def\reserved at a{\UseTextSymbol{#1}#3}%
   \ifx\reserved at a#5%
     \long\def#4{\UseTextSymbol{#1}#2}%
@@ -1390,11 +1392,35 @@
     \ifx\reserved at a#5%
       \long\def#4{\UseTextAccent{#1}#2}%
     \else
-      \declare at command@copy at let#4#5%
+      \@if at text@composite at copy@else#4#5#3{#6}%
+        {\declare at command@copy at let#4#5}%
     \fi
   \fi}
 %    \end{macrocode}
 %
+%   This command checks if the text command being copied is a text
+%   composite command.  Text composites are declared differently for
+%   each argument \meta{char}, and are stored as
+%   |\\|\meta{enc}|\|\meta{cmd}-\meta{char}, so we can't copy them
+%   unless we know every \meta{char} that was declared.  A copied
+%   composite will still work, but that's because it will use the old
+%   name, so it isn't a \emph{full} copy.
+%    \begin{macrocode}
+\def\@if at text@composite at copy@else#1#2#3#4{%
+  \edef\reserved at a##1{%
+    \noexpand\@text at composite \noexpand#2##1\noexpand\@empty
+    \noexpand\@text at composite
+      {\noexpand\@latex at error
+        {\noexpand\string\noexpand#3 undeclared in encoding #4}%
+       \noexpand\@eha{##1}}}
+  \ifx\reserved at a#2%
+    \@latex at error{Composites cannot be copied yet.}\@eha
+    \expandafter\@firstofone
+  \else
+    \expandafter\@firstofone
+  \fi}
+%    \end{macrocode}
+%
 %   Here's the \cs{@copy at declaretextcommand@enc} auxiliary:
 %    \begin{macrocode}
 \begingroup\edef\x{\endgroup





More information about the latex3-commits mailing list.