summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/storecmd/README39
-rw-r--r--Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex6
-rw-r--r--Master/texmf-dist/tex/latex/storecmd/storecmd.sty105
3 files changed, 113 insertions, 37 deletions
diff --git a/Master/texmf-dist/doc/latex/storecmd/README b/Master/texmf-dist/doc/latex/storecmd/README
index e380405f9d8..d872f0bdb3f 100644
--- a/Master/texmf-dist/doc/latex/storecmd/README
+++ b/Master/texmf-dist/doc/latex/storecmd/README
@@ -8,9 +8,13 @@ SUMMARY
This package provides macros for command definition that save the
name of the command being defined in a file or a macro container.
+While using a syntax similar to that of \newcommand, some or all of
+the parameters of the defined command can be delimited,
+as desired by the command author.
+
It was written in response to a post on comp.text.tex for a macro
that will define commands and also save the commands being defined
-in a file or a container macro for spelling exceptions. Three
+in a file or a container macro, eg, for spelling exceptions. Three
macros are provided for this purpose:
\defsavecmd<cmd><param>{<defn>}
@@ -25,9 +29,36 @@ both \newsavecmd and \renewsavecmd will not do so.
The commands \defsavecmd, \newsavecmd and \renewsavecmd may be
prefixed by \globalcmd and/or \protectedcmd to yield global or robust
-definitions, respectively.
+definitions, respectively. For example,
+
+\defsavecmd\cmda#1#2{xxx#1#2}
+\globalcmd\defsavecmd\cmdb#1#2{xxx#1#2}
+\globalcmd\newsavecmd\cmdc[2]{xxx#1#2}
+\protectedcmd\globalcmd\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}}
+
+The parameters of \defsavecmd can readily be delimited as in the case
+of \def. The parameters of \newsavecmd and \renewsavecmd can be
+delimited as follows:
+
+\newsavecmd<cmd><param>(<delimiters>){<defn>}
+\renewsavecmd<cmd><param>(<delimiters>){<defn>}
+
+The <delimiters>, given in parenthesis, have the syntax:
+
+1<\delim1> 2<\delim2> ... 9<\delim9>
+
+where <\delim1> is the delimiter for the first parameter, etc. Only the
+parameters with delimiters are to be specified in <delimiters>.
+For example,
+
+\protectedcmd\newsavecmd\cmda[2](1\@nil 2\@mil){xxx#1#2}
+\newsavecmd\cmdb[9][yy](3\@nil 9\@mil){xxx#1#2#3...#9}
+
+When the first argument is optional, then it can't have a delimiter,
+since the delimiter for that parameter is already '[]'.
+
-The package options are:
+The package options are
neversave - Never save/store the new commands in the container
file or command. The new commands will still be defined.
@@ -73,6 +104,8 @@ EXAMPLE FILE
\globalcmd\newsavecmd\cmdc[2]{xxx#1#2}
\globalcmd\newsavecmd\cmdd[2][yy]{xxx#1#2}
\protectedcmd\globalcmd\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}}
+\newsavecmd\cmde[2](1\@nil 2\@mil){xxx#1#2}
+\newsavecmd\cmdf[9][yy](2\@nil 3\@mil){xxx#1#2#3...#9}
% Try \show\mycommands or see file 'mycommands.tex'.
diff --git a/Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex b/Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex
index c1325c8d9f6..d7f0afc9688 100644
--- a/Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex
+++ b/Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex
@@ -11,14 +11,16 @@
% \def\mycommands{}
\usepackage[
- storerenew=false,storecmd=mycommands,storefile=mycommands
+ storerenew=false,storecmd=mycommands,storefile=mycommands,
]{storecmd}
\defsavecmd\cmda#1#2{xxx#1#2}
\globalcmd\defsavecmd\cmdb#1#2{xxx#1#2}
-\globalcmd\newsavecmd\cmdc[2]{xxx#1#2}
+\globalcmd\newsavecmd*\cmdc[2]{xxx#1#2}
\globalcmd\newsavecmd\cmdd[2][yy]{xxx#1#2}
\protectedcmd\globalcmd\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}}
+\protectedcmd\newsavecmd\cmde[2](1\@nil 2\@mil){xxx#1#2}
+\newsavecmd\cmdf[9][yy](3\@nil 9\@mil){xxx#1#2#3...#9}
% Try \show\mycommands or see file 'mycommands.tex'.
diff --git a/Master/texmf-dist/tex/latex/storecmd/storecmd.sty b/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
index 9c8b410740c..79a2d78562b 100644
--- a/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
+++ b/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
@@ -42,7 +42,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\xdef#2{\csliststack{#1\@space}#2\expandcsonce\LTS@tempa}%
}%
}
-\newvariables{if}[stcmd@]{storefile,storecmd,storeescap,global,protected}
+\newvariables{if}[stcmd@]{storefile,storecmd,cmdescap,global,protected}
\robust@def*\stcmd@typeintocontinue{%
\message{^^JType x or X to quit, or <RETURN> to proceed^^J}%
{\endlinechar-1\global\read-1 to\@gtempa}%
@@ -102,13 +102,13 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\if\stcmd@overwrite\else
\ifdefFT{#1}{}{\stcmd@tempa\expandcsonce}%
\fi
- \stcmd@storeescaptrue
+ \stcmd@cmdescaptrue
\gdef#1{}%
}{%
\if\stcmd@overwrite\else
\ifcsndefFT{#1}{}{\stcmd@tempa\noexpandcsn}%
\fi
- \stcmd@storeescapfalse
+ \stcmd@cmdescapfalse
\csn@gdef{#1}{}%
}%
}%
@@ -120,6 +120,18 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\XProcessOptions*\relax
\robust@def*\globalcmd{\stcmd@globaltrue}
\robust@def*\protectedcmd{\stcmd@protectedtrue}
+\robust@def*\stcmd@global@protected{%
+ \ifstcmd@global
+ \stcmd@globalfalse
+ \let\stcmd@tempa\global
+ \else
+ \let\stcmd@tempa\@empty
+ \fi
+ \ifstcmd@protected
+ \stcmd@protectedfalse\protected
+ \fi
+ \stcmd@tempa
+}
\robust@def*\defsavecmd{\cpt@starorlong\stcmd@defsavecmd}
\robust@def*\newsavecmd{\cpt@starorlong\stcmd@newsavecmd}
\robust@def*\renewsavecmd{\cpt@starorlong\stcmd@renewsavecmd}
@@ -135,7 +147,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\ifboolFT{stcmd@storecmd}{}{%
\cptexpanded{%
\stcmd@merge
- \ifstcmd@storeescap
+ \ifstcmd@cmdescap
\expandcsonce\stcmd@storecmd
\else
\noexpandcsn\stcmd@storecmd
@@ -152,16 +164,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\fi
}%
\stcmd@savecmd{#1}%
- \ifstcmd@global
- \stcmd@globalfalse
- \let\reserved@a\global
- \else
- \let\reserved@a\@empty
- \fi
- \ifstcmd@protected
- \stcmd@protectedfalse\protected
- \fi
- \reserved@a\l@ngrel@x\def#1%
+ \stcmd@global@protected\l@ngrel@x\def#1%
}
\robust@def*\stcmd@newsavecmd#1{%
\stcmd@savecmd{#1}%
@@ -182,12 +185,20 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\robust@def*\stcmd@newcommand{\cpt@starorlong\stcmd@n@wcommand}
\robust@def*\stcmd@n@wcommand#1{\LTS@testopt{\stcmd@n@wc@mmand#1}0}
\robust@def*\stcmd@n@wc@mmand#1[#2]{%
- \ifnextisbrack{\stcmd@xargdef#1[#2]}{\stcmd@argdef#1[#2]}%
+ \ifnextisbrack{\stcmd@xargdef@a#1{#2}}{\stcmd@argdef@a#1{#2}}%
+}
+\robust@def\stcmd@argdef@a#1#2{%
+ \LTS@testpnopt{\stcmd@argdef@b{#1}{#2}}{}%
+}
+\robust@def\stcmd@argdef@b#1#2(#3)#4{%
+ \def\stcmd@tempd{#3}%
+ \ifcsdefinable#1{\stcmd@yargdef#1\@ne{#2}{#4}}%
}
-\robust@def\stcmd@argdef#1[#2]#3{%
- \ifcsdefinable#1{\stcmd@yargdef#1\@ne{#2}{#3}}%
+\robust@def\stcmd@xargdef@a#1#2[#3]{%
+ \LTS@testpnopt{\stcmd@xargdef@b{#1}{#2}{#3}}{}%
}
-\robust@def\stcmd@xargdef#1[#2][#3]#4{%
+\robust@def\stcmd@xargdef@b#1#2#3(#4)#5{%
+ \def\stcmd@tempd{#4}%
\ifcsdefinable#1{%
\ifstcmd@global\global\fi
\ifstcmd@protected\protected\fi
@@ -195,30 +206,60 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\expandafter\@protected@testopt\expandafter#1%
\csname\string#1\endcsname{#3}%
}%
- \aftercsname\stcmd@yargdef{\string#1}\tw@{#2}{#4}%
+ \aftercsname\stcmd@yargdef{\string#1}\tw@{#2}{#5}%
}%
}
\robust@def\stcmd@yargdef#1#2#3{%
- \ifx#2\tw@
- \def\reserved@b##11{[####1]}%
+ \ifnum#2=\tw@
+ \def\stcmd@tempb##11{[####1]}%
\else
- \let\reserved@b\@gobble
+ \let\stcmd@tempb\@gobble
\fi
\expandafter\stcmd@zargdef\expandafter{\number#3}#1%
}
\robust@def\stcmd@zargdef#1#2{%
- \def\reserved@a##1#1##2##{%
- \ifstcmd@global
- \stcmd@globalfalse
- \let\reserved@a\global
- \else
- \let\reserved@a\@empty
+ \begingroup
+ \def\stcmd@tempa##1#1##2##{%
+ \def\stcmd@tempc{\stcmd@global@protected\l@ngrel@x}%
+ \cptexpandsecond{\expandafter\endgroup\stcmd@tempc
+ \expandafter\def\expandafter#2\stcmd@tempb##1#1}{\elt{#1}}%
+ }%
+ \@tempcnta\z@pt
+ \loop
+ \advance\@tempcnta\@ne
+ \csn@def{d\number\@tempcnta}{}%
+ \ifnum\@tempcnta<9\relax
+ \repeat
+ \ifx\stcmd@tempd\@empty\else
+ \@tempcnta\z@pt
+ \def\do##1##2{%
+ \ifstrcmpTF{##1}\zargdef@nil{}{%
+ \advance\@tempcnta\@ne
+ \ifnum\@tempcnta>#1\relax
+ \stcmd@err{Number of delimiters exceeds
+ number of parameters}\@ehc
+ \fi
+ \ifinsetTF{,##1,}{,1,2,3,4,5,6,7,8,9,}{}{%
+ \stcmd@err{Invalid delimiter syntax:
+ \MsgBrk no digit [1-9] found before delimiter}\@ehc
+ }%
+ \csn@def{d##1}{##2}\do
+ }%
+ }%
+ \expandafter\do\stcmd@tempd\zargdef@nil\zargdef@nil
+ \fi
+ \ifx\stcmd@tempb\@gobble\else
+ \expandafter\ifx\csname d1\endcsname\@empty\else
+ \stcmd@err{Argument one of command \string#2 is
+ \MsgBrk already delimited by '[]'}\@ehc
\fi
- \ifstcmd@protected\stcmd@protectedfalse\protected\fi
- \reserved@a\l@ngrel@x
- \expandafter\def\expandafter#2\reserved@b##1#1%
+ \fi
+ \def\elt##1{\expandcsnonce{d##1}}%
+ \edef\stcmd@tempc{0####1\ifx\stcmd@tempb\@gobble\elt1\fi
+ ####2\elt2####3\elt3####4\elt4####5\elt5####6\elt6%
+ ####7\elt7####8\elt8####9\elt9%
}%
- \reserved@a0##1##2##3##4##5##6##7##8##9###1%
+ \expandafter\stcmd@tempa\stcmd@tempc###1%
}
\endinput