[latex3-commits] [git/LaTeX3-latex3-latex2e] rawoptions: Saving raw option lists (a67105c6)
David Carlisle
d.p.carlisle at gmail.com
Wed Aug 26 00:42:31 CEST 2020
Repository : https://github.com/latex3/latex2e
On branch : rawoptions
Link : https://github.com/latex3/latex2e/commit/a67105c63cf9d97e4bba3e81ef73f45199eaad8a
>---------------------------------------------------------------
commit a67105c63cf9d97e4bba3e81ef73f45199eaad8a
Author: David Carlisle <d.p.carlisle at gmail.com>
Date: Mon Nov 12 00:50:53 2018 +0000
Saving raw option lists
option handler ammended to save \@raw at opt@... in addition to \opt at ...
so that it is available for extended option handlers,
eg in kvoptions.sty (hyperref) defining
\def\KVO at ProcessKeyvalOptions#1{%
\expandafter\ifx\csname @raw at opt@\@currname.\@currext\endcsname\relax
\else
\expandafter\let\csname opt@\@currname.\@currext\expandafter\endcsname\csname @raw at opt@\@currname.\@currext\endcsname
\fi
...
would allow
\usepackage[ colorlinks , pdftitle=A perfect day , pdfborder=0 0 0]{hyperref}
with spaces in values preserved,
To avoid the extended values breaking existing option handling the
unused option list processing is extended so that after [x=y] only
"x" is added to the unused option list (the mechanism used to remove
items from the unused option list does not allow {}).
This change should have no effect on existing documents other than
possible different text in an unused global option warning.
unless an extended option handler is used that takes advantage of the
raw data.
>---------------------------------------------------------------
a67105c63cf9d97e4bba3e81ef73f45199eaad8a
base/ltclass.dtx | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 115 insertions(+), 5 deletions(-)
diff --git a/base/ltclass.dtx b/base/ltclass.dtx
index 056632e6..fcbaa8e2 100644
--- a/base/ltclass.dtx
+++ b/base/ltclass.dtx
@@ -1030,19 +1030,46 @@
% \begin{macro}{\PassOptionsToClass}
% If the package has been loaded, we check that it was first loaded with
% the options. Otherwise we add the option list to that of the package.
+% \changes{v1.3a}{2018/11/11}{save raw option lists}
% \begin{macrocode}
+%</2ekernel>
+%<latexrelease>\IncludeInRelease{2018/12/01}%
+%<latexrelease> {\@pass at ptions}{Raw option lists}%
+%<*2ekernel|latexrelease>
\def\@pass at ptions#1#2#3{%
\expandafter\xdef\csname opt@#3.#1\endcsname{%
\@ifundefined{opt@#3.#1}\@empty
{\csname opt@#3.#1\endcsname,}%
- \zap at space#2 \@empty}}
+ \zap at space#2 \@empty}%
+% \end{macrocode}
+% Extend raw option list
+% \begin{macrocode}
+ \@ifundefined{@raw at opt@#3.#1}%
+ {\expandafter\gdef\csname @raw at opt@#3.#1\endcsname{#2}}%
+ {\expandafter\g at addto@macro\csname @raw at opt@#3.#1\endcsname{,#2}}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\@pass at ptions}{Raw option lists}%
+%<latexrelease>\def\@pass at ptions#1#2#3{%
+%<latexrelease> \expandafter\xdef\csname opt@#3.#1\endcsname{%
+%<latexrelease> \@ifundefined{opt@#3.#1}\@empty
+%<latexrelease> {\csname opt@#3.#1\endcsname,}%
+%<latexrelease> \zap at space#2 \@empty}}
+%<*2ekernel>
+% \end{macrocode}
+%
+% \begin{macrocode}
\@onlypreamble\@pass at ptions
% \end{macrocode}
%
% \begin{macrocode}
\def\PassOptionsToPackage{\@pass at ptions\@pkgextension}
\def\PassOptionsToClass{\@pass at ptions\@clsextension}
-\@onlypreamble\PassOptionsToPackage
\@onlypreamble\PassOptionsToClass
% \end{macrocode}
% \end{macro}
@@ -1077,18 +1104,48 @@
% \end{macro}
%
% \begin{macro}{\OptionNotUsed}
+% \changes{v1.3a}{2018/11/11}{filter out =value from unused option list}
+% \begin{macro}{\@remove at eq@value}
+% \changes{v1.3a}{2018/11/11}{macro added}
% If we are in a class file, add |\CurrentOption| to the list of
% unused options. Otherwise, in a package file do nothing.
% \begin{macrocode}
+%</2ekernel>
+%<latexrelease>\IncludeInRelease{2018/12/01}%
+%<latexrelease> {\OptionNotUsed}{filter unused option list}%
+%<*2ekernel|latexrelease>
+\def\@remove at eq@value#1=#2\@nil{#1}
+% \end{macrocode}
+%
+% \begin{macrocode}
\def\OptionNotUsed{%
\ifx\@currext\@clsextension
\xdef\@unusedoptionlist{%
\ifx\@unusedoptionlist\@empty\else\@unusedoptionlist,\fi
- \CurrentOption}%
+ \expandafter\@remove at eq@value\CurrentOption=\@nil}%
\fi}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\OptionNotUsed}{filter unused option list}%
+%<latexrelease>\let\@remove at eq@value\@undefined
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<latexrelease>\def\OptionNotUsed{%
+%<latexrelease> \ifx\@currext\@clsextension
+%<latexrelease> \xdef\@unusedoptionlist{%
+%<latexrelease> \ifx\@unusedoptionlist\@empty\else\@unusedoptionlist,\fi
+%<latexrelease> \CurrentOption}%
+%<latexrelease> \fi}
+%<*2ekernel>
+% \end{macrocode}
+%
+% \begin{macrocode}
\@onlypreamble\OptionNotUsed
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\default at ds}
% The default option code.
@@ -1239,11 +1296,29 @@
% {Name changed from \cs{@executeoption}}
% \changes{v1.0e}{1994/05/17}
% {Execute option after removing from list, not before}
+% \changes{v1.3a}{2018/11/11}{filter out =value from unused option list}
% \begin{macrocode}
+%</2ekernel>
+%<latexrelease>\IncludeInRelease{2018/12/01}%
+%<latexrelease> {\@use at ption}{filter unused option list}%
+%<*2ekernel|latexrelease>
\def\@use at ption{%
- \@expandtwoargs\@removeelement\CurrentOption
+ \@expandtwoargs\@removeelement
+ {\expandafter\@remove at eq@value\CurrentOption=\@nil}%
\@unusedoptionlist\@unusedoptionlist
\csname ds@\CurrentOption\endcsname}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\@use at ption}{filter unused option list}%
+%<latexrelease>\def\@use at ption{%
+%<latexrelease> \@expandtwoargs\@removeelement\CurrentOption
+%<latexrelease> \@unusedoptionlist\@unusedoptionlist
+%<latexrelease> \csname ds@\CurrentOption\endcsname}
+%<*2ekernel>
+% \end{macrocode}
+%
+% \begin{macrocode}
\@onlypreamble\@use at ption
% \end{macrocode}
% \end{macro}
@@ -1557,15 +1632,23 @@
% {Prevent loss of brackets PR/3965}
% \changes{v2.1b}{2016/11/09}
% {Improve \cs{ifx} tests PR/4497}
+% \changes{v1.3a}{2018/11/11}{save raw class option list}
% \begin{macrocode}
%</2ekernel>
-%<latexrelease>\IncludeInRelease{2017/01/01}%
+%<latexrelease>\IncludeInRelease{2018/12/01}%
%<latexrelease> {\@fileswith at pti@ns}{ifx tests in \@fileswith at pti@ns}%
%<*2ekernel|latexrelease>
\def\@fileswith at pti@ns#1[#2]#3[#4]{%
\ifx#1\@clsextension
\ifx\@classoptionslist\relax
\xdef\@classoptionslist{\zap at space#2 \@empty}%
+% \end{macrocode}
+% Save raw class list.
+% \begin{macrocode}
+ \gdef\@raw at classoptionslist{#2}%
+% \end{macrocode}
+%
+% \begin{macrocode}
\def\reserved at a{%
\@onefilewithoptions#3[{#2}][{#4}]#1%
\@documentclasshook}%
@@ -1604,6 +1687,33 @@
\fi
\reserved at a}
%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2017/01/01}%
+%<latexrelease> {\@fileswith at pti@ns}{ifx tests in \@fileswith at pti@ns}%
+%<latexrelease>\def\@fileswith at pti@ns#1[#2]#3[#4]{%
+%<latexrelease> \ifx#1\@clsextension
+%<latexrelease> \ifx\@classoptionslist\relax
+%<latexrelease> \xdef\@classoptionslist{\zap at space#2 \@empty}%
+%<latexrelease> \def\reserved at a{%
+%<latexrelease> \@onefilewithoptions#3[{#2}][{#4}]#1%
+%<latexrelease> \@documentclasshook}%
+%<latexrelease> \else
+%<latexrelease> \def\reserved at a{%
+%<latexrelease> \@onefilewithoptions#3[{#2}][{#4}]#1}%
+%<latexrelease> \fi
+%<latexrelease> \else
+%<latexrelease> \def\reserved at b##1,{%
+%<latexrelease> \ifx\@nnil##1\relax\else
+%<latexrelease> \ifx\@nnil##1\@nnil\else
+%<latexrelease> \noexpand\@onefilewithoptions##1[{#2}][{#4}]%
+%<latexrelease> \noexpand\@pkgextension
+%<latexrelease> \fi
+%<latexrelease> \expandafter\reserved at b
+%<latexrelease> \fi}%
+%<latexrelease> \edef\reserved at a{\zap at space#3 \@empty}%
+%<latexrelease> \edef\reserved at a{\expandafter\reserved at b\reserved at a,\@nnil,}%
+%<latexrelease> \fi
+%<latexrelease> \reserved at a}
% \end{macrocode}
%
% \begin{macrocode}
More information about the latex3-commits
mailing list.