1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
%\iffalse
% !TEX program = pdflatex
% !TEX encoding = ISO-8859-1
%<*internal>
\iffalse
%</internal>
%<*readme>
---------------------------------------------------------------
The keys3opts2 package --- Using keys3 for LaTeX2e options
Maintained by Joseph Wright
E-mail: joseph.wright@morningstar2.co.uk
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
---------------------------------------------------------------
The keys3 package is an experimental implementation of key
management for LaTeX3. The entire package is written in
expl3 code rather than in traditional TeX/LaTeX. The
keys3opts2 package provides a mechanism to allow load-time
option processed using keys3 in LaTeX2e.
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
---------------------------------------------------------------
The keys3opts2 package --- Using keys3 for LaTeX2e options
Maintained by Joseph Wright
E-mail: joseph.wright@morningstar2.co.uk
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
---------------------------------------------------------------
EXPERIMENTAL CODE
Do not distribute this file without also distributing the
source files specified above.
Do not distribute a modified version of this file.
\endpreamble
\postamble
Copyright (C) 2008-2009 by
Joseph Wright <joseph.wright@morningstar2.co.uk>
It may be distributed and/or modified under the conditions of
the LaTeX Project Public License (LPPL), either version 1.3c of
this license or (at your option) any later version. The latest
version of this license is in the file:
http://www.latex-project.org/lppl.txt
This work is "maintained" (as per LPPL maintenance status) by
Joseph Wright.
This work consists of the file keys3opts2.dtx
and the derived files keys3opts2.pdf,
keys3opts2.sty and
keys3opts2.ins.
\endpostamble
\usedir{tex/latex/keys3}
\generate{
\file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/keys3}
\generate{
\file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</internal>
%<*driver|package>
\RequirePackage{l3names}
\GetIdInfo$Id: keys3opts2.dtx 93 2009-05-03 20:34:46Z josephwright $
{Using keys3 for LaTeX2e options}
%</driver|package>
%\fi
%\iffalse
%<*driver>
%\fi
\ProvidesFile{\filename.\filenameext}
[\filedate\space v\fileversion\space\filedescription]
%\iffalse
\documentclass[full]{l3doc}
\begin{document}
\DocInput{\filename.\filenameext}
\end{document}
%</driver>
% \fi
%
% \title{The \textsf{keys3opts2} package^^A
% \thanks{This file has version number \fileversion, last
% revised \filedate.}\\
% Using \textsf{keys3} for \LaTeXe\ options}
% \author{Joseph Wright^^A
% \thanks{E-mail: joseph.wright@morningstar2.co.uk}}
% \date{\filedate}
% \maketitle
%
%\section{Package options}
%
% The methods that \LaTeX3 will use to process package options are not
% clear at the present time. However, in order to fully test the
% \pkg{expl3} bundle fully, it is useful to be able to work with
% the \LaTeXe\ system but using \LaTeX3 methods as far as possible.
%
% The \pkg{keys3} package provides an experimental method for
% managing key--value input using \pkg{expl3} syntax. It is
% self-contained and does not use any \LaTeXe methods. On the other
% hand, \pkg{keys3opts2} is intended as a ``bridge'' between the
% \LaTeXe\ kernel and \textsf{keys3}. It allows keys to be created
% using \pkg{keys3} and processed by \LaTeXe\ as package or class
% options.
%
%\subsection{functions}
%
% \begin{function}{\keys_options_ltx:n}
% \begin{syntax}
% "\keys_options_ltx:n" <module>
% \end{syntax}
% The only macro for outside use. Processes the current option list
% using the currently defined keys, checking if they exist for
% <module>.
% \end{function}
%
% \begin{function}{
% \keys_options_ltx_cls:n|
% \keys_options_ltx_pkg:n
% }
% \begin{syntax}
% "\keys_options_ltx_cls:n" <option>
% \end{syntax}
% Helper macros for processing class and package options,
% respectively.
% \end{function}
%
% \begin{function}{\keys_options_ltx_strip_eq:w}
% \begin{syntax}
% "\keys_options_ltx_strip_eq:w" <option> "\q_stop"
% \end{syntax}
% Used to strip ``\texttt{=}'' out of options.
% \end{function}
%
% \begin{variable}{\l_keys_options_ltx_clist}
% Storage area for option list.
% \end{variable}
%
%\subsection{Implementation}
%
% Almost everything here is based heavily on \pkg{pgfopts}, which is
% itself a port of the appropriate code from \pkg{kvoptions} to work
% with \pkg{pgfkeys}.
%
% As this package is an add-on to \pkg{keys3}, the same internal
% module name (|\keys_|) is used here as in the main package. The lead
% off as usual.
% \begin{macrocode}
%<*package>
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
\RequirePackage{keys3}
% \end{macrocode}
%
%\begin{macro}{\l_keys_options_ltx_clist}
% A simple storage area.
% \begin{macrocode}
\clist_new:N \l_keys_options_ltx_clist
% \end{macrocode}
%\end{macro}
%
%\begin{macro}{\keys_options_ltx:n}
% As this is a minimal testing package, a lot of the complexity of the
% normal \LaTeX\ options is ignored. Here, the package insists a path
% is given for the keys. First, a path may need to be added to the
% argument given. The path we need to process is then stored in
% \cs{l_keys_current_key_tl}.
% \begin{macrocode}
\cs_new:Nn \keys_options_ltx:n {
\tl_set:Nx \l_keys_current_key_tl {#1}
\keys_path_add:N \l_keys_current_key_tl
\clist_clear:N \l_keys_options_ltx_clist
\cs_if_eq:NNTF \@currext \@clsextension {
\cs_if_free:cF { opt@ \@currname . \@currext } {
\clist_map_function:cN { opt@ \@currname . \@currext }
\keys_options_ltx_cls:n
}
}{
\cs_if_free:NF \@classoptionslist {
\clist_map_function:NN \@classoptionslist \keys_options_ltx_pkg:n
}
\cs_if_free:cF { opt@ \@currname . \@currext } {
\exp_args:NNc \clist_concat:NNN \l_keys_options_ltx_clist
{ opt@ \@currname . \@currext } \l_keys_options_ltx_clist
}
}
\clist_put_left:Nn \l_keys_options_ltx_clist { #1 /.cd: }
\exp_args:NV \keys_manage:n \l_keys_options_ltx_clist
\AtEndOfPackage { \cs_set_eq:NN \@unprocessedoptions \scan_stop: }
}
% \end{macrocode}
%\end{macro}
%\begin{macro}{\keys_options_ltx_cls:n}
% This macro checks if the current class option is a known key. To do
% that, any ``\texttt{=}'' part has to be removed first.
% \begin{macrocode}
\cs_new:Nn \keys_options_ltx_cls:n {
\keys_if_cmd_exist:nTF {
\l_keys_current_key_tl / \keys_options_ltx_strip_eq:w #1 = \q_stop
}{
\clist_put_right:Nn \l_keys_options_ltx_clist {#1}
}{
\clist_put_right:Nn \@unusedoptionlist {#1}
}
}
% \end{macrocode}
%\end{macro}
%\begin{macro}{\keys_options_ltx_pkg:n}
% For packages, options need to be removed from the global list.
% \begin{macrocode}
\cs_new:Nn \keys_options_ltx_pkg:n {
\keys_if_cmd_really_exist:nT {
\l_keys_current_key_tl / \keys_options_ltx_strip_eq:w #1 = \q_stop
}{
\clist_put_right:Nn \l_keys_options_ltx_clist {#1}
\clist_remove_element:Nn \@unusedoptionlist {#1}
}
}
% \end{macrocode}
%\end{macro}
%
%\begin{macro}{\keys_options_ltx_strip_eq:w}
% A simple method to remove an equals sign plus any trailing data.
% \begin{macrocode}
\cs_new:Npn \keys_options_ltx_strip_eq:w #1 = #2 \q_stop {#1}
%</package>
% \end{macrocode}
%\end{macro}
%
%\Finale
|