From ec5c318aae2e09b7ba46b4e228a732acfa34aa82 Mon Sep 17 00:00:00 2001 From: Joseph Wright Date: Mon, 20 Nov 2023 11:13:33 +0000 Subject: [PATCH] Add options to unused list when unknown key is active --- base/changes.txt | 4 ++++ base/ltkeys.dtx | 19 +++++++++++++------ base/testfiles/github-1183.lvt | 28 ++++++++++++++++++++++++++++ base/testfiles/github-1183.tlg | 17 +++++++++++++++++ 4 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 base/testfiles/github-1183.lvt create mode 100644 base/testfiles/github-1183.tlg diff --git a/base/changes.txt b/base/changes.txt index 37d22f6a3..c2b6d0d4c 100644 --- a/base/changes.txt +++ b/base/changes.txt @@ -6,6 +6,10 @@ to completeness or accuracy and it contains some references to files that are not part of the distribution. ================================================================================ +2024-06-03 Joseph Wright + * ltkeys.dtx: + Correct addition to unused option list with unknown key property (gh/1183) + ================================================================================ All changes above are only part of the development branch for the next release. ================================================================================ diff --git a/base/ltkeys.dtx b/base/ltkeys.dtx index 34a0ab4b4..87365fd13 100644 --- a/base/ltkeys.dtx +++ b/base/ltkeys.dtx @@ -33,7 +33,7 @@ %<*driver> % \fi \ProvidesFile{ltkeys.dtx} - [2024/01/13 v1.0m LaTeX Kernel (Keyval options)] + [2024/06/03 v1.0n LaTeX Kernel (Keyval options)] % \iffalse \documentclass{l3doc} \GetFileInfo{ltkeys.dtx} @@ -295,6 +295,8 @@ % \changes{v1.0h}{2022/06/19}{Further work on handling of option removal} % \changes{v1.0h}{2022/06/20}{Use raw options data} % \changes{v1.0m}{2024/01/13}{Trim spaces off key names} +% \changes{v1.0n}{2024/06/03} +% {Correct unused option tracking where unknown keys are allowed} % \begin{macro}{\@@_options_class:nnn} % \changes{v1.0h}{2022/06/20}{New function} % \changes{v1.0i}{2022/07/05}{Correct naming of raw class options storage} @@ -310,10 +312,11 @@ { \cs_if_free:cF { @raw@opt@ \@currname . \@currext } { - \keys_if_exist:nnTF {#1} { unknown } + \clist_map_inline:cn { @raw@opt@ \@currname . \@currext } { - \clist_put_right:Nv \l_@@_options_clist - { @raw@opt@ \@currname . \@currext } + \exp_args:Ne \@@_options_class:nnn + { \@@_remove_equals:n {##1} } + {##1} {#1} } { \clist_map_inline:cn { @raw@opt@ \@currname . \@currext } @@ -333,8 +336,12 @@ \clist_remove_all:Nn \@unusedoptionlist {#1} } { - \clist_if_in:NnF \@unusedoptionlist {#1} - { \clist_put_right:Nn \@unusedoptionlist {#1} } + \keys_if_exist:nnTF {#3} { unknown } + { \clist_put_right:Nn \l_@@_options_clist {#2} } + { + \clist_if_in:NnF \@unusedoptionlist {#1} + { \clist_put_right:Nn \@unusedoptionlist {#1} } + } } } % \end{macrocode} diff --git a/base/testfiles/github-1183.lvt b/base/testfiles/github-1183.lvt new file mode 100644 index 000000000..37941f55b --- /dev/null +++ b/base/testfiles/github-1183.lvt @@ -0,0 +1,28 @@ +\input{test2e} + +\begin{filecontents}[overwrite]{github-1183.cls} +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{github-1183} +\LoadClassWithOptions{article} + +\DeclareKeys[testwork]{% + test .code = \newcommand{\foo}{#1}, + test .usage = load, + % the following three lines give an equivalent definition of your bertha + % option as defined with `\DeclareOption{bertha}{}` + bertha .code = {}, + bertha .value_forbidden:n = true, + bertha .usage = load, + % if you use this unknown handler, you get "test" and "bertha" as unknown + % options, if you omit it you get "a4paper" as unknown option + unknown .code = {} +} +\ProcessKeyOptions[testwork] + +\endinput +\end{filecontents} +\documentclass[a4paper,test=wtf,bertha]{github-1183} + +\START +\begin{document} +\END \ No newline at end of file diff --git a/base/testfiles/github-1183.tlg b/base/testfiles/github-1183.tlg new file mode 100644 index 000000000..af264c89d --- /dev/null +++ b/base/testfiles/github-1183.tlg @@ -0,0 +1,17 @@ +This is a generated file for the LaTeX2e validation system. +Don't change this file in any respect. +(github-1183.aux) +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line .... +LaTeX Font Info: ... okay on input line .... +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line .... +LaTeX Font Info: ... okay on input line .... +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line .... +LaTeX Font Info: ... okay on input line .... +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line .... +LaTeX Font Info: ... okay on input line .... +LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line .... +LaTeX Font Info: ... okay on input line .... +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line .... +LaTeX Font Info: ... okay on input line .... +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line .... +LaTeX Font Info: ... okay on input line ....