Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to unused list when unknown key is active #1184

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* ltkeys.dtx:
Correct addition to unused option list with unknown key property (gh/1183)

2024-06-19 David Carlisle <[email protected]>

* fontdef.dtx:
Expand Down
8 changes: 5 additions & 3 deletions base/ltkeys.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltkeys.dtx}
[2024/06/20 v1.0o LaTeX Kernel (Keyval options)]
[2024/06/25 v1.0p LaTeX Kernel (Keyval options)]
% \iffalse
\documentclass{l3doc}
\GetFileInfo{ltkeys.dtx}
Expand Down Expand Up @@ -361,6 +361,8 @@
% \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/19}{Refactor function}
% \changes{v1.0p}{2024/06/25}
% {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}
Expand All @@ -387,7 +389,7 @@
{
\exp_args:Ne \@@_options_class:nnn
{ \tl_trim_spaces:e { \@@_remove_equals:n {##1} } }
{##1} {#1}
{##1} {#1}
}
}
}
Expand All @@ -400,7 +402,7 @@
}
{
\keys_if_exist:nnTF {#3} { unknown }
{ \@@_options_class:nn {#1} {#2} }
{ \clist_put_right:Nn \l_@@_options_clist {#2} }
{
\clist_if_in:NnF \@unusedoptionlist {#1}
{ \clist_put_right:Nn \@unusedoptionlist {#1} }
Expand Down
28 changes: 28 additions & 0 deletions base/testfiles/github-1183.lvt
Original file line number Diff line number Diff line change
@@ -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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an extra option which is unknown to both article and githu-1183 classes, to trigger the "Unused global option(s)" waning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still shouldn't see a warning?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a conceptual point I think that global options should be handled as follows:

  • if a package uses a global option it is marked as used (but still offered to other packages as a global option)
  • if no package uses a global option there should be an "unused global option warning"

The big question is what does this mean if a a package defines an unknown option handler?

  • Given that for the default unknown option handler (raising an unknown option error) global options are ignored one can argue that the same should happen if a different unknown option handler is implemented
  • Another possibility is to pass global options to an unknown option handler (if it is not the default) and consider them used if that happens (that means that with one such package we would automatically use all global options and there is no warning ever)
  • Finally one could implement some sort of a mix of the two by offering an interface to be used in the unknown option handler to explicitly mark a global option as used if it is passed through and is handled (not sure how that should look like exactly)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still shouldn't see a warning?

@josephwright I'm not sure which behavior is expected (#1183 has some discussions on it), but with current proposed change, if aaapaper is used as class option, it will remain in unused options list. See muzimuzhi@5875883.


\START
\begin{document}
\END
17 changes: 17 additions & 0 deletions base/testfiles/github-1183.tlg
Original file line number Diff line number Diff line change
@@ -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 ....