summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/storecmd/README4
-rw-r--r--Master/texmf-dist/doc/latex/storecmd/storecmd-guide.pdfbin0 -> 262857 bytes
-rw-r--r--Master/texmf-dist/doc/latex/storecmd/storecmd-guide.tex195
-rw-r--r--Master/texmf-dist/tex/latex/storecmd/storecmd.sty65
4 files changed, 237 insertions, 27 deletions
diff --git a/Master/texmf-dist/doc/latex/storecmd/README b/Master/texmf-dist/doc/latex/storecmd/README
index d872f0bdb3f..6d29072ce42 100644
--- a/Master/texmf-dist/doc/latex/storecmd/README
+++ b/Master/texmf-dist/doc/latex/storecmd/README
@@ -8,8 +8,8 @@ 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,
+Even when the user uses 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
diff --git a/Master/texmf-dist/doc/latex/storecmd/storecmd-guide.pdf b/Master/texmf-dist/doc/latex/storecmd/storecmd-guide.pdf
new file mode 100644
index 00000000000..d770dd5a3f7
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/storecmd/storecmd-guide.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/storecmd/storecmd-guide.tex b/Master/texmf-dist/doc/latex/storecmd/storecmd-guide.tex
new file mode 100644
index 00000000000..b6a30c4b2a3
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/storecmd/storecmd-guide.tex
@@ -0,0 +1,195 @@
+\documentclass[
+ use-a4-paper,
+ use-10pt-font,
+ final-version,
+ use-UK-English,
+ fancy-section-headings,
+ frame-section-numbers,
+ para-abstract-style,
+ input-config-file,
+ no-hyperref-messages,
+ wrapquote
+]{amltxdoc}
+
+\makeatletter
+\hfuzz1pt
+\makeindex
+\usepackage{makeidx}
+\subtitlefont{\bf\sf}
+
+\useshortdoccmds
+
+\begin{document}
+
+\begin{frontmatter}
+\title{The \texttt{\color{blue}storecmd} Package\titleref{t1}}
+\titlenotes[t1]{%
+ The package is available at \url{\titleurltext}.
+ This user manual corresponds to version~0.0.2 of the package.
+}
+\subtitle{Define command and save its name in a container file or macro}
+\titleurl{http://www.ctan.org/tex-archive/macros/latex/contrib/storecmd/}
+\author{Ahmed Musa\Email{amusa22@gmail.com}\\Preston, Lancashire, UK}
+
+\end{frontmatter}
+
+
+\hrule height.5pt depth.5pt width\textwidth
+\vskip 1ex plus 1pt minus 1pt
+\begingroup
+\hypersetup{linkcolor=blue}\tableofcontents
+\endgroup
+\hrule height.5pt depth.5pt width\textwidth
+
+
+\docsection(sec:intro){Introduction}
+
+This package provides macros for command definition that save the name of the command being defined in a file or a macro container. For ease of reference, we refer to macros for command definition as \quoted{master macros}, and the macro that stores the defined commands as the \quoted{container macro}. The file that stores the defined commands is the \quoted{container file}. In this package there are two categories of master macros for command definition: one category has a syntax similar to that of \tex's \hx{\def} while the other category has the syntax of \latex's \hx{\newcommand}. Only one master macro is available in the first category. Naturally, commands defined by the master macro of the first category can have their parameters delimited in the usual way. When the user uses one of the master macros for command definition from the second category (\ie, one of those that have a syntax similar to that of \hx{\newcommand}), some or all of the parameters of the defined command can be delimited, as desired by the command author. Normally, parameters of commands defined by \latex's \hx{\newcommand} can't be delimited.
+
+The package can also be used as a debugging tool, or at least as a command location tool: namely, to store the names of defined commands and the sources in which they are defined. This can be realized by using the \fx{showsource} package option. However, this will track only the commands defined by the master macros of this package. It is safe to assign \hhx'{\newcommand, \renewcommand} to \ffx'{\newsavecmd, \renewsavecmd}, respectively. But, for rather obvious reasons, it is not advisable to simply replace the native \hhx'{\global,\long,\protected,\def,\gdef} by the master macros of this package\footnote{One reason for this is that, for example, you can't do \ftfx{\stcglobal\let\x\y} or \ftfx{\stcglobal\@tempswatrue} because \ftffx'{\stcprotected,\stcglobal} are tailor made for the commands \ftffx'{\defsavecmd, \newsavecmd, \renewsavecmd}.}.
+
+
+\docsection{Motivation}
+
+The package was written in response to a post on \ltshref{https://groups.google.com/forum/
+#!topic/comp.text.tex/o14P2e83o4A}{comp.text.tex} for a macro that will define commands and also save the commands being defined in a file or a container macro, \eg, for spelling exceptions on editors that don't support \tex syntax.
+
+
+\docsection{Package options}
+
+The package options are described in \sref{tab:pkgoptions}.
+
+\extrarowheight=2pt
+\arrayrulecolor{yellow}
+\begin{tabularx}{\linewidth}{|m{3cm}|m{2.5cm}|X|}
+\caption{Package options\label{tab:pkgoptions}}\\\hline
+\rowcolor{pink}
+\bfseries Option&\bfseries Default&\bfseries Meaning\\\hline
+\endfirsthead
+\hline
+\multicolumn{3}{|l|}{\emph{Continued from last page}}\\\hline
+\bfseries Option&\bfseries Default&\bfseries Meaning\\\hline
+\endhead
+\multicolumn{3}{|r|}{\emph{Continued on next page}}\\\hline
+\endfoot
+\hline
+\endlastfoot
+\fxi{neversave} & \texttt{false} & Never save/store the new command name in the container file or container macro. The new commands will still be defined.\\\hline
+\fxi{storerenew} & \texttt{false} & Allow the storage of a command name that has already been stored. This is used by \fx{\renewsavecmd}.\\\hline
+\fxi{overwrite} & \texttt{false} & Allow overwrite of an existing container file or container macro.\\\hline
+\fxi{storefile} & \fxi{containerfile} & Container file name.\\\hline
+\fxi{storecmd} & \fxi{containermacro} & Container macro name.\\\hline
+\fxi{showsource} & \texttt{false} & Show the name of the source file of the command.\\\hline
+\fxi{verbose} & \texttt{true} & Give extra information in the transcript file. Turn this option off if you don't like or need such information, but only minimal information is actually logged.\\\hline
+\end{tabularx}
+
+When a boolean option is given without value, its value is assumed to be \hx{true}.
+
+
+\docsection{User commands}
+
+Three master macros are provided for storing command names:
+
+\start{newmacro}[\defsavecmd,\newsavecmd,\renewsavecmd]
+\defsavecmd|A(cmd)|A(param){|A(defn)}
+\newsavecmd|A(cmd)[|A(nparam)][|A(default)]{|A(defn)}
+\renewsavecmd|A(cmd)[|A(nparam)][|A(default)]{|A(defn)}
+\finish{newmacro}
+\fxi*{\defsavecmd,\newsavecmd,\renewsavecmd}
+
+Here \ang{cmd} is the command name, \ang{param} is the parameter list, \ang{nparam} is the number of parameters, \ang{default} is the default value of the first parameter/argument, and \ang{defn} is the replacement text. In \fx{\defsavecmd}, the \ang{param} list is as in \tex's \hx{\def}; in \ffx'{\newsavecmd, \renewsavecmd}, the \ang{nparam} and \ang{default} are as in \hx{\newcommand}. Both \ffx'{\defsavecmd, \renewsavecmd} will overwrite an existing command, but \fx{\newsavecmd} will not do so.
+
+The commands \ffx'{\defsavecmd, \newsavecmd, \renewsavecmd} may be prefixed by \fx{\stcglobal} and/or \fx{\stcprotected} to yield global or robust definitions, respectively. For example,
+
+\start{example}[\stcglobal,\stcprotected]
+\defsavecmd\cmda#1#2{xxx#1#2}
+|R(\stcglobal)\defsavecmd\cmdb#1#2{xxx#1#2}
+|R(\stcglobal)\newsavecmd\cmdc[2]{xxx#1#2}
+|R(\stcprotected\stcglobal)\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}}
+\finish{example}
+\fxi*{\stcglobal,\stcprotected}
+
+
+\docsubsection{Delimited parameters}
+
+The parameters of \fx{\defsavecmd} can readily be delimited as in the case of \tex's \hx{\def}. The parameters of \ffx'{\newsavecmd, \renewsavecmd} can be delimited as follows:
+
+\start'{newmacro}[Delimited parameters]
+\newsavecmd|A(cmd)[|A(param)][|A(default)]|(|A(delimiters)|){|A(defn)}
+\renewsavecmd|A(cmd)[|A(param)][|A(default)]|(|A(delimiters)|){|A(defn)}
+\finish{newmacro}
+
+The \ang{delimiters}, given here in parenthesis, have the syntax
+
+\start'{newmacro}[Delimited parameters]
+1|A(delim1) 2|A(delim2) ... 9|A(delim9)
+\finish{newmacro}
+
+where \ang{delim1} is the delimiter for the first parameter, etc. Only the parameters with delimiters are to be specified in \ang{delimiters}. For example,
+
+\start'{example}[Delimited parameters]
+\newsavecmd\cmda[2]|(1\@nil 2\@mil|){xxx#1#2}
+\newsavecmd\cmdb[9][yy]|(3\@nil 4\@mil 6\@nnil|){xxx#1#2#3...#9}
+\finish{example}
+
+When the first argument is optional, then it can't have a delimiter, since the delimiter for that parameter is already \quotedfx{[]}.
+
+
+\docsection{Examples}
+
+The following example is available in the accompanying \file{storecmd-example} file:
+
+\start{example}[\defsavecmd,\newsavecmd,\stcglobal, etc]
+\documentclass{article}
+% Container commands are also accepted as package options, but in this
+% case `catoptions' must be loaded before \usepackage{storecmd}.
+% Eg,
+% \usepackage{catoptions}
+% \usepackage[storecmd=\mycommands]{storecmd}
+%
+% Uncomment the next line to test what happens when an existing container
+% command is being refilled:
+% \def\mycommands{}
+
+\usepackage[
+ storerenew=true,storecmd=mycommands,storefile=mycommands
+]{storecmd}
+
+\defsavecmd\cmda#1#2{xxx#1#2}
+\stcglobal\defsavecmd\cmdb#1#2{xxx#1#2}
+\stcglobal\newsavecmd\cmdc[2]{xxx#1#2}
+\stcglobal\newsavecmd\cmdd[2][yy]{xxx#1#2}
+\stcprotected\stcglobal\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}}
+\stcprotected\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'.
+
+\begin{document}
+Blackberry lily.
+\end{document}
+\finish{example}
+\fxi*{\defsavecmd,\newsavecmd,\renewsavecmd}
+
+
+\docsection(sec:version-hist){Version history}
+
+The \stsign on the right-hand side of the following lists means the subject features in the package but is not reflected anywhere in this user guide.
+
+\begin{versionhist}
+ \begin{version}{0.0.2}{2011/10/22}
+ \item User guide completed.\vsecref*
+ \end{version}
+ \begin{version}{0.0.1}{2011/10/17}
+ \item First public release.\vsecref*
+ \end{version}
+\end{versionhist}
+
+\newpage
+\ltsindexpreamble{Index numbers refer to page numbers.}
+\ltsindexpreambleformat{\centering}
+\ltsindexcolumns\tw@
+
+\printindex
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/storecmd/storecmd.sty b/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
index 79a2d78562b..08a81919d0d 100644
--- a/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
+++ b/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
@@ -29,6 +29,8 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\SetStyleFileMessages[stcmd@]{info}{warn}{err}
\RequirePackage{ltxtools}[2011/09/10]
+\robust@def*\stcmd@verbosewarn#1{\ifstcmd@verbose\stcmd@warn{#1}\fi}
+\robust@def*\stcmd@verboseinfo#1{\ifstcmd@verbose\stcmd@info{#1}\fi}
\providecommand*\ifsentinelTF[1]{%
\edef\reserved@a{\unexpanded{#1}}%
\ifx\reserved@a\currsentinel\expandafter\@firstoftwo
@@ -42,7 +44,8 @@ $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,cmdescap,global,protected}
+\newvariables{if}[stcmd@]{storefile,storecmd,cmdescap,global,long,
+ protected,verbose}
\robust@def*\stcmd@typeintocontinue{%
\message{^^JType x or X to quit, or <RETURN> to proceed^^J}%
{\endlinechar-1\global\read-1 to\@gtempa}%
@@ -50,21 +53,15 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\@gtempa\expandafter{\@gtempa}}%
\xifstrcmpTF\@gtempa{x}\LTS@emergencystop\relax
}
-\XDeclareSwitchOption{storerenew}[true](stcmd@){%
- \ifdefswitchTF{stcmd@storerenew}{%
- \stcmd@info{'storerenew' set true\on@line}%
- }{}%
-}
-\XDeclareSwitchOption{overwrite}[true](stcmd@){%
- \ifdefswitchTF{stcmd@overwrite}{%
- \stcmd@info{'overwrite' set true\on@line}%
- }{}%
-}
-\XDeclareSwitchOption{neversave}[true](stcmd@){%
- \ifdefswitchTF{stcmd@neversave}{%
- \stcmd@info{'neversave' set true\on@line}%
- }{}%
+
+\docommalist{storerenew,overwrite,neversave,showsource}{%
+ \XDeclareSwitchOption{#1}[true](stcmd@){%
+ \ifdefswitchTF{stcmd@#1}{%
+ \stcmd@verboseinfo{'#1' set true\on@line}%
+ }{}%
+ }%
}
+
\XDeclareSwitchOption{verbose}[true](stcmd@){%
\ifdefswitchTF{stcmd@verbose}{%
\stcmd@info{'verbose' set true\on@line}%
@@ -115,22 +112,35 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
}
\XDeclareOption*{\stcmd@warn{Unknown option '\CurrentOption' ignored}}
\XExecuteOptions{%
- neversave=false,storerenew=false,overwrite=false,verbose=true
+ verbose=true,neversave=false,storerenew=false,overwrite=false,
+ showsource=false
}
\XProcessOptions*\relax
+\robust@def*\longcmd{\stcmd@longtrue}
\robust@def*\globalcmd{\stcmd@globaltrue}
\robust@def*\protectedcmd{\stcmd@protectedtrue}
-\robust@def*\stcmd@global@protected{%
+\robust@def*\stcmd@cmdprefixes@a{%
+ \ifstcmd@global\global\fi
+ \ifstcmd@long\long\fi
+ \ifstcmd@protected\protected\fi
+}
+\robust@def*\stcmd@cmdprefixes@b{%
\ifstcmd@global
\stcmd@globalfalse
- \let\stcmd@tempa\global
+ \let\stcmd@global\global
+ \else
+ \let\stcmd@global\@empty
+ \fi
+ \ifstcmd@long
+ \stcmd@longfalse
+ \let\stcmd@long\long
\else
- \let\stcmd@tempa\@empty
+ \let\stcmd@long\@empty
\fi
\ifstcmd@protected
\stcmd@protectedfalse\protected
\fi
- \stcmd@tempa
+ \stcmd@global\stcmd@long
}
\robust@def*\defsavecmd{\cpt@starorlong\stcmd@defsavecmd}
\robust@def*\newsavecmd{\cpt@starorlong\stcmd@newsavecmd}
@@ -139,7 +149,13 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\if\stcmd@neversave\else
\begingroup
\escapechar=92
- \xdef\@gtempa{\expandafter\@gobble\string#1}%
+ \xdef\@gtempa{%
+ \expandafter\@gobble\string#1%
+ \if\stcmd@showsource
+ \@space(\ifx\@currname\@empty
+ \jobname.tex\else\@currname.\@currext\fi)%
+ \fi
+ }%
\endgroup
\ifstcmd@storefile
\immediate\write\stcmd@outputcheck{\@gtempa}%
@@ -164,7 +180,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\fi
}%
\stcmd@savecmd{#1}%
- \stcmd@global@protected\l@ngrel@x\def#1%
+ \stcmd@cmdprefixes@b\l@ngrel@x\def#1%
}
\robust@def*\stcmd@newsavecmd#1{%
\stcmd@savecmd{#1}%
@@ -200,8 +216,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\robust@def\stcmd@xargdef@b#1#2#3(#4)#5{%
\def\stcmd@tempd{#4}%
\ifcsdefinable#1{%
- \ifstcmd@global\global\fi
- \ifstcmd@protected\protected\fi
+ \stcmd@cmdprefixes@a
\expandafter\def\expandafter#1\expandafter{%
\expandafter\@protected@testopt\expandafter#1%
\csname\string#1\endcsname{#3}%
@@ -220,7 +235,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\robust@def\stcmd@zargdef#1#2{%
\begingroup
\def\stcmd@tempa##1#1##2##{%
- \def\stcmd@tempc{\stcmd@global@protected\l@ngrel@x}%
+ \def\stcmd@tempc{\stcmd@cmdprefixes@b\l@ngrel@x}%
\cptexpandsecond{\expandafter\endgroup\stcmd@tempc
\expandafter\def\expandafter#2\stcmd@tempb##1#1}{\elt{#1}}%
}%