summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-08-26 23:58:20 +0000
committerKarl Berry <karl@freefriends.org>2009-08-26 23:58:20 +0000
commitccb587e18c23dd8a68d9deaab22ec4e090142e23 (patch)
tree8a219b6d853fcb87a9d26c4ff5f4d49a081d6068 /Master
parent7f22b556e93ffe99258d3be57223233879bd5e7b (diff)
keycommand 2.z (26aug09)
git-svn-id: svn://tug.org/texlive/trunk@14875 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/keycommand/keycommand-example.pdfbin135984 -> 135984 bytes
-rw-r--r--Master/texmf-dist/doc/latex/keycommand/keycommand-example.tex4
-rw-r--r--Master/texmf-dist/doc/latex/keycommand/keycommand.pdfbin246472 -> 220135 bytes
-rw-r--r--Master/texmf-dist/source/latex/keycommand/keycommand.dtx301
-rw-r--r--Master/texmf-dist/source/latex/keycommand/keycommand.ins10
-rw-r--r--Master/texmf-dist/tex/latex/keycommand/keycommand.sty99
6 files changed, 282 insertions, 132 deletions
diff --git a/Master/texmf-dist/doc/latex/keycommand/keycommand-example.pdf b/Master/texmf-dist/doc/latex/keycommand/keycommand-example.pdf
index f9e9eec228b..61fc8d38dcb 100644
--- a/Master/texmf-dist/doc/latex/keycommand/keycommand-example.pdf
+++ b/Master/texmf-dist/doc/latex/keycommand/keycommand-example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/keycommand/keycommand-example.tex b/Master/texmf-dist/doc/latex/keycommand/keycommand-example.tex
index 78aa8223214..c075f4a039d 100644
--- a/Master/texmf-dist/doc/latex/keycommand/keycommand-example.tex
+++ b/Master/texmf-dist/doc/latex/keycommand/keycommand-example.tex
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% keycommand : an easy way to define commands with keys
+%% keycommand : an easy way to define commands with optional keys
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -21,7 +21,7 @@
%% keycommand.sty, keycommand.pdf, keycommand.ins,
%% keycommand-example.tex
%%
-%% keycommand : an easy way to define commands with keys
+%% keycommand : an easy way to define commands with optional keys
%% Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
%%
diff --git a/Master/texmf-dist/doc/latex/keycommand/keycommand.pdf b/Master/texmf-dist/doc/latex/keycommand/keycommand.pdf
index 60144c6fb3e..83be1a41c1d 100644
--- a/Master/texmf-dist/doc/latex/keycommand/keycommand.pdf
+++ b/Master/texmf-dist/doc/latex/keycommand/keycommand.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/keycommand/keycommand.dtx b/Master/texmf-dist/source/latex/keycommand/keycommand.dtx
index 1a5c641058a..05585675a2e 100644
--- a/Master/texmf-dist/source/latex/keycommand/keycommand.dtx
+++ b/Master/texmf-dist/source/latex/keycommand/keycommand.dtx
@@ -1,5 +1,5 @@
% \iffalse meta-comment
-% keycommand : an easy way to define commands with keys
+% keycommand : an easy way to define commands with optional keys |v2.z 2009/08/26]
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
@@ -37,7 +37,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: keycommand 2009/07/22 v1.0 an easy way to define commands with keys}
+\Msg{* Package: keycommand 2009/07/22 v1.0 an easy way to define commands with optional keys}
\Msg{************************************************************************}
\keepsilent
@@ -48,7 +48,7 @@
This is a generated file.
-keycommand : an easy way to define commands with keys
+keycommand : an easy way to define commands with optional keys [v2.z 2009/08/26]
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
@@ -61,7 +61,7 @@ and the derived files
keycommand.sty, keycommand.pdf, keycommand.ins,
keycommand-example.tex
-keycommand : an easy way to define commands with keys
+keycommand : an easy way to define commands with optional keys
Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
\endpreamble
@@ -94,19 +94,18 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
\fi
%</ignore>
%<*driver>
+\edef\thisfile{\jobname}
+\def\thisinfo{an easy way to define commands with optional keys.}
+\def\thisdate{2009/08/26}
+\def\thisversion{2.$\zeta$}
+\let\loadclass\LoadClass
+\def\LoadClass#1{\loadclass[abstracton]{scrartcl}\let\scrmaketitle\maketitle\AtEndOfClass{\let\maketitle\scrmaketitle}}
\documentclass[a4paper,oneside]{ltxdoc}
\usepackage[latin9]{inputenc}
\usepackage[american]{babel}
-\usepackage{etex,holtxdoc,geometry,tocloft,fancyhdr,color,bbding}\CodelineNumbered
+\usepackage{etex,holtxdoc,geometry,tocloft,fancyhdr,color,bbding,embedfile,framed,multirow,txfonts}\CodelineNumbered
\lastlinefit999
-\font\ding=dingbat scaled 800
-\geometry{top=2cm,headheight=1cm,headsep=.3cm,bottom=2cm,left=5cm,right=3cm}
-\fancyhf{}\fancyhead[L]{The \xpackage{keycommand} package -- easy way to define commands with keys}
-\fancyfoot[L]{\color[gray]{.35}\scriptsize\xpackage{keycommand}\quad\copyright\oldstylenums{2009}\,\lower.3ex\hbox{\NibRight}\,Florent Chervet}
-\fancyfoot[R]{\oldstylenums{\thepage} / \oldstylenums{\pageref{LastPage}}}
-\pagestyle{fancy}
-\newcommand\macrocodecolor{\color{macrocode}}\definecolor{macrocode}{rgb}{0.18,0.00,0.45}
-\newcommand\reflinkcolor{\color{reflink}}\definecolor{reflink}{rgb}{0.49,0.00,0.00}
+\geometry{top=2cm,headheight=1cm,headsep=.3cm,bottom=1.4cm,footskip=.5cm,left=4cm,right=2cm}
\hypersetup{%
pdftitle={The keycommand package},
pdfsubject={An e-TeX package for more useful tools for LaTeX package writers},
@@ -115,13 +114,14 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
pdfstartview={FitH},
pdfkeywords={tex, e-tex, latex, package, keys, keycommand, newcommand, keyval, kvsetkeys, programming},
bookmarksopen=true,bookmarksopenlevel=2}
+\embedfile{\thisfile.dtx}
\begin{document}
- \DocInput{keycommand.dtx}
+ \DocInput{\thisfile.dtx}
\end{document}
%</driver>
% \fi
%
-% \CheckSum{673}
+% \CheckSum{770}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -161,21 +161,58 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% \DoNotIndex{\maketitle,\parindent,\setbox,\x,\kernel@ifnextchar}
% \DoNotIndex{\KVS@CommaComma,\KVS@CommaSpace,\KVS@EqualsSpace,\KVS@Equals,\KVS@Global,\KVS@SpaceEquals,\KVS@SpaceComma,\KVS@Comma}
%
-% \title{The \xpackage{keycommand}\kern6pt package}
-% \author{Florent Chervet \xemail{florent.chervet@free.fr}}
-% \date{July 22, 2009}
-%
+% \makeatletter
% \MakeShortVerb{\+}
-%
% \catcode`\§\active\def§{\par\nobreak\vskip-\parskip}
-% \makeatletter
+% \def\thispackage{\xpackage{\thisfile}}
+% \def\ThisPackage{\Xpackage{\thisfile}}
+% \def\Xpackage{\@dblarg\X@package}
+% \def\X@package[#1]#2{%
+% \xpackage{#2\footnote{\noindent\xpackage{#2}: \href{http://www.ctan.org/tex-archive/macros/latex/contrib/#1}{\nolinkurl{CTAN:macros/latex/contrib/#1}}}}}
+
+%
% \parindent\z@\parskip.4\baselineskip\topsep\parskip\partopsep\z@
% \g@addto@macro\macro@font{\macrocodecolor\let\AltMacroFont\macro@font}
% \def\smex{\leavevmode\hb@xt@2em{\hfil$\longrightarrow$\hfil}}
+% \def\csred#1{\textcolor{red}{\cs{#1}}}
+% \def\CSbf#1{\textbf{\CS{#1}}}
+% \def\csbf#1{\textbf{\cs{#1}}}
+%
+% \fancyhf{}\fancyhead[L]{The \thispackage\ package -- \thisinfo}
+% \fancyfoot[L]{\color[gray]{.35}\scriptsize\thispackage\quad[rev.\thisversion]\quad\copyright\oldstylenums{2009}\,\lower.3ex\hbox{\NibRight}\,Florent Chervet}
+% \fancyfoot[R]{\oldstylenums{\thepage} / \oldstylenums{\pageref{LastPage}}}
+% \pagestyle{fancy}
+% \fancypagestyle{plain}{%
+% \let\headrulewidth\z@
+% \fancyhf{}%
+% \fancyfoot[R]{\oldstylenums{\thepage} / \oldstylenums{\pageref{LastPage}}}}
+%
+% \newcommand\macrocodecolor{\color{macrocode}}\definecolor{macrocode}{rgb}{0.18,0.00,0.45}
+% \newcommand\reflinkcolor{\color{reflink}}\definecolor{reflink}{rgb}{0.49,0.00,0.00}
+%
% \makeatother
%
+% \deffootnote{1em}{0pt}{\rlap{\textsuperscript{\thefootnotemark}}\kern1em}
+% \title{\mdseries The{\bfseries\ThisPackage}\kern.6em package}
+% \author{Florent Chervet {\footnotesize\xemail{florent.chervet@free.fr}}}
+% \date{\thisdate~--~version \thisversion}
+% \subtitle{\thisinfo}
+%
% \maketitle
%
+% \makeatletter\begingroup\let\@thefnmark\@empty\let\@makefntext\@firstofone
+% \footnotetext{\noindent
+% This documentation is produced with the +DocStrip+ utility.
+% \begin{tabbing}
+% \qquad\=\smex\=To get the documentation, \= run (thrice):\quad\= \texttt{pdflatex keycommand.dtx} \\
+% \qquad\>\>To get the index, \> run:\>\texttt{makeindex -s gind.ist keycommand.idx} \\
+% \>\smex\>To get the package, \> run:\> \texttt{etex keycommand.dtx}
+% \end{tabbing}§
+% The \xext{dtx} file is embedded into this pdf file thank to \xpackage{embedfile} by H. Oberdiek.}
+% \endgroup\makeatother
+%
+% \deffootnote{1em}{0pt}{\rlap{\thefootnotemark.}\kern1em}
+%
% \begin{abstract}\parindent0pt\noindent
%
% \xpackage{keycommand} provides an easy way to define commands or environments
@@ -187,20 +224,13 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% via the +\keycmd+ prefix.
%
% This package requires and is based on the package \xpackage{kvsetkeys} by Heiko Oberdiek.
-%
% It is designed to work with \eTeX{} for the code uses the primives +\unexpanded+ and +\protected+.
%
-% \end{abstract}\vskip-\baselineskip
-% \makeatletter\let\@thefnmark\@empty
-% \@footnotetext{This documentation is produced with the +DocStrip+ utility.
-% \begin{tabbing}
-% \qquad\=\smex\=To get the documentation, \= run (thrice):\quad\= \texttt{pdflatex keycommand.dtx} \\
-% \>\smex\>To get the package, \> run:\> \texttt{etex keycommand.dtx}
-% \end{tabbing}}\makeatother
+% \end{abstract}
%
+% \bigskip
% \cftbeforesecskip=5pt plus2pt minus4pt
% \tableofcontents
-% \tracingnone
%
% \def\B#1{\texttt{[}\meta{#1}\texttt{]}}
%
@@ -225,16 +255,16 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% &+\newkeyenvironment+ & +\renewkeyenvironment+ \\
% and:&+\providekeycommand+
% \end{tabular}\end{center}
-
+%
% Moreover, if you need (or prefer) the syntax of +\def+ (or |\gdef|, |\edef|, |\xdef|)
% you shall refer to the section \nameref{subsec:keycmd} (in \nameref{Implementation}).
%
% \begin{declcs}{newkeycommand}\,\M{control sequence}\,\B{key-value list}\,\B{number of args}\,\M{definition}
% \end{declcs}
%
-% \xpackage{keycommand} allow \LaTeX{} users to define commands with key in a easy way.
+% \xpackage{keycommand} allow \LaTeX{} users to define commands with optional keys in a easy way.
% Better is a small example than a long talking: let's define a command \cs{Rule} whose
-% +width+, +thickness+ and +raise+ can be specified as keys.
+% +width+, +thickness+ and +raise+ can be specified as keys.
%
% With \xpackage{keycommand} we just have to say:§
% \begin{tabbing}\label{Rule}
@@ -262,6 +292,12 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% \>4:\> \rule[1ex]{1em}{2pt}hello\rule[1ex]{1em}{2pt}
% \end{tabbing}
%
+% \textsc{Nota bene:} it is also possible to give a key a default value which is the value of another key.
+% For example:§
+% \quad |\newkeycommand\CmdKey[alpha=hello, beta=\commandkey{alpha}]{|...|}|
+%
+% When called as: |\CmdKey[alpha=world]|, the key |beta| will then have the same value: |world|.
+%
% \begin{declcs}{newkeyenvironment}\,\M{envir name}\,\B{key-values pairs}\,\B{number of args}\,\M{begin}\,\M{end}
% \end{declcs}
%
@@ -276,7 +312,6 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
%
% A example of a key-environment is left in the file: +keycommand-example.tex+.
%
-% \enlargethispage{\baselineskip}
% \subsection{Error messages}
%
% If you use the command +\Rule+ (defined in \ref{Rule}) with a key say: +height+
@@ -292,9 +327,23 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% will not have any error message: +\commandkey{height}+ will just be expanded into +\relax+
% at +\Rule+ expansion time.
%
+% \edef\restorespaceskip{\spaceskip\the\spaceskip \xspaceskip\the\xspaceskip}
+% \spaceskip=.1em plus.1fil \xspaceskip\spaceskip
% To be honest, when you redefine a key-command using |\renewkeycommand| or
% |\renewkeyenvironment| or |\keycmd\def| the keys defined before for the old command are undefined.
% This way you have the expected error message in all cases.
+% \restorespaceskip
+%
+% \subsection{Test if a key is defined}
+%
+% When you define a key command you may let the default value of a key empty. Then, you may wish to
+% expand some commands only if the key has been given by the user (with a non empty value). This can
+% be achieved using the macro |\ifcommandkey|:
+%
+% \begin{declcs}{ifcommandkey}\,\M{key name}\,\M{commands if key is blank}\,\M{commands if key is NOT blank}
+% \end{declcs}
+%
+%
%
% \StopEventually{
% }
@@ -312,7 +361,7 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
[2005/12/01]% LaTeX must be 2005/12/01 or younger (see kvsetkeys.dtx).
\ProvidesPackage{keycommand}
- [2009/07/22 an easy way to define commands with keys]
+ [2009/07/22 v2.e- an easy way to define commands with optional keys]
% \end{macrocode}
%
% \subsection{Requirements}
@@ -328,17 +377,15 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
\RequirePackage{etex,kvsetkeys}
% \end{macrocode}
%
-% \iffalse
+%
% \subsection{Syntactical enhancement}
%
-% \begin{macro}{\`name`}
-% We define a shortcut for +\csname+...+\endcsname+ all along this package.
+% We will define a shortcut for +\expandafter\noexpand\csname+...+\endcsname+ all along this package.
% \begin{macrocode}
-\let\kcmd@AtEnd=\`
-\def\`#1`{\csname #1\endcsname}
+\edef\kcmd@AtEnd{\catcode34 \the\catcode34}% "
+\catcode34 4
% \end{macrocode}
-% \end{macro}
-% \fi
+%
%
% \subsection{Defining keys}
%
@@ -348,7 +395,7 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% the \xpackage{keyval} package.
%
% \begin{macrocode}
-\def\kcmd@keydef#1#2#3#4#5{% #1=\global(eventually), #2=command, #3=family, #4=key, #5=def
+\def\kcmd@keydef#1#2#3#4#5{% #1=\global, #2=command, #3=family, #4=key, #5=def
#1\expandafter\edef\csname kcmd@keys\string#2\endcsname{%
\csname kcmd@keys\string#2\endcsname,#4}%
#1\@namedef{KV@#3@#4@default\expandafter}\expandafter{%
@@ -391,20 +438,26 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% \end{macrocode}
% \end{macro}
%
-% \subsection{The \cs{keycmd} prefix} \label{subsec:keycmd}
+% \clearpage
+% \subsection{The \csbf{keycmd} prefix} \label{subsec:keycmd}
%
% |\keycmd| acts just like a (expandable) prefix for |\def| or |\edef|:
%
% The syntax is:§
-% \begin{tabbing}
-% %\qquad\= +\keycmd+\=\textcolor{red}{\textasteriskcentered} \hskip6cm \textcolor{red}{\textasteriskcentered}\,\= optional\\
-% \>\> {(\color{red}+\protected|\long|\outer|\global+})\> optional \\
-% \>\> (+\def|\gdef|\edef|\xdef+)\> required \\
-% \>\> +\CommandWithKeys+ \> Name of the command to define \\
-% \>\> +[key=value pairs]+ \> keys and default values \\
-% \>\> \textcolor{red}{\emph{parameter string}} \> optional (same syntax as |\def|) \\
-% \>\> +{+ \emph{replacement text} +}+ \> required
-% \end{tabbing}
+% \DeleteShortVerb{\|}\catcode`\|\active\let|\textbar
+% \def\tvs{\textcolor{green}{\textvisiblespace}}
+% \def\cblue{\color{blue}}\def\cred{\color{red}}% \begin{framed}\begin{centering}\begin{tabular}{clll}
+% & \multicolumn{2}{l}{\cs{keycmd}\textcolor{red}{\textasteriskcentered}\tvs} & \textcolor{red}{\textasteriskcentered} optional \\
+% \cblue possibly & & (\csred{long}\tvs|\csred{global}\tvs|\csred{protected}\tvs|\csred{outer}\tvs) & optional (zero or more) \\
+% \cblue in a macro & \multirow{-2}*{\cblue $\Biggl\lbrace$\qquad} & (\cs{def}|\cs{edef}|\cs{gdef}|\cs{xdef}) & required: see below \\
+% & & \textit{control sequence} & required \\
+% & & +[key=value pairs]+ & keys and default values \\
+% & & \textcolor{red}{Parameter string} & optional \\
+% & & \meta{Replacement text} & required
+% \end{tabular}\end{centering}\end{framed}
+
+
+
%
% Without the star form, +\long+ is assumed; but it can always be specified as +\long+ \textbf{after}
% +\keycmd+. Example:§
@@ -418,7 +471,7 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% \end{macro}
%
% \begin{macro}{\kcmd@prefix}
-% This macro reads the prefixes one after another (including the +\def+ word)
+% This is the prefixes scanner: this macro reads the prefixes one after another (including the +\def+ word)
% and stores them in +\kcmd@prfx+. We open a group for all declarations will
% be local until the final definition of +\CommandWithKeys+.
%
@@ -426,32 +479,40 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
\def\kcmd@prefix{\begingroup
\let\kcmd@gbl\@empty
\def\kcmd@prfx{\l@ngrel@x}%
- \futurelet\x\kcmd@pref@x}
-\def\kcmd@pref@x{%
- \ifx\x\@sptoken \let\next\kcmd@pref@x@space
+ \futurelet\x\kcmd@@prefix}
+\def\kcmd@@prefix{%
+ \let\kcmd@next@addto\kcmd@next@prefix
+ \ifx\x\@sptoken \let\next\kcmd@space@prefix
\else \let\next\kcmd@addto@prfx
\ifx\x\long
\else\ifx\x\outer
\else\ifx\x\protected
\else\ifx\x\global \def\kcmd@gbl{\global}%
\else
- \def\kcmd@pref@x@next{\expandafter\key@cmd\noexpand}%
+ \def\kcmd@next@addto{\expandafter\key@cmd\noexpand}%
\ifx\x\def
\else\ifx\x\edef
\else\ifx\x\gdef \def\kcmd@gbl{\global}%
\else\ifx\x\xdef \def\kcmd@gbl{\global}%
- \else \def\next{\kcmd@error{a \string\def\space
- was expected after \string\keycmd.}}%
+ \else \let\kcmd@next@addto\kcmd@next@prefix
+ \ifx\y\x\kcmd@error@prefix
+ \else\let\y\x
+ \fi
+ \let\next\kcmd@expand@prefix
\fi\fi\fi\fi
\fi\fi\fi\fi
\fi\next}
-\begingroup\def\:{\kcmd@pref@x@space}
-\expandafter\gdef\: {\futurelet\x\kcmd@pref@x}
-\endgroup
-\def\kcmd@addto@prfx#1{\expandafter\def\expandafter
- \kcmd@prfx\expandafter{\kcmd@prfx#1}\kcmd@pref@x@next}
-\def\kcmd@pref@x@next{\futurelet\x\kcmd@pref@x}
-\def\kcmd@error#1{\@latex@error{#1}\@ehd}
+\def\kcmd@next@prefix{\futurelet\x\kcmd@@prefix}
+\def\kcmd@expand@prefix{\expandafter\kcmd@next@prefix}
+\def\kcmd@addto@prfx#1{\let\y\@undefined
+ \expandafter\def\expandafter\kcmd@prfx
+ \expandafter{\kcmd@prfx#1}\kcmd@next@addto}
+\expandafter\def\expandafter\kcmd@space@prefix\space{\kcmd@next@prefix}
+\def\kcmd@error@prefix{\@latex@error{A \string\def\space
+ (or \string\gdef\space or \string\edef\space or \string\xdef)\MessageBreak
+ was expected after \string\keycmd\MessageBreak
+ I found a \meaning\x!\MessageBreak
+ see keycommand documentation for more information}\@ehd}
% \end{macrocode}
% \end{macro}
%
@@ -504,7 +565,7 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
\kcmd@undefinekeys{\kcmd@gbl}{#1}%
\kv@parse{##1}{\kcmd@definekey{\kcmd@gbl}{#1}{\kcmd@fam}}%
\kcmd@gbl\protected\def#1{% entry point
- \protected\def\commandkey########1{\noexpand\csname\kcmd@fam @########1\endcsname}%
+ \def\commandkey########1{\noexpand\csname\kcmd@fam @########1\endcsname}%
\def\"kcmd\string#1"########1[########2]{%
\kvsetkeys{\kcmd@fam}{########1,########2}%
\"\string #1"}%
@@ -538,11 +599,11 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
% had been defined as +\outer+ before...
% \begin{macrocode}
\DeclareRobustCommand\newkeycommand{\@star@or@long
- \expandafter\new@keycommand\noexpand}
+ {\expandafter\new@keycommand\noexpand}}
\DeclareRobustCommand\renewkeycommand{\@star@or@long
- \expandafter\renew@keycommand\noexpand}
+ {\expandafter\renew@keycommand\noexpand}}
\DeclareRobustCommand\providekeycommand{\@star@or@long
- \expandafter\provide@keycommand\noexpand}
+ {\expandafter\provide@keycommand\noexpand}}
% \end{macrocode}
% \end{macro}
%
@@ -612,30 +673,70 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
\expandafter\let\csname end#1\endcsname\relax
\new@keyenvironment{#1}}
% \end{macrocode}
+% \iffalse
+%<package>
+%<package>
+% \fi
%
-% \subsection{\xpackage{kvsetkeys} correction}
+% \subsection{Test if keys are blank}
%
-% |\kv@normalize| inserts an unwilling blank space due to a small error in the code.
-% Mr Oberdiek has been asked for correction...
+% First we need some helper macros:
+% \begin{macrocode}
+\def\kcmd@afterelse#1\else#2\fi{\fi#1}
+\def\kcmd@afterfi#1\fi{\fi#1}
+% \end{macrocode}
%
+%
+% \begin{macro}{\expandnext}
+% The following macros comes from the \Xpackage{etextools} package (by F. Chervet):
% \begin{macrocode}
-\def\kv@normalize#1{%
- \begingroup
- \toks@{,#1,}%
- \KVS@Comma
- \KVS@SpaceComma{ }%
- \KVS@CommaSpace
- \KVS@CommaComma
- \KVS@Equals
- \KVS@SpaceEquals{ }%
- \KVS@EqualsSpace% <original code>\KVS@EqualsSpace{ }</original code>
- \xdef\KVS@Global{\the\toks@}%
- \endgroup
- \let\kv@list\KVS@Global
-}
+\newcommand\kcmd@expandnext[2]{%
+ \ifx#1\kcmd@expandnext
+ \kcmd@afterelse\expandafter\expandafter\expandafter
+ \expandafter\@kcmd@expandnext{#2}{\expandafter\expandafter\expandafter}%
+ \else\kcmd@afterfi\expandafter#1\expandafter{#2}%
+ \fi}
+\long\def\@kcmd@expandnext#1#2#3{%
+ \ifx#1\kcmd@expandnext
+ \expandafter\kcmd@afterelse\expandafter\expandafter\expandafter
+ \expandafter\@kcmd@expandnext{#3}{\expandafter#2#2}%
+ \else
+ \expandafter\kcmd@afterfi#2#1#2{#3}%
+ \fi}
% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\kcmd@expandonce}
+% The following macro comes from the \Xpackage{etoolbox} package (by P. Lehmann):
% \begin{macrocode}
+\def\kcmd@expandonce#1{\unexpanded\expandafter{#1}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\kcmd@ifblank}
+% The following macro comes from the \Xpackage[misc/url.sty]{url} package:
+% \begin{macrocode}
+\begingroup\catcode`\:=4\catcode`\&=4
+\gdef\kcmd@ifblank#1{\kcmd@ifblank@#1&&\@secondoftwo\@firstoftwo:}
+\gdef\kcmd@ifblank@#1#2&#3#4#5:{#4}
+\endgroup
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifcommandkey}
+% \begin{macrocode}
+\newcommand\ifcommandkey[3]{%
+ \kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@expandnext
+ \kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@expandnext
+ \kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@ifblank{%
+ \kcmd@expandnext\kcmd@expandnext\kcmd@expandonce{\commandkey{#1}}}
+ {#3}
+ {#2}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\kcmd@AtEnd
%</package>
% \end{macrocode}
%
@@ -732,6 +833,30 @@ Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
%</example>
% \end{macrocode}
%
+% \begin{History}
+%
+% \begin{Version}{2009/08/26 v2.z}
+% \item
+%
+% \end{Version}
+%
+% \begin{Version}{2009/08/04 v2.e-}
+% \item
+% Fix catcode of double quote (") in case user command had a double quote in its name...
+% \item
+% Add History to the documentation file
+% \item
+% Modify the prefixes scanner (it is now the same as the one of \Xpackage{ltxnew}).
+% Modify the documentation (\KOMAScript\ classe)
+% \end{Version}
+%
+% \begin{Version}{2009/07/22 v1.0}
+% \item
+% First version.
+% \end{Version}
+%
+% \end{History}
+%
% \begin{thebibliography}{9}
%
% \bibitem{kvsetkeys}
diff --git a/Master/texmf-dist/source/latex/keycommand/keycommand.ins b/Master/texmf-dist/source/latex/keycommand/keycommand.ins
index 4b81554e728..b3567da80a4 100644
--- a/Master/texmf-dist/source/latex/keycommand/keycommand.ins
+++ b/Master/texmf-dist/source/latex/keycommand/keycommand.ins
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% keycommand : an easy way to define commands with keys
+%% keycommand : an easy way to define commands with optional keys
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -21,13 +21,13 @@
%% keycommand.sty, keycommand.pdf, keycommand.ins,
%% keycommand-example.tex
%%
-%% keycommand : an easy way to define commands with keys
+%% keycommand : an easy way to define commands with optional keys
%% Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
%%
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: keycommand 2009/07/22 v1.0 an easy way to define commands with keys}
+\Msg{* Package: keycommand 2009/07/22 v1.0 an easy way to define commands with optional keys}
\Msg{************************************************************************}
\keepsilent
@@ -38,7 +38,7 @@
This is a generated file.
-keycommand : an easy way to define commands with keys
+keycommand : an easy way to define commands with optional keys [v2.z 2009/08/26]
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
@@ -51,7 +51,7 @@ and the derived files
keycommand.sty, keycommand.pdf, keycommand.ins,
keycommand-example.tex
-keycommand : an easy way to define commands with keys
+keycommand : an easy way to define commands with optional keys
Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
\endpreamble
diff --git a/Master/texmf-dist/tex/latex/keycommand/keycommand.sty b/Master/texmf-dist/tex/latex/keycommand/keycommand.sty
index 23b30abba2a..e6043d051ed 100644
--- a/Master/texmf-dist/tex/latex/keycommand/keycommand.sty
+++ b/Master/texmf-dist/tex/latex/keycommand/keycommand.sty
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% keycommand : an easy way to define commands with keys
+%% keycommand : an easy way to define commands with optional keys
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -21,18 +21,18 @@
%% keycommand.sty, keycommand.pdf, keycommand.ins,
%% keycommand-example.tex
%%
-%% keycommand : an easy way to define commands with keys
+%% keycommand : an easy way to define commands with optional keys
%% Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
%%
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
[2005/12/01]% LaTeX must be 2005/12/01 or younger (see kvsetkeys.dtx).
\ProvidesPackage{keycommand}
- [2009/07/22 an easy way to define commands with keys]
+ [2009/07/22 v2.e- an easy way to define commands with optional keys]
\RequirePackage{etex,kvsetkeys}
-\let\kcmd@AtEnd=\`
-\def\`#1`{\csname #1\endcsname}
-\def\kcmd@keydef#1#2#3#4#5{% #1=\global(eventually), #2=command, #3=family, #4=key, #5=def
+\edef\kcmd@AtEnd{\catcode34 \the\catcode34}% "
+\catcode34 4
+\def\kcmd@keydef#1#2#3#4#5{% #1=\global, #2=command, #3=family, #4=key, #5=def
#1\expandafter\edef\csname kcmd@keys\string#2\endcsname{%
\csname kcmd@keys\string#2\endcsname,#4}%
#1\@namedef{KV@#3@#4@default\expandafter}\expandafter{%
@@ -55,36 +55,45 @@
\csname KV@kcmd@\expandafter\@gobble\string #2@\kcmp@temp\endcsname
\@undefined}}%
#1\@namedef{kcmd@keys\string#2}{\@gobble}}
+
\DeclareRobustCommand\keycmd{\@star@or@long\kcmd@prefix}
\def\kcmd@prefix{\begingroup
\let\kcmd@gbl\@empty
\def\kcmd@prfx{\l@ngrel@x}%
- \futurelet\x\kcmd@pref@x}
-\def\kcmd@pref@x{%
- \ifx\x\@sptoken \let\next\kcmd@pref@x@space
+ \futurelet\x\kcmd@@prefix}
+\def\kcmd@@prefix{%
+ \let\kcmd@next@addto\kcmd@next@prefix
+ \ifx\x\@sptoken \let\next\kcmd@space@prefix
\else \let\next\kcmd@addto@prfx
\ifx\x\long
\else\ifx\x\outer
\else\ifx\x\protected
\else\ifx\x\global \def\kcmd@gbl{\global}%
\else
- \def\kcmd@pref@x@next{\expandafter\key@cmd\noexpand}%
+ \def\kcmd@next@addto{\expandafter\key@cmd\noexpand}%
\ifx\x\def
\else\ifx\x\edef
\else\ifx\x\gdef \def\kcmd@gbl{\global}%
\else\ifx\x\xdef \def\kcmd@gbl{\global}%
- \else \def\next{\kcmd@error{a \string\def\space
- was expected after \string\keycmd.}}%
+ \else \let\kcmd@next@addto\kcmd@next@prefix
+ \ifx\y\x\kcmd@error@prefix
+ \else\let\y\x
+ \fi
+ \let\next\kcmd@expand@prefix
\fi\fi\fi\fi
\fi\fi\fi\fi
\fi\next}
-\begingroup\def\:{\kcmd@pref@x@space}
-\expandafter\gdef\: {\futurelet\x\kcmd@pref@x}
-\endgroup
-\def\kcmd@addto@prfx#1{\expandafter\def\expandafter
- \kcmd@prfx\expandafter{\kcmd@prfx#1}\kcmd@pref@x@next}
-\def\kcmd@pref@x@next{\futurelet\x\kcmd@pref@x}
-\def\kcmd@error#1{\@latex@error{#1}\@ehd}
+\def\kcmd@next@prefix{\futurelet\x\kcmd@@prefix}
+\def\kcmd@expand@prefix{\expandafter\kcmd@next@prefix}
+\def\kcmd@addto@prfx#1{\let\y\@undefined
+ \expandafter\def\expandafter\kcmd@prfx
+ \expandafter{\kcmd@prfx#1}\kcmd@next@addto}
+\expandafter\def\expandafter\kcmd@space@prefix\space{\kcmd@next@prefix}
+\def\kcmd@error@prefix{\@latex@error{A \string\def\space
+ (or \string\gdef\space or \string\edef\space or \string\xdef)\MessageBreak
+ was expected after \string\keycmd\MessageBreak
+ I found a \meaning\x!\MessageBreak
+ see keycommand documentation for more information}\@ehd}
\def\key@cmd#1{\@testopt{\expandafter\@keycmd\noexpand#1}{}}
\def\@keycmd#1[#2]{\@tempswafalse\expandafter
\@rc@ifdefinable\noexpand#1{\@tempswatrue}%
@@ -112,7 +121,7 @@
\kcmd@undefinekeys{\kcmd@gbl}{#1}%
\kv@parse{##1}{\kcmd@definekey{\kcmd@gbl}{#1}{\kcmd@fam}}%
\kcmd@gbl\protected\def#1{% entry point
- \protected\def\commandkey########1{\noexpand\csname\kcmd@fam @########1\endcsname}%
+ \def\commandkey########1{\noexpand\csname\kcmd@fam @########1\endcsname}%
\def\"kcmd\string#1"########1[########2]{%
\kvsetkeys{\kcmd@fam}{########1,########2}%
\"\string #1"}%
@@ -129,11 +138,11 @@
in the keycommand \string#1!\MessageBreak
see the definition of the keycommand (or environment)\wheremsg}\@ehd}
\DeclareRobustCommand\newkeycommand{\@star@or@long
- \expandafter\new@keycommand\noexpand}
+ {\expandafter\new@keycommand\noexpand}}
\DeclareRobustCommand\renewkeycommand{\@star@or@long
- \expandafter\renew@keycommand\noexpand}
+ {\expandafter\renew@keycommand\noexpand}}
\DeclareRobustCommand\providekeycommand{\@star@or@long
- \expandafter\provide@keycommand\noexpand}
+ {\expandafter\provide@keycommand\noexpand}}
\def\new@keycommand#1{\@testopt{\expandafter\@newkeycommand\noexpand#1}{}}
\def\@newkeycommand#1[#2]{\begingroup
\@tempswafalse\expandafter
@@ -181,20 +190,36 @@
\expandafter\let\csname\expandafter\string\csname #1\endcsname\endcsname\relax
\expandafter\let\csname end#1\endcsname\relax
\new@keyenvironment{#1}}
-\def\kv@normalize#1{%
- \begingroup
- \toks@{,#1,}%
- \KVS@Comma
- \KVS@SpaceComma{ }%
- \KVS@CommaSpace
- \KVS@CommaComma
- \KVS@Equals
- \KVS@SpaceEquals{ }%
- \KVS@EqualsSpace% <original code>\KVS@EqualsSpace{ }</original code>
- \xdef\KVS@Global{\the\toks@}%
- \endgroup
- \let\kv@list\KVS@Global
-}
+
+
+\def\kcmd@afterelse#1\else#2\fi{\fi#1}
+\def\kcmd@afterfi#1\fi{\fi#1}
+\newcommand\kcmd@expandnext[2]{%
+ \ifx#1\kcmd@expandnext
+ \kcmd@afterelse\expandafter\expandafter\expandafter
+ \expandafter\@kcmd@expandnext{#2}{\expandafter\expandafter\expandafter}%
+ \else\kcmd@afterfi\expandafter#1\expandafter{#2}%
+ \fi}
+\long\def\@kcmd@expandnext#1#2#3{%
+ \ifx#1\kcmd@expandnext
+ \expandafter\kcmd@afterelse\expandafter\expandafter\expandafter
+ \expandafter\@kcmd@expandnext{#3}{\expandafter#2#2}%
+ \else
+ \expandafter\kcmd@afterfi#2#1#2{#3}%
+ \fi}
+\def\kcmd@expandonce#1{\unexpanded\expandafter{#1}}
+\begingroup\catcode`\:=4\catcode`\&=4
+\gdef\kcmd@ifblank#1{\kcmd@ifblank@#1&&\@secondoftwo\@firstoftwo:}
+\gdef\kcmd@ifblank@#1#2&#3#4#5:{#4}
+\endgroup
+\newcommand\ifcommandkey[3]{%
+ \kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@expandnext
+ \kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@expandnext
+ \kcmd@expandnext\kcmd@expandnext\kcmd@expandnext\kcmd@ifblank{%
+ \kcmd@expandnext\kcmd@expandnext\kcmd@expandonce{\commandkey{#1}}}
+ {#3}
+ {#2}}
+\kcmd@AtEnd
\endinput
%%
%% End of file `keycommand.sty'.