[latex3-commits] [git/LaTeX3-latex3-latex3] main: Extend key creation (bbb21ead5)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed May 25 18:47:04 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/bbb21ead5be2b432971bd4e1c2c7adf999a4fd01

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

commit bbb21ead5be2b432971bd4e1c2c7adf999a4fd01
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed May 25 17:47:04 2022 +0100

    Extend key creation


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

bbb21ead5be2b432971bd4e1c2c7adf999a4fd01
 l3packages/xtemplate/testfiles/xtemplate003.tlg |  7 +++++++
 l3packages/xtemplate/xtemplate.dtx              | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/l3packages/xtemplate/testfiles/xtemplate003.tlg b/l3packages/xtemplate/testfiles/xtemplate003.tlg
index e56b40cfc..ea38915d0 100644
--- a/l3packages/xtemplate/testfiles/xtemplate003.tlg
+++ b/l3packages/xtemplate/testfiles/xtemplate003.tlg
@@ -229,6 +229,7 @@ l. ...}
 TEST 11: Testing code interface missing var assignment
 ============================================================
 Defining \l_X_tl on line ...
+Defining key template/test/tname/key1 on line ...
 Defining \template vars > test/tname on line ...
 Defining \template restrictions > test/tname on line ...
 ! Package xtemplate Error: Key 'key2' has no implementation on line ....
@@ -250,6 +251,8 @@ but there is no key called 'key2'.
 ============================================================
 TEST 12: Testing code interface var assignments
 ============================================================
+Defining key template/test/tname/key1 on line ...
+Defining key template/test/tname/key2 on line ...
 ============================================================
 ============================================================
 TEST 13: Testing code interface: missing var declarations
@@ -257,7 +260,9 @@ TEST 13: Testing code interface: missing var declarations
 Defining \template defaults > test/tname3 on line ...
 Defining \template key types > test/tname3 on line ...
 Defining \template key order > test/tname3 on line ...
+Defining key template/test/tname3/key1 on line ...
 Defining \l_Y_tl on line ...
+Defining key template/test/tname3/key2 on line ...
 Defining \template vars > test/tname3 on line ...
 Defining \template restrictions > test/tname3 on line ...
 > \template code > test/tname3=\protected\long macro:#1->\AssignTemplateKeys .
@@ -272,6 +277,7 @@ l. ...}
 ============================================================
 TEST 14: Testing code interface: missing var declarations
 ============================================================
+Defining key template/test/tname3/key1 on line ...
 ! Package xtemplate Error: Incorrect variable description 'glabol'.
 For immediate help type H <return>.
  ...                                              
@@ -281,6 +287,7 @@ The argument 'glabol' is not of the form
 or 
 'global <variable>'.
 It must be given in one of these formats to be used in a template.
+Defining key template/test/tname3/key3 on line ...
 > \template code > test/tname3=\protected\long macro:#1->\AssignTemplateKeys .
 <recently read> }
 l. ...}
diff --git a/l3packages/xtemplate/xtemplate.dtx b/l3packages/xtemplate/xtemplate.dtx
index 94b74f54f..f10f7b409 100644
--- a/l3packages/xtemplate/xtemplate.dtx
+++ b/l3packages/xtemplate/xtemplate.dtx
@@ -1615,6 +1615,11 @@
         { choice } { \@@_implement_choices:n {#3} }
         { code }
           {
+            \keys_define:nx { template / #1 }
+              {
+                \l_@@_key_name_tl
+                  .cs_set_protected:Np = \exp_not:N #3
+              }
             \prop_put:Non \l_@@_vars_prop
               \l_@@_key_name_tl {#2#3}
           }
@@ -1622,11 +1627,21 @@
           {
             \cs_if_exist:NF #3
               { \cs_new:Npn #3 { } }
+            \keys_define:nx { template / #1 }
+              {
+                \l_@@_key_name_tl
+                  .cs_set_protected:Np = \exp_not:N #3
+              }
             \prop_put:Non \l_@@_vars_prop
               \l_@@_key_name_tl {#2#3}
           }
         { instance }
           {
+            \keys_define:nx { template / #1 }
+              {
+                \l_@@_key_name_tl
+                  .code = { \cs_set:Npn \exp_not:N #3 { \UseInstance {##1} } }
+              }
             \prop_put:Non \l_@@_vars_prop
               \l_@@_key_name_tl {#2#3}
           }





More information about the latex3-commits mailing list.