Debian Codegraph @

texmf-dist/doc/latex/skeyval/README

raw
1 This is the README file for the 'skeyval' package.
2
3 AUTHOR
4
5 Ahmed Musa
6
7 VERSION
8
9 Version 1.3, 2013/05/15.
10
11 LOCATION ON CTAN
12
13 macros/latex/contrib/skeyval
14
15 ANNOUNCEMENT TEXT
16
17 The package integrates the features of xkeyval and of pgfkeys by
18 introducing a new set of handlers. Style keys, links, changing
19 key callbacks and values on the fly, and other features of pgfkeys
20 are introduced in a new context.
21
22 LICENSE
23
24 Copyright (c) 2010-2013 Ahmed Musa
25
26 This software is author-maintained. Permission is granted to copy,
27 distribute and/or modify this software under the terms of the
28 LaTeX Project Public License, version 1.3 or higher. This software
29 is provided 'as it is', without warranty of any kind, either
30 expressed or implied, including, but not limited to, the implied
31 warranties of merchantability and fitness for any particular purpose.
32
33
34 FILES
35
36 The following files constitute the skeyval bundle and must be
37 distributed as a whole:
38
39 README, skeyval.sty, skeyval-core.tex, skeyval-for.tex,
40 skeyval-view.sty, skeyval-ltxpatch.sty, skeyval-ltxcmds.tex,
41 skeyval-pstkey.sty, skeyval-pstkey.tex, skeyval-testclass.cls,
42 skeyval-testpkg.sty, skeyval-pokayoke1.tex, skeyval-pokayoke2.tex,
43 skeyval-view-pokayoke1.tex.
44
45 The skeyval package can be used by LaTeX and non-LaTeX users. LaTeX users
46 should load the package via
47
48 \usepackage[<options>]{skeyval}
49
50 or, in class files and packages,
51
52 \RequirePackage[<options>]{skeyval}
53
54 Plain TeX users can do
55
56 \input skeyval-core
57
58 Users of pre-version-1.0 of skeyval package can access the former
59 version by entering the option 'compatibility' in <options> above.
60 This option will automatically load version 0.73 (the version
61 just before 1.0) of skeyval package. From version 1.0, the package
62 has changed radically. Please accept my sincere apologies for making
63 changes to the implementation and command names without renaming
64 the package. I hate the practice of creating many forks of the same
65 package, irrespective of the fact that forking a package is rather
66 a standard practice in LaTeX.
67
68
69 SUMMARY
70
71 The 's' in skeyval means 'skeleton' or 'master' keys.
72
73 The skeyval package provides commands for compactly defining and
74 initializing all types of key (ordinary, command, boolean, style, choice,
75 etc). It attempts to combine the features of xkeyval package and
76 pgfkeys package. One of the powers of pgfkeys package lies in its use
77 of handlers. But the way handlers are used in pgfkeys package does add
78 to computational complexity and overheads. Family or key filtering in
79 pgfkeys is particularly complex and inefficient. Nesting of family or
80 key filtering is, in particular, not recommended.
81
82 In pgfkeys package, handlers come at the end of the key name, so that
83 if a key isn't defined, the system tests to find if the key has a
84 handler at its end. If a handler is found and defined, the handler's
85 callback (called 'code' by pgfkeys package) is executed on the
86 current path. The required search overhead isn't insignificant.
87
88 The skeyval package puts handlers at the beginning of the key
89 (or a set of keys) and uses the handler to process the key (or a set
90 of keys). This speeds up key processing and reduces the computational
91 complexity. Key processing, including filtering, can be nested
92 naturally and efficiently.
93
94 The skeyval package also maintains and, in fact, greatly extends the
95 functionality and syntaxes of the xkeyval and ltxkeys packages.
96
97 Some of the features of skeyval vs. xkeyval are as follows. All the
98 features listed below could be incorporated in xkeyval package but
99 at a great expense.
100
101 * xkeyval's use of the rather expensive selective sanitization
102 scheme of Uwe Kern;
103
104 * xkeyval strips three levels of outer braces in the values of keys;
105
106 * the impossibility of parsing unbalanced conditionals in key values
107 while using xkeyval;
108
109 * xkeyval requires a large payload for defining many keys in the
110 same family;
111
112 * when using xkeyval, existing keys could be easily overridden
113 (there is nothing like \newcommand functionality);
114
115 * key macros, once defined by xkeyval, are difficult to modify/patch;
116
117 * key macros defined by xkeyval can't accept more than one argument;
118
119 * xkeyval provides no machinery for deploying style (subject/observer)
120 keys;
121
122 * xkeyval offers no direct tools for key-commands and key-environments;
123
124 * xkeyval can't be loaded before \documentclass (eg, in the past the
125 fontspec package needed this feature);
126
127 * skeyval offers 'list processor keys' (called 'listkeys').
128
129
130 Very few examples of the functionality of skeyval package are given in
131 the following.
132
133 ** Ordinary, command/store, boolean, toggle, and choice keys can be
134 defined and set. For example,
135
136 \skvordkeys[KV]{fam}{key1,key2}[default value]{%
137 \def\testcmd##1##2{#1+##1+##2}%
138 }
139 \skvoptionkeys[KV]{fam}{key1}
140 \skvnonoptionkeys[KV]{fam}{key2}
141
142 \skvchoicekeys[KV]{fam}[mp@]{key1,key2}[\val\nr]{%
143 center.do=\def\vala{#1},
144 right.do=\def\valb{#1},
145 left.do=\def\valc{#1}
146 }[center]{\def\x##1{#1*##1}}
147
148 ** Apart from the usual keys in xkeyval and ltxkeys packages, it is
149 now possible to define a rather weird key like
150
151 \skvpntkey[KV]{fam}{evaluate (?) as (?) using (?)}{\edef#2{#3}}
152
153 The key name here is 'evaluate (?) as (?) by (?)'. It has three
154 arguments, indicated by the closed parenthesis. The mark '?' can be
155 replaced by any character or characters, and the key could have up
156 to 9 arguments. This key can be set as
157
158 \skvsetkeys[KV]{fam}{evaluate (\x) as (\y) using (\numexpr\x*2)}
159
160 We can also define the same key with the default values specified:
161
162 \skvpntkey[KV]{fam}{evaluate (?) as (?) using (?)}[\x\y{\numexpr\x*2}]{%
163 \def\argone{#1}\def\argtwo{#2}\def\argthree{#3}%
164 }
165
166 and set it as follows (if pgfmath package is loaded):
167
168 \skvsetkeys[KV]{fam}{%
169 evaluate (\x) as (\pgfmathresult) using (\pgfmathparse{\x^10})
170 }
171
172 ** Default prefix can be set by
173
174 \skvsetdefaultprefix{<pref>}
175
176 For a fixed prefix, this can be used to avoid repeated entry of the
177 key prefix in many of the commands of the skeyval package. Note,
178 however, that the first '[]' in
179
180 \skvordkey[KV]{fam}{key1}[deafult value]{}
181
182 still can't be used for any other thing than the key prefix.
183
184 With
185
186 \skvsetdefaultprefix{myprefix}
187
188 we can do
189
190 \skvordkey{fam}{key1}[deafult1]{}
191 \skvcmdkey{fam}[mp@]{key2}[deafultx,defaulty]{%
192 \def\cmd##1{#1+#2+##1}%
193 }
194 \skvassignargs{fam}{key2}{.expanded{#1,#2}}
195
196 and much later
197
198 \def\valuex{valuex}
199 \def\valuey{valuey}
200 \skvsetkeys[myprefix]{fam}{key1=value1,key2={\valuex,\valuey}}
201
202 ** The callbacks of keys can be readily modified using commands
203 like \skvaddtocallback, \skvprependtocallback, \skvappendtocallback,
204 or (within \directkeys) using the handlers .prepend code, .append code,
205 .add code.
206
207 ** Handlers
208
209 The skeyval package has many handlers. The handlers of skeyval package
210 start with a dot (.), as in pgfkeys package.
211
212 Unlike in pgfkeys package, when 'expand' or 'expanded'
213 is found in a handler, the expansion will invariably be done
214 when the key is set, not when it's being defined.
215
216
217 ** Subject-observer keys (called 'style keys' in pgfkeys) can be readily
218 introduced.
219
220 \skvappendstyles[KV]{fam}{key1,key2}{keya=.expanded{\vala},keyb=valb}
221 [default of key1&2]{\def\y##1{#1*##1}}
222
223 Here the subjects/observable are key1 and key2, while the observers are keya
224 and keyb. For now, the only thing the subject does is to set the given values
225 of the observers on the current path. In the future, we intend to extend
226 the subject-observer functionality to include more features of the
227 observer pattern found in other programming paradigms. We foresee that
228 subjects will be able to publish their services, and observer keys will be
229 able to subscribe for notification from subjects. And rather than having
230 'notify messages' simply setting observer keys with prior prescribed
231 observer values, which is what is currently obtainable, observers may be
232 able to do more with such messages (such as change observer state patterns).
233
234 ** The parameters/arguments of callbacks of keys can be easily changed
235 by calling \skvdefinekeys, \skvmakekeys, \skvassignargs or \directkeys.
236
237 \skvordkeys[KV1]{fam2}{keya,keyb}[default-a]{\def\x##1{#1*##1}}
238 \skvassignargs[KV1,KV2]{fam1,fam2}{keya,keyb}{.expand{#1/#2}}
239 \skvsetkeys[KV1]{fam2}{keya=vala/valb}
240
241 ** \directkeys command:
242
243 \directkeys{%
244 .exec code=\def\avalue{a+b},
245 .paths={KV1/fam1,KV1/fam2,KV2/fam1,KV2/fam2},
246 .holder prefix=mp@,
247 .initialize keys after define,
248 .define keys={
249 .ord/keya/def-a/\def\xa##1{#1*##1*#2},
250 .arg/keya/#1+#2,
251 .cmd/.value required{keyb}/def-b/\def\cmdb##1{##1@#1},
252 },
253 .initial values={
254 keya=ini-value,
255 },
256 .ignore family=fam2,
257 .set keys={
258 keya=.expanded{\avalue}
259 },
260
261 ** Nested \directkeys. The current path is put on stack
262 and restored later, so that the nest is independent
263 of its surrounding topology (prefix and family). But
264 the default prefix survives outside \directkeys.
265
266 \directkeys{
267 .default prefix=KV,
268 % The prefix for 'famx' will be 'KV'.
269 .paths={KV3/fam3,KV3/famx},
270 .new keys={
271 .initialize keys after define=false,
272 .ord/keya/defa/\def\ya##1{#1*##1*#2},
273 .arg/keya/#1+#2,
274 .choice/keyc/center/{right,left,center,justified},
275 .arg expanded/keyc/#1,
276 .bool/keyd/true,
277 .cmd/.forbid value{keye}/defe/\def\ye##1{#1*##1},
278 },
279 },
280 .try set keys={
281 .paths={KV1/fam1,KV3/fam3},
282 .try=2,
283 .goal=1,
284 .kv list={keyc=left,keyd=false},
285 },
286 .ignore path=KV1/fam1,
287 .exec=\def\cvalue{center},
288 .search also set keys={
289 .add prefix=KV3,
290 .add families={fam3,fam4},
291 .max attempts=4, .goal=2,
292 .kv list={keyc=.expand once{\cvalue}},
293 },
294 .append values={
295 keya=\def\y##1{#1+##1},
296 keyb=\def\w##1{#1+##1},
297 },
298 .prepend code={
299 keyb=\def\pre##1{#1+##1},
300 },
301 .slots{
302 key1/keya=value1,
303 key2/keyb=value2
304 },
305 .inherit code={
306 key1/keyb, key2/keyd
307 },
308 .preset keys={
309 key1,key2
310 },
311 }
312
313 ** Handlers and letting handlers
314
315 The skeyval has many handlers and many tools for creating handlers.
316 A full listing of handlers and their meaning will be provided in
317 the user manual.
318
319 .define handlers, .define handler
320 .new handlers, .new handler
321 .new reserved handlers, .new reserved handler,
322 .define reserved handlers, .define reserved handler
323 .define narg handler,.define narg handlers
324 .new narg handler,.new narg handlers
325 .new reserved narg handler,.new reserved narg handlers,
326 .define reserved narg handler,.define reserved narg handlers
327 .handlers let, .handler let
328 .handlers let*, .handler let*, .force handler let
329 .handlers let reserved, .handler let reserved
330 .reserve handlers
331
332
333 ** Prepending and appending to key names and callbacks at
334 definition time:
335
336 \directkeys*{
337 .path=claudio/color,
338 .hp=claudio@col@,
339 .define keys={
340 .prepend to every key name=X@,
341 .append to every key name=@Y,
342 .prepend to every callback=\def\X##1{#1*##1},
343 .append to every callback=\def\Y##1{##1**#1},
344 .ord/{1,2,3,4,5,6}/red,
345 }
346 }
347 \skvusekeys[.path=claudio/color]{X@1@Y,X@2@Y}
348
349
350 ** Several new features are introduced by the skeyval package. For
351 example, we now have 'slot' and 'link' keys. For example, to link
352 keys via .link or .slot handler, we can do:
353
354 \directkeys{%
355 .link={key1, key2}/keya,
356 .link={key3, key4}/{keya, keyb},
357 .append slot expand twice={key3, key4}/keyf=\valuea,
358 .prepend slot expanded={key5, key6}/{keyc=#1, keyd=#1},
359 .prepend slot={key7, key8}/{keyd=#1, keye=#1},
360 .allowed values expanded=keye/{
361 center.do=\def\curralign##1{\hfil##1\hfil},
362 right.do=\def\curralign##1{\hfill##1},
363 left.do=\def\curralign##1{##1\hfill},
364 justified.do=\let\curralign\@iden
365 },
366 }
367
368 ** Bipolar boolean keys
369
370 \skvbiboolkeys[KV]{fam}[mp@]{.forbid value{keya},keyb}[true]{%
371 \ifmp@keya\def\xa##1{##1}\fi
372 }{%
373 \ifmp@keyb\def\xb##1{##1}\fi
374 }%
375 \skvsetkeys[KV]{fam}{keya}
376
377 The value of keya is frozen as 'true'. Hence whenever keya is called,
378 the value 'true' will be used for it. Since keya and keyb are bipolar,
379 the value of keyb will be 'false' whenever keya is called.
380
381 \skvbiboolkeys+[KV]{fam}[mp@]{keya,keyb}[true]{%
382 \ifmp@keya\def\xa##1{##1}\fi
383 }{%
384 \ifmp@keyb\def\xb##1{##1}\fi
385 }{%
386 \skv@warn{Value '#1' is invalid}%
387 }
388 \skvsetkeys[KV]{fam}{keya=xtrue}
389
390
391 ** The concepts of 'trying' to set a key with 'goals' is introduced.
392 The handler '.goal' can be interpreted in the sense of \pagegoal,
393 but applied to setting a key. See an example above. Then there
394 is 'search also' set keys.
395
396 ** 'Quick keys' are a new concept. They're quite fast to define and set,
397 but they can't carry pointers.
398
399 \skvquickkeys.define{<family>}[<holder.prefix>]{<list>}
400 \skvquickkeys.set{<family>}[<na>]{<kvlist>}
401
402 When defining keys, the syntax of <list> is:
403
404 {<keya-1,...,keya-n>}/{<default>}/{<callback>}/{<nominations>}/{<arg>}
405 ;...;
406 {<keyx-1,...,keyx-n>}/{<default>}/{<callback>}/{<nominations>}/{<arg>}
407
408 Example:
409
410 \skvquickkeys.define{fam}[mp@]{%
411 keya/true/\def\x##1{#1*##1}/true,false;
412 keyb;
413 keyc,keyd/aaa+bbb/\def\y##1{#1*##1*#2}/.na/#1+#2;
414 }
415
416 '.na' means a missing entry that isn't empty but should be ignored.
417
418 <nominations> can be used to restrict the user-values of the key
419 or keys.
420
421 <arg> means the argument pattern for the key or keys.
422
423
424 ** Keys can be 'made', as in
425
426 \skvmakekeys[
427 .prefix=KVA,
428 .families={fam1,fam2},
429 .holder prefix=mp@,
430 .all are new,
431 .define in all families,
432 .initialize after define
433 ]{%
434 .ord/{keya,keyb}/{default-a},
435 .arg/keyb/{#1+#2},
436 .cmd/{keyc,keyd}/,
437 .zcmd/key e/\def\cmde##1{##1}/
438 \edef\y{\detokenize\expandafter{\thp@keye}}\def\x##1{#1*key e*##1},
439 .choice/keyf/center/{center.do=\def\x##1{#1*##1},left,right},
440 .zbool/show center/true/\edef\cmd{\ifthp@showcenter Yes\else No\fi}
441 }
442
443 'z-keys' are keys whose names are zapped (ie, spaces are removed)
444 internally. This is to allow holder/store macros to be used
445 without spaces in their names, while maintaining key names with
446 spaces.
447
448 ** Keys can be set using \skvsetkeys, \directkeys (with the handlers
449 .set keys, .try, etc.), or \skvusekeys:
450
451 \krdusekeys[
452 .prefix=KVA,
453 .families={fam1,fam2},
454 .set in all families,
455 .save unknown keys
456 ]{%
457 keya,keyb
458 }
459
460 \directkeys*{
461 .path=user/color,
462 .hp=user-col-,
463 .define keys={
464 .cmd/{1,2,3,4,5,6}/red
465 }
466 }
467 \newcommand*\setcolorlist[1]{\skvusekeys[.path=user/color]{#1}}
468 \setcolorlist{1=red,2=blue,3=cyan,4=green,5=magenta,6=purple}
469 \newcommand*\usecolor[1]{%
470 \skvifcsname user-col-#1\then
471 \csname user-col-#1\endcsname
472 \else
473 black%
474 \fi
475 }
476 \newcommand*\drawcoloredarrows[1]{%
477 \foreachfox {#1}{%
478 \draw[\usecolor{##1},-stealth] (0,-##1)--(2,-##1);
479 }
480 }
481 \begin{document}
482 \begin{tikzpicture}
483 \drawcoloredarrows{1,...,4}
484 \end{tikzpicture}
485 \end{document}
486
487 ** Arguments of keys:
488
489 Argument of keys can be prescribed
490
491 1. Within the key's callback by using the pointers
492
493 .arg, .arg unexpanded, .arg expand once, .arg expand twice,
494 .arg expanded.
495
496 Example:
497
498 \def\somemethod#1#2{%
499 \begingroup
500 \color{#1}%
501 Using \ifskvnovalue default\else user \fi value of `\skvcurrentkey'.
502 \endgraf
503 Argument-2 of key: #2%
504 \endgroup
505 }
506 % Test arguments given inside the callback:
507 \skvcmdkeys[KV]{fam}{keya}[red/default]{%
508 .arg expanded{#1/#2}%
509 \somemethod{#1}{#2}%
510 }
511 \begin{document}
512 \def\aval{blue/Some stuff}
513 \skvsetkeys[KV]{fam}{keya=\aval}
514 \end{document}
515
516 2. By calling the command \skvassignargs.
517
518 3. By using the following handlers within \directkeys or within
519 \skvdefinekeys
520
521 .arg, .arg unexpanded, .arg expand once, .arg expand twice,
522 .arg expanded
523
524
525 ** Listkeys
526
527 List processor keys. The key's value is considered a csv list
528 and each of its element is used as the argument of the key's callback.
529 The user of a listkey doesn't have to define his own list processor,
530 or define one key for each list item. The list separator can be
531 arbitrary; it can be specified in the key's callback as the
532 argument of the dummy commands \listsep and \listparser. The default
533 list separator is comma (,).
534
535 \makeatletter
536 \def\somemethod#1#2{%
537 \begingroup
538 \color{#1}%
539 \ifskvnovalue
540 \ifnum\skvlistcount=\@ne
541 \endgraf
542 Using default value of `\skvcurrentkey':
543 \fi
544 \else
545 \ifnum\skvlistcount=\@ne
546 \endgraf
547 Using user value of `\skvcurrentkey':
548 \fi
549 \fi
550 \endgroup
551 \endgraf
552 Processing item no. \skvlistcount: #2%
553 }
554
555 % Use comma (,), the default list separator, as the list
556 % separator for keya and keyb:
557 \skvlistkeys[KV]{fam}{keya,keyb}[default1,default2]{%
558 \somemethod{blue}{#1}%
559 % Process only four (4) items of the list/value for keya and keyb:
560 \ifnum\skvlistcount=4\relax
561 \skvstopprocessinglistkey
562 \fi
563 }
564 %\skvshowcs{KV/fam/keya.@cbk}
565
566 % Use semicolon (;) as the list separator for keyc and keyd:
567 \skvlistkeys[KV]{fam}{keyc,keyd}[default1;default2]{%
568 % The next line gives error, as expected, since a list key
569 % can't have an assigned argument that isn't simple.
570 % .arg{#1,#2}%
571 \listsep{;}\somemethod{red}{#1}%
572 }
573 \makeatother
574
575 \begin{document}
576 \parindent0pt
577 % No values for keya and keyb; use their default values:
578 \skvsetkeys[KV]{fam}{keya,keyb}
579 \par\bigskip
580 \skvsetkeys[KV]{fam}{%
581 keya={item1A,item1B,item1C,item1D,item1E,item1F},
582 keyb={item2A,item2B,item2C,item2D,item2E,item2F}
583 }
584 \par\bigskip
585 % Set keyc and keyd with their default values:
586 \skvsetkeys[KV]{fam}{keyc,keyd}
587 \par\bigskip
588 \skvsetkeys[KV]{fam}{%
589 keyc={item1A;item1B;item1C;item1D},
590 keyd={item2A;item2B;item2C;item2D}
591 }
592 \end{document}
593
594 ** Make any key a listkeys at key-setting time
595
596 You can use the pointers '.process list' on any key's value at
597 key-setting time to temporarily turn that key into a listkey.
598 Its current value will be processed as a list, ie, the key's
599 callback will be applied to every element of the current value.
600 This scheme is costlier than defining the key as a listkey,
601 using \skvlistkey, but it is more versatile. This allows any
602 key to accept and process a value that is a list, irrespective
603 of its argument pattern.
604
605 Example 1:
606
607 \skvordkeys[KV]{fam}{key1,key2}[default]{\def\xx##1{##1*#1}}
608 \skvsetkeys[KV]{fam}{%
609 key1=val1,key2=.process list{val2a,val2b}
610 }
611
612 Example 2:
613
614 \skvordkeys[KV]{fam}{key1,key2}[default]{%
615 .arg expanded{#1/#2}%
616 \def\x##1{##1*#1*#2}%
617 }
618 \def\aval{val1a/val1b}
619 \def\bval{val2a/val2b,val2c/val2d}
620 \skvsetkeys[KV]{fam}{%
621 % Because of '.arg expanded' in the key's callback, \aval
622 % will be expanded at setting keys:
623 key1=\aval,
624 % \bval will be expanded before its content is processed
625 % as a list. Because of '.arg expanded' in the key's callback,
626 % each element in \bval will be expanded at setting keys:
627 key2=.expand once process list{\bval}
628 }
629
630 Example 3:
631
632 \skvordkeys[KV]{fam}{key1}[default]{\def\x##1{##1*#1}}
633 \def\aval{val1a,val1b,val1c,val1d}
634 \def\bval{\aval}
635 \def\cval{\bval}
636 \skvsetkeys[KV]{fam}{%
637 key1=.expand once process list{\aval},
638 key1=.expand twice process list{\bval},
639 key1=.expand process list{\cval}
640 }
641
642
643 ** Disabling keys:
644
645 Message type to be issued when a disabled key is called:
646
647 \skvmessagetypefordisabledkey{<message type>}
648
649 <message type> can be 'warning', 'error', or 'nothing'. The default is
650 'warning'.
651
652 The key(s) may be disabled long before \skvmessagetypefordisabledkey
653 is called.
654
655 Disabling keys locally:
656
657 \skvdisablekeys[<pref>]{<fam>}{<key list>}
658
659 Disabling keys globally:
660
661 \skvgdisablekeys[<pref>]{<fam>}{<key list>}
662
663
664 ** Keys defined in families can be 'viewed' in files using the package
665 'skeyval-view'. The functionality of 'skeyval-view' is greater than
666 that of xkeyval-view package.
667
668 ** Files skeyval-pstkey.sty and skeyval-pstkey.tex are provided for
669 PSTricks developers and users, as did xkeyval package.
670
671 ** Some new and versatile looping macros are introduced in the
672 skeyval package. In fact, the powerful \newforeach list
673 processor of the 'loops' package has its roots in the 'skeyval-for'
674 module. It is a generalization of PGF's \foreach macro for
675 arbitrary parsers and list separators, including active parsers.
676
677 ** For a package 'foobar', you can access its options by
678
679 \csname [email protected]\endcsname
680
681 To get the options that were actually found/defined and instantiated
682 during the processing of options, the skeyval package offers
683 \skvpackagelist and '.poxkeys' (processed options).
684
685 If 'option1' and 'option2' (but not 'option3') are recognized
686 options of foobar.sty, then after
687
688 \usepackage[option1,option2,option3]{foobar}
689
690 you can issue
691
692 \show\skvpackagelist -> foobar.sty{option1,option2}
693
694 \expandafter\show\csname foobar.sty.poxkeys\endcsname
695 -> option1, option2
696
697 ** Key filtering
698
699 The handlers for key filtering are
700
701 .prefix, .change prefix, .family, .change family, .families,
702 .change families, .add family, .add families, .ignore family,
703 .ignore families, .restore family, .restore families, .paths,
704 .change path, .change paths, .add paths, .ignore paths, .restore paths,
705 .ignore keys, .restore keys
706
707 \newcommand{\storecontent}{}
708 \newcommand{\usecontent}{%
709 \ifx\storecontent\@empty
710 \@@warning{\noexpand\storecontent is empty}%
711 \else
712 \storecontent
713 \fi
714 }
715 \directkeys{%
716 % Define keys in two families:
717 .families={family1,family2},
718 .define ordinary keys={
719 store//\skvappendtomacro\storecontent{#1},
720 remove//\skvpatchcmd\storecontent{#1}{}{}{
721 \@@warning{No token '\detokenize{#1}' in command \string\storecontent}
722 }
723 }
724 }
725 \def\savpar{\par}
726 \def\bigvskip{\par\bigskip}
727 \def\showfam{Family: \skvcurrentfamily\savpar}
728
729 \begin{document}
730 \directkeys{%
731 % Set keys in only family1:
732 .family=family1,
733 .set keys={
734 store={\showfam first test\bigvskip},
735 store={\showfam second test\bigvskip}
736 },
737 .exec code=\usecontent{\color{red}\savpar\hrule\bigvskip},
738 % Set keys in only family2:
739 .family=family2,
740 .set keys={
741 remove={\showfam first test\bigvskip},
742 remove={\showfam second test\bigvskip},
743 store={\showfam third test\bigvskip},
744 store={\showfam fourth test\bigvskip}
745 },
746 .exec code=\usecontent
747 }
748 \end{document}
749
750 ** Inheritance of keys
751
752 There are \skvkeyslet with the syntax
753
754 \skvkeyslet[<pref>]{<family>}{<list>}
755 <list> -> {<newkey1>,<newkey2>,...,<newkey-n>}={<oldkey>}
756
757 and the handler .inherit.
758
759 \directkeys{
760 .prefix=KV,
761 .family=fam,
762 .define ordinary keys={
763 key1/def1/\def\cmd##1{#1*##1},
764 key2/def2
765 },
766 .inherit={
767 {key3,key4}={key1},
768 }
769 }
770 \skvshowcs{KV/fam/key3.@cbk}
771
772 ** Defining and setting keys on fixed prefix and family
773
774 \skvsetprefix{KV}
775 \skvsetfamily{fam}
776 \skvdefineordkey{key1}[def1]{\def\cmd##1{#1*##1}}
777 \skvprocesskeys{key1=value1}
778
779 % End of readme file