[latex3-commits] [git/LaTeX3-latex3-latex3] master: Enable key inheritance for defaults (fixes #504) (3008882)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jan 29 21:54:55 CET 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/3008882136867f329953e388258ebed0b683647e

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

commit 3008882136867f329953e388258ebed0b683647e
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jan 29 20:54:55 2019 +0000

    Enable key inheritance for defaults (fixes #504)


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

3008882136867f329953e388258ebed0b683647e
 l3kernel/CHANGELOG.md                   |    1 +
 l3kernel/l3keys.dtx                     |   29 +++++++++++++++++++++++++++--
 l3kernel/testfiles/m3expl001.luatex.tlg |    1 +
 l3kernel/testfiles/m3expl001.ptex.tlg   |    1 +
 l3kernel/testfiles/m3expl001.tlg        |    1 +
 l3kernel/testfiles/m3expl001.uptex.tlg  |    1 +
 l3kernel/testfiles/m3expl001.xetex.tlg  |    1 +
 l3kernel/testfiles/m3expl003.luatex.tlg |    1 +
 l3kernel/testfiles/m3expl003.ptex.tlg   |    1 +
 l3kernel/testfiles/m3expl003.tlg        |    1 +
 l3kernel/testfiles/m3expl003.uptex.tlg  |    1 +
 l3kernel/testfiles/m3expl003.xetex.tlg  |    1 +
 l3kernel/testfiles/m3keys003.lvt        |    4 +++-
 l3kernel/testfiles/m3keys003.tlg        |    3 +++
 14 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index dc40b45..b6e4ba5 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -15,6 +15,7 @@ this project uses date-based 'snapshot' version identifiers.
 ### Fixed
 
 - Handling of nested key setting when filtering, _etc._ (see #526)
+- Inheritance of default values (see #504)
 
 ## [2019-01-28]
 
diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index c4311e0..0259c89 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -2364,6 +2364,7 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_value_or_default:n}
+% \begin{macro}{\@@_default_inherit:}
 %   If a value is given, return it as |#1|, otherwise send a default if
 %   available.
 %    \begin{macrocode}
@@ -2377,12 +2378,33 @@
               \l_keys_value_tl
               { \c_@@_default_root_tl \l_keys_path_tl }
           }
-          { \tl_clear:N \l_keys_value_tl }
+          {
+            \tl_clear:N \l_keys_value_tl
+            \cs_if_exist:cT
+              { \c_@@_inherit_root_tl \@@_parent:o \l_keys_path_tl }
+              { \@@_default_inherit: }
+          }
       }
       { \tl_set:Nn \l_keys_value_tl {#1} }
   }
+\cs_new_protected:Npn \@@_default_inherit:
+  {
+    \clist_map_inline:cn
+      { \c_@@_inherit_root_tl \@@_parent:o \l_keys_path_tl }
+      {
+        \cs_if_exist:cT
+          { \c_@@_default_root_tl ##1 / \l_keys_key_tl }
+          {
+            \tl_set_eq:Nc
+              \l_keys_value_tl
+              { \c_@@_default_root_tl ##1 / \l_keys_key_tl }
+            \clist_map_break:
+          }
+      }
+  }
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\@@_execute:, \@@_execute_inherit:, \@@_execute_unknown:}
 % \begin{macro}[EXP]{\@@_execute:nn}
@@ -2567,7 +2589,10 @@
 \cs_new:Npn \@@_parent:w #1 / #2 / #3 \q_stop #4
   {
     \tl_if_blank:nTF {#2}
-      { \use_none:n #4 }
+      {
+        \tl_if_blank:nF {#4}
+          { \use_none:n #4 }
+      }
       {
         \@@_parent:w #2 / #3 \q_stop { #4 / #1 }
       }
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 9694890..fb048cb 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -3382,6 +3382,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index af6e85f..b4c2ef5 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -3675,6 +3675,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 94c2a94..0213ad0 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -3675,6 +3675,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index be1eb55..36d106d 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -3675,6 +3675,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 97fe952..f05ee00 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -3420,6 +3420,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 9694890..fb048cb 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -3382,6 +3382,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index af6e85f..b4c2ef5 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -3675,6 +3675,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 94c2a94..0213ad0 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -3675,6 +3675,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index be1eb55..36d106d 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -3675,6 +3675,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 97fe952..f05ee00 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -3420,6 +3420,7 @@ Defining \__keys_find_key_module:w on line ...
 Defining \__keys_set_selective: on line ...
 Defining \__keys_check_groups: on line ...
 Defining \__keys_value_or_default:n on line ...
+Defining \__keys_default_inherit: on line ...
 Defining \__keys_execute: on line ...
 Defining \__keys_execute_inherit: on line ...
 Defining \__keys_execute_unknown: on line ...
diff --git a/l3kernel/testfiles/m3keys003.lvt b/l3kernel/testfiles/m3keys003.lvt
index 3708f824..0a8b541 100644
--- a/l3kernel/testfiles/m3keys003.lvt
+++ b/l3kernel/testfiles/m3keys003.lvt
@@ -160,6 +160,7 @@
     \keys_define:nn { module }
       {
         key-one .code:n = \tl_show:n {#1} , 
+        key-one .default:n = foo ,
         key-two .choices:nn = { a , b } { \tl_show:n {#1} }
       }
     \keys_define:nn { module-two }
@@ -169,7 +170,8 @@
     \keys_set:nn { module-two / path }
       {
         key-one = a ,
-        key-two = b
+        key-two = b ,
+        key-one
       }
     \keys_set:nn { module-two / path }
       {
diff --git a/l3kernel/testfiles/m3keys003.tlg b/l3kernel/testfiles/m3keys003.tlg
index 8f37e9d..f745697 100644
--- a/l3kernel/testfiles/m3keys003.tlg
+++ b/l3kernel/testfiles/m3keys003.tlg
@@ -136,6 +136,9 @@ l. ...  }
 > b.
 <recently read> }
 l. ...  }
+> foo.
+<recently read> }
+l. ...  }
 ! LaTeX3 Error: The key 'module-two/path/key-not-defined' is unknown and is
 (LaTeX3)        being ignored.
 For immediate help type H <return>.





More information about the latex3-commits mailing list