[latex3-commits] [git/LaTeX3-latex3-latex2e] develop: Add \DeclareUnknownKeysHandler (5de565da)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Feb 16 00:06:37 CET 2022


Repository : https://github.com/latex3/latex2e
On branch  : develop
Link       : https://github.com/latex3/latex2e/commit/5de565da21f1f0cc6a75981b230bcc6b1ac54a70

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

commit 5de565da21f1f0cc6a75981b230bcc6b1ac54a70
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Feb 15 23:06:37 2022 +0000

    Add \DeclareUnknownKeysHandler


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

5de565da21f1f0cc6a75981b230bcc6b1ac54a70
 base/changes.txt |  1 +
 base/ltkeys.dtx  | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/base/changes.txt b/base/changes.txt
index ec575ae7..477c0d9b 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -11,6 +11,7 @@ are not part of the distribution.
 
         * ltkeys.dtx:
         Expand optional module argument in design-level commands
+        Add \DeclareUnknownKeysHandler
 
 2022-02-07  Joseph Wright  <Joseph.Wright at latex-project.org>
 
diff --git a/base/ltkeys.dtx b/base/ltkeys.dtx
index a15b2b45..b71f536d 100644
--- a/base/ltkeys.dtx
+++ b/base/ltkeys.dtx
@@ -364,7 +364,23 @@
 %   function to allow for potential set-up steps.
 %    \begin{macrocode}
 \NewDocumentCommand \DeclareKeys { O { \@currname } +m }
-  { \exp_args:Nf \keys_define:nn \keys_define:nn {#1} {#2} }
+  { \exp_args:Nf \keys_define:nn {#1} {#2} }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DeclareUnknownKeysHandler}
+%    \begin{macrocode}
+\NewDocumentCommand \DeclareUnknownKeysHandler { O { \@currname } +m }
+  {
+    \cs_set_protected:cpn { @@_unknown_handler_ #1 :nn } ##1##2 {#2}
+    \exp_args:Nxx \keys_define:nn {#1}
+      {
+        unknown .code:n = 
+          \exp_not:N \exp_args:NV
+            \exp_not:c { @@_unknown_handler_ #1 :nn }
+            \exp_not:N \l_keys_key_str {####1}
+      }
+  }
 %    \end{macrocode}
 % \end{macro}
 %





More information about the latex3-commits mailing list.