summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/expkv-bundle/pkg-def.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/expkv-bundle/pkg-def.tex')
-rw-r--r--Master/texmf-dist/doc/latex/expkv-bundle/pkg-def.tex76
1 files changed, 61 insertions, 15 deletions
diff --git a/Master/texmf-dist/doc/latex/expkv-bundle/pkg-def.tex b/Master/texmf-dist/doc/latex/expkv-bundle/pkg-def.tex
index fade98e8b8f..5a682b73bc4 100644
--- a/Master/texmf-dist/doc/latex/expkv-bundle/pkg-def.tex
+++ b/Master/texmf-dist/doc/latex/expkv-bundle/pkg-def.tex
@@ -320,7 +320,7 @@ showing line.
expand to the second argument (so behave like |\@secondoftwo|). The idea is
that with this type you can define a key which should be typeset formatted.
The |edata| and |xdata| variants will fully expand \val, the |gdata| and
- |xdata| variants will store \val\ inside \meta{cs} globally. Juts like with
+ |xdata| variants will store \val\ inside \meta{cs} globally. Just like with
|store| you can use macro parameters without having to double them. The
\prefixes\ only affect the key-macro, \meta{cs} will always be expandable and
|\long|.
@@ -462,6 +462,18 @@ showing line.
the \kv\ list inside of \meta{set} and defines a \Nkey\ with a static list.
\end{function}
+\begin{function}[module=expkv-def type]{alias}
+ \begin{syntax}
+ alias \key\ = \meta{key_2} \prefixes2333
+ \end{syntax}
+ Copy the definition of \meta{key_2} to \key. \key\ will inherit being |long|
+ or |protected| from \meta{key_2} as well. If a \Vkey\ named \meta{key_2}
+ exists its definition is copied, and if an accordingly named \Nkey\ exists its
+ definition is copied to the new name as well. At least one of the two keys
+ must exist or else this throws an error. If \meta{key_2} is later redefined
+ the definition of \key\ will stay the same.
+\end{function}
+
\begin{function}[module=expkv-def type]{set}
\begin{syntax}
set \key\ = \marg{set} \prefixes2233
@@ -608,6 +620,37 @@ showing line.
\end{enverb}
\end{example}
+\begin{function}[module=expkv-def type]{choice-aliases}
+ \begin{syntax}
+ choice-aliases \key\ = \{\meta{new}=\meta{old}, \ldots\} \prefixes2333
+ \end{syntax}
+ Copy the definition of the choice \meta{old} of \key\ to a \meta{new} choice
+ for the same \key. The \key\ must be an existing |choice| key. Inside the
+ \meta{new}=\meta{old} list all elements must get a value. If used the
+ |new|-prefix will apply to each individual \meta{new} choice name (so if any
+ already exists it'll throw an error, and the current element will be ignored).
+ The \meta{new} choice will inherit being |protected| from the \meta{old} one.
+ The \meta{old} choice must be defined obviously.
+
+ This works for a |choice| or |bool| \type\ as well as all their variants. If
+ something redefines some of the choices later on the aliases will keep the
+ original definition.
+\end{function}
+\begin{example}
+ {Create shortcuts for choices using the \texttt{choice-aliases} \type}
+ With the following we create a key that accepts some choices, and since our
+ keyboard is only designed to handle a finite number of keystrokes we also
+ allow for shorter names of those choices. (This is not part of the ongoing
+ example using the |example| set above.)
+ \begin{enverb}[no-store,no-tcb]
+ \ekvdefinekeys{choice-alias-example}
+ {
+ choice-store key = { long-name, short-name }
+ ,choice-aliases key = { ln = long-name, sn = short-name }
+ }
+ \end{enverb}
+\end{example}
+
\begin{function}[module=expkv-def type]{unknown code}
\begin{syntax}
unknown code = \marg{definition} \prefixes2322
@@ -668,25 +711,28 @@ argument order without any performance hit if you compare this to
\end{function}
\bigskip
-Time to use all those keys defined in the different examples!
+Time to use all those keys defined in the different examples as part of the
+|example| set!
% undo the global no-tcb setting
\ekvset{enverb}{no-store,undo-no-tcb}%
\begin{enverb}[restore,below,inter=Which results in three paragraphs of text:]
\newcommand\defexample[1][]
{%
- \ekvset{example}{#1}%
- After walking \the\exampledistance\space we finally reached
- \examplebar{\emph}{no particular place}.
- There I ordered
- \iffoo
- a drink called \examplefoostore\space (that has
- \the\examplefoocount\space tokens in it)%
- \else
- nothing of particular interest%
- \fi
- \examplebaz{ and ate \emph}.
- Then a friend of mine also chose \exampledrink.
- \par
+ \begingroup % keep the values set local to this call
+ \ekvset{example}{#1}%
+ After walking \the\exampledistance\space we finally reached
+ \examplebar{\emph}{no particular place}.
+ There I ordered
+ \iffoo
+ a drink called \examplefoostore\space (that has
+ \the\examplefoocount\space tokens in it)%
+ \else
+ nothing of particular interest%
+ \fi
+ \examplebaz{ and ate \emph}.
+ Then a friend of mine also chose \exampledrink.
+ \par
+ \endgroup
}
\defexample[nofoo]
\defexample[all,choose=lemonade]