[latex3-commits] [git/LaTeX3-latex3-latex3] gh795: Copying xparse (robust) commands (3e2a7adf1)
PhelypeOleinik
phelype.oleinik at latex-project.org
Thu Jan 14 19:40:00 CET 2021
Repository : https://github.com/latex3/latex3
On branch : gh795
Link : https://github.com/latex3/latex3/commit/3e2a7adf13180430537cf4652f5d9632b2eb8d42
>---------------------------------------------------------------
commit 3e2a7adf13180430537cf4652f5d9632b2eb8d42
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Thu Jan 14 15:39:15 2021 -0300
Copying xparse (robust) commands
part of #795
>---------------------------------------------------------------
3e2a7adf13180430537cf4652f5d9632b2eb8d42
l3packages/xparse/xparse.dtx | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/l3packages/xparse/xparse.dtx b/l3packages/xparse/xparse.dtx
index c84bfdbd8..ec04c4ca0 100644
--- a/l3packages/xparse/xparse.dtx
+++ b/l3packages/xparse/xparse.dtx
@@ -1266,6 +1266,13 @@
% \end{macrocode}
% \end{variable}
%
+% \begin{variable}{\s_@@}
+% Scratch space.
+% \begin{macrocode}
+\scan_new:N \s_@@
+% \end{macrocode}
+% \end{variable}
+%
% \begin{variable}{\l_@@_tmp_prop, \l_@@_tmpa_tl, \l_@@_tmpb_tl}
% \begin{macro}{\@@_tmp:w}
% Scratch space.
@@ -4300,6 +4307,39 @@
% \end{macrocode}
% \end{macro}
%
+% At this point we know that the command has the right shape, so we can
+% just do the copying.
+%
+% \subsubsection{Robust commands}
+%
+% \begin{macro}{\@@_robust_cmd_set_eq:NN}
+% Copying a robust command is rather easy. The tricky part is to
+% define the top-level expansion of the command, because it needs to
+% cope with possibly expandable defaults to optional arguments (that
+% must not be expanded at this point) and with optional arguments
+% whose default is another argument, so parameter tokens may be
+% involved. Copying the actual code of the command is just a matter
+% of copying \cs[no-index]{\meta{name} code}.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_robust_cmd_set_eq:NN #1 #2
+ {
+ \tl_set:Nx \l_@@_tmpa_tl { \cs_to_str:N #1 ~ }
+ \tl_set:Nx \l_@@_tmpb_tl { \cs_to_str:N #2 ~ }
+ \cs_set:Npn \@@_tmp:w ##1
+ { ####1 \exp_not:c {##1} \exp_not:c { ##1 code } ####2 }
+ \use:e
+ {
+ \cs_set:Npx \exp_not:N \@@_tmp:w
+ \@@_tmp:w \l_@@_tmpb_tl \s_@@
+ { \@@_tmp:w \l_@@_tmpa_tl }
+ }
+ \cs_set_protected_nopar:Npx #1
+ { \exp_args:No \exp_not:o { \exp_after:wN \@@_tmp:w #2 \s_@@ } }
+ \cs_set_eq:cc { \l_@@_tmpa_tl code } { \l_@@_tmpb_tl code }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Argument processors}
%
% \begin{macro}{\@@_bool_reverse:N}
More information about the latex3-commits
mailing list.