[latex3-commits] [git/LaTeX3-latex3-latex2e] options: Add tests and correct some issues as a result (ca0b183b)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Dec 1 14:20:54 CET 2021


Repository : https://github.com/latex3/latex2e
On branch  : options
Link       : https://github.com/latex3/latex2e/commit/ca0b183b0fcca809912a07c5b08d32f7c993db8c

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

commit ca0b183b0fcca809912a07c5b08d32f7c993db8c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Dec 1 13:20:09 2021 +0000

    Add tests and correct some issues as a result
    
    Not sure about the msg from \SetKeysOptions:
    formally, it takes the family not the package name.


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

ca0b183b0fcca809912a07c5b08d32f7c993db8c
 base/ltkeys.dtx                | 15 ++++++-------
 base/testfiles/github-0710.lvt | 36 +++++++++++++++++++++++++++++++
 base/testfiles/github-0710.tlg | 48 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+), 8 deletions(-)

diff --git a/base/ltkeys.dtx b/base/ltkeys.dtx
index c5043d0f..2003d352 100644
--- a/base/ltkeys.dtx
+++ b/base/ltkeys.dtx
@@ -390,13 +390,10 @@
       {
         \clist_map_inline:Nn \l_@@_tmpa_tl
           {
-            \keys_set:nn {#1}
+            \keys_define:nn {#1}
               {
                 ##1 .code:n =
-                  \prop_get:NnNTF \l_@@_options_module_prop {#1} \l_@@_tmpa_tl
-                    { \exp_args:NV \@@_options_loaded:nn \l_@@_tmpa_tl }
-                    { \@@_options_loaded:nn {#1} }
-                      {##1}
+                  \@@_options_loaded:nn {#1} {##1}
               }
           }
       }
@@ -404,9 +401,11 @@
 \cs_new_protected:Npn \@@_options_loaded:nn #1#2
   {
     \bool_if:NTF \l_@@_options_loading_bool
-      { \msg_warning:nnn { keys } { load-option-ignored } }
-      { \msg_error:nnnn { keys } { load-only } }
-        {#1} {#2}
+      {
+        \msg_warning:nnxx { keys } { load-option-ignored }
+          { \use:c { opt at fam@\@currname.\@currext } } {#2}
+      }
+      { \msg_error:nnnn { keys } { load-only } {#1} {#2} }
   }
 \msg_new:nnn { keys } { load-option-ignored }
   { Package~"#1"~has~already~been~loaded:~ignoring~load-time~option~"#2". }
diff --git a/base/testfiles/github-0710.lvt b/base/testfiles/github-0710.lvt
new file mode 100644
index 00000000..88c96d4b
--- /dev/null
+++ b/base/testfiles/github-0710.lvt
@@ -0,0 +1,36 @@
+\documentclass{article}
+\begin{filecontents}{mypkg.sty}
+\DeclareKeysOptions{
+  load-option-A .store = \my at A ,
+  load-option-A .usage = load  ,
+  load-option-B .store = \my at B ,
+  load-option-B .usage = load  ,
+  general-option-C .store = \my at C
+}
+\ProcessKeysOptions
+\newcommand\mypkgtest{%
+  \begingroup
+    \edef\x{\my at A:\my at B:\my at C}%
+    \show\x
+  \endgroup
+}
+\end{filecontents}
+\input{test2e}
+
+\START
+\AUTHOR{Joseph Wright}
+
+\usepackage[load-option-A = 111]{mypkg}                           % 1
+\mypkgtest
+\usepackage[load-option-A = 222]{mypkg}                           % 2
+\mypkgtest
+\usepackage[load-option-A = 333, general-option-C  = 333]{mypkg}  % 3
+\mypkgtest
+\usepackage{mypkg}                                                % 4
+\mypkgtest
+\usepackage[load-option-B = 555]{mypkg}                           % 5
+\mypkgtest
+\SetKeysOptions[mypkg]{load-option-A = 666}                       % 6 
+\mypkgtest
+
+\END
\ No newline at end of file
diff --git a/base/testfiles/github-0710.tlg b/base/testfiles/github-0710.tlg
new file mode 100644
index 00000000..b205d3b3
--- /dev/null
+++ b/base/testfiles/github-0710.tlg
@@ -0,0 +1,48 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+Author: Joseph Wright
+(mypkg.sty)
+> \x=macro:
+->111::.
+\mypkgtest ...f \x {\my at A :\my at B :\my at C }\show \x 
+                                                  \endgroup 
+l. ...\mypkgtest
+LaTeX3 Warning: Package "mypkg" has already been loaded: ignoring load-time
+(LaTeX3)        option "load-option-A".
+> \x=macro:
+->111::.
+\mypkgtest ...f \x {\my at A :\my at B :\my at C }\show \x 
+                                                  \endgroup 
+l. ...\mypkgtest
+LaTeX3 Warning: Package "mypkg" has already been loaded: ignoring load-time
+(LaTeX3)        option "load-option-A".
+> \x=macro:
+->111::333.
+\mypkgtest ...f \x {\my at A :\my at B :\my at C }\show \x 
+                                                  \endgroup 
+l. ...\mypkgtest
+> \x=macro:
+->111::333.
+\mypkgtest ...f \x {\my at A :\my at B :\my at C }\show \x 
+                                                  \endgroup 
+l. ...\mypkgtest
+LaTeX3 Warning: Package "mypkg" has already been loaded: ignoring load-time
+(LaTeX3)        option "load-option-B".
+> \x=macro:
+->111::333.
+\mypkgtest ...f \x {\my at A :\my at B :\my at C }\show \x 
+                                                  \endgroup 
+l. ...\mypkgtest
+! LaTeX3 Error: Key "load-option-A" may only be used in the during loading of
+(LaTeX3)        package "mypkg".
+For immediate help type H <return>.
+ ...                                              
+l. ...\SetKeysOptions[mypkg]{load-option-A = 666}
+                                                                       % 6
+LaTeX was asked to set a key called "load-option-A", but this is only allowed
+in the optional argument when loading package "mypkg".
+> \x=macro:
+->111::333.
+\mypkgtest ...f \x {\my at A :\my at B :\my at C }\show \x 
+                                                  \endgroup 
+l. ...\mypkgtest





More information about the latex3-commits mailing list.