[latex3-commits] [git/LaTeX3-latex3-latex3] master: New key property .cs_set:Np (80748a287)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Feb 11 09:30:15 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/80748a287fe5a5e21986f15c07ace92b6ec2041c

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

commit 80748a287fe5a5e21986f15c07ace92b6ec2041c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Feb 11 08:30:15 2020 +0000

    New key property .cs_set:Np


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

80748a287fe5a5e21986f15c07ace92b6ec2041c
 l3kernel/CHANGELOG.md            |   3 ++
 l3kernel/l3keys.dtx              |  54 +++++++++++++++++++
 l3kernel/testfiles/m3keys006.lvt | 110 +++++++++++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3keys006.tlg |  91 ++++++++++++++++++++++++++++++++
 4 files changed, 258 insertions(+)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 49e36da35..31b00ecc3 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Added
+- Key property `.cs_set:Np` and variants
+
 ### Fixed
 - Allow for full range of encodings when expanding text (issue #671)
 - Support `\begin`/`\end` in text expansion
diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index d172a1a04..4fb894149 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -243,6 +243,20 @@
 %   \meta{value} given for the \meta{key}.
 % \end{function}
 %
+% \begin{function}[added = 2020-01-11]
+%   {
+%     .cs_set:Np, .cs_set:cp,
+%     .cs_set_protected:Np, .cs_set_protected:cp,
+%     .cs_gset:Np, .cs_gset:cp,
+%     .cs_gset_protected:Np, .cs_gset_protected:cp,
+%   }
+%   \begin{syntax}
+%     \meta{key} .cs_set:Np = \meta{control sequence} \meta{arg.~spec.}
+%   \end{syntax}
+%   Defines \meta{key} to set \meta{control sequence} to have \meta{arg.~spec.}
+%   and replacement text \meta{value}.
+% \end{function}
+%
 % \begin{function}[updated = 2013-07-09]
 %   {.default:n, .default:V, .default:o, .default:x}
 %   \begin{syntax}
@@ -1588,6 +1602,21 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_cs_set:NNpn, \@@_cs_set:Ncpn}
+%   Creating control sequences is a bit more tricky than other cases as
+%   we need to pick up the |p| argument. To make the internals look clearer,
+%   the trailing |n| argument here is just for appearance.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_cs_set:NNpn #1#2#3#
+  {
+    \cs_set_protected:cpx { \c_@@_code_root_str \l_keys_path_str } ##1
+      { #1 \exp_not:N #2 \exp_not:n {#3} {##1} }
+    \use_none:n
+  }
+\cs_generate_variant:Nn \@@_cs_set:NNpn { Nc }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\@@_default_set:n}
 %   Setting a default value is easy. These are stored using \cs{cs_set:cpx} as this
 %   avoids any worries about whether a token list exists.
@@ -1898,6 +1927,31 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}
+%   {.cs_set:Np, .cs_set:cp, .cs_set_protected:Np, .cs_set_protected:cp}
+% \begin{macro}
+%   {.cs_gset:Np, .cs_gset:cp, .cs_gset_protected:Np, .cs_gset_protected:cp}
+%    \begin{macrocode}
+\cs_new_protected:cpn { \c_@@_props_root_str .cs_set:Np } #1
+  { \@@_cs_set:NNpn \cs_set:Npn #1 { } }
+\cs_new_protected:cpn { \c_@@_props_root_str .cs_set:cp } #1
+  { \@@_cs_set:Ncpn \cs_set:Npn #1 { } }
+\cs_new_protected:cpn { \c_@@_props_root_str .cs_set_protected:Np } #1
+  { \@@_cs_set:NNpn \cs_set_protected:Npn #1 { } }
+\cs_new_protected:cpn { \c_@@_props_root_str .cs_set_protected:cp } #1
+  { \@@_cs_set:Ncpn \cs_set_protected:Npn #1 { } }
+\cs_new_protected:cpn { \c_@@_props_root_str .cs_gset:Np } #1
+  { \@@_cs_set:NNpn \cs_gset:Npn #1 { } }
+\cs_new_protected:cpn { \c_@@_props_root_str .cs_gset:cp } #1
+  { \@@_cs_set:Ncpn \cs_gset:Npn #1 { } }
+\cs_new_protected:cpn { \c_@@_props_root_str .cs_gset_protected:Np } #1
+  { \@@_cs_set:NNpn \cs_gset_protected:Npn #1 { } }
+\cs_new_protected:cpn { \c_@@_props_root_str .cs_gset_protected:cp } #1
+  { \@@_cs_set:Ncpn \cs_gset_protected:Npn #1 { } }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}{.default:n, .default:V, .default:o, .default:x}
 %   Expansion is left to the internal functions.
 %    \begin{macrocode}
diff --git a/l3kernel/testfiles/m3keys006.lvt b/l3kernel/testfiles/m3keys006.lvt
new file mode 100644
index 000000000..b2152f8c2
--- /dev/null
+++ b/l3kernel/testfiles/m3keys006.lvt
@@ -0,0 +1,110 @@
+% Copyright (C) 2020 The LaTeX3 Project
+
+
+\documentclass{minimal}
+\input{regression-test}
+
+\RequirePackage[enable-debug]{expl3}
+\ExplSyntaxOn
+\debug_on:n { check-declarations , deprecation , log-functions }
+\ExplSyntaxOff
+
+
+\begin{document}
+\START
+\AUTHOR{Joseph Wright}
+\ExplSyntaxOn
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\TEST { .cs_set:Np }
+  {
+    \keys_define:nn { module }
+      {
+        key-one .cs_set:Np  = \my_local_cs:nn #1#2 ,
+        key-two .cs_gset:Np = \my_global_cs:nn #1#2
+      }
+    \cs_show:N \my_local_cs:nn
+    \cs_show:N \my_global_cs:nn
+    \group_begin:
+      \keys_set:nn { module }
+        {
+          key-one   = #1~and~#2 ,
+          key-two   = (#1)(#2)
+        }
+      \cs_show:N \my_local_cs:nn
+      \cs_show:N \my_global_cs:nn
+    \group_end:
+    \cs_show:N \my_local_cs:nn
+    \cs_show:N \my_global_cs:nn
+  }
+
+\TEST { .cs_set:cp }
+  {
+    \keys_define:nn { module }
+      {
+        key-one .cs_set:cp  = { my_local_cs:nn } #1#2 ,
+        key-two .cs_gset:cp = { my_global_cs:nn } #1#2
+      }
+    \cs_show:N \my_local_cs:nn
+    \cs_show:N \my_global_cs:nn
+    \group_begin:
+      \keys_set:nn { module }
+        {
+          key-one   = #1~and~#2 ,
+          key-two   = (#1)(#2)
+        }
+      \cs_show:N \my_local_cs:nn
+      \cs_show:N \my_global_cs:nn
+    \group_end:
+    \cs_show:N \my_local_cs:nn
+    \cs_show:N \my_global_cs:nn
+  }
+
+\TEST { .cs_set_protected:Np }
+  {
+    \keys_define:nn { module }
+      {
+        key-one .cs_set_protected:Np  = \my_local_cs:nn #1#2 ,
+        key-two .cs_gset_protected:Np = \my_global_cs:nn #1#2
+      }
+    \cs_show:N \my_local_cs:nn
+    \cs_show:N \my_global_cs:nn
+    \group_begin:
+      \keys_set:nn { module }
+        {
+          key-one   = #1~and~#2 ,
+          key-two   = (#1)(#2)
+        }
+      \cs_show:N \my_local_cs:nn
+      \cs_show:N \my_global_cs:nn
+    \group_end:
+    \cs_show:N \my_local_cs:nn
+    \cs_show:N \my_global_cs:nn
+  }
+
+\TEST { .cs_set_protected:cp }
+  {
+    \keys_define:nn { module }
+      {
+        key-one .cs_set_protected:cp  = { my_local_cs:nn } #1#2 ,
+        key-two .cs_gset_protected:cp = { my_global_cs:nn } #1#2
+      }
+    \cs_show:N \my_local_cs:nn
+    \cs_show:N \my_global_cs:nn
+    \group_begin:
+      \keys_set:nn { module }
+        {
+          key-one   = #1~and~#2 ,
+          key-two   = (#1)(#2)
+        }
+      \cs_show:N \my_local_cs:nn
+      \cs_show:N \my_global_cs:nn
+    \group_end:
+    \cs_show:N \my_local_cs:nn
+    \cs_show:N \my_global_cs:nn
+  }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\END
diff --git a/l3kernel/testfiles/m3keys006.tlg b/l3kernel/testfiles/m3keys006.tlg
new file mode 100644
index 000000000..7df3a4eda
--- /dev/null
+++ b/l3kernel/testfiles/m3keys006.tlg
@@ -0,0 +1,91 @@
+This is a generated file for the LaTeX (2e + expl3) validation system.
+Don't change this file in any respect.
+Author: Joseph Wright
+============================================================
+TEST 1: .cs_set:Np
+============================================================
+> \my_local_cs:nn=undefined.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=undefined.
+<recently read> }
+l. ...  }
+> \my_local_cs:nn=\long macro:#1#2->#1 and #2.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+> \my_local_cs:nn=undefined.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 2: .cs_set:cp
+============================================================
+> \my_local_cs:nn=\relax.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+> \my_local_cs:nn=\long macro:#1#2->#1 and #2.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+> \my_local_cs:nn=\relax.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 3: .cs_set_protected:Np
+============================================================
+> \my_local_cs:nn=undefined.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+> \my_local_cs:nn=\protected\long macro:#1#2->#1 and #2.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\protected\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+> \my_local_cs:nn=undefined.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\protected\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 4: .cs_set_protected:cp
+============================================================
+> \my_local_cs:nn=\relax.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\protected\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+> \my_local_cs:nn=\protected\long macro:#1#2->#1 and #2.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\protected\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+> \my_local_cs:nn=\relax.
+<recently read> }
+l. ...  }
+> \my_global_cs:nn=\protected\long macro:#1#2->(#1)(#2).
+<recently read> }
+l. ...  }
+============================================================





More information about the latex3-commits mailing list.