diff options
author | Karl Berry <karl@freefriends.org> | 2011-10-18 22:27:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-10-18 22:27:52 +0000 |
commit | 9034d579ec475d9282ef5566f4175debd5cfa818 (patch) | |
tree | 62a63a3f1539da20963b27fa0f0dca2d8fd431c4 | |
parent | 86a5f1787b71ce0d2d78ec9cc32fe01f4b97d3ee (diff) |
new latex package storecmd (18oct11)
git-svn-id: svn://tug.org/texlive/trunk@24317 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/storecmd/README | 105 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex | 29 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/storecmd/storecmd.sty | 224 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/storecmd.tlpsrc | 0 |
6 files changed, 360 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/storecmd/README b/Master/texmf-dist/doc/latex/storecmd/README new file mode 100644 index 00000000000..e380405f9d8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/storecmd/README @@ -0,0 +1,105 @@ +This is the README file for the 'storecmd' package. + +VERSION + +Version 0.0.1, October 2011. + +SUMMARY + +This package provides macros for command definition that save the +name of the command being defined in a file or a macro container. +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 +macros are provided for this purpose: + +\defsavecmd<cmd><param>{<defn>} +\newsavecmd<cmd><param>{<defn>} +\renewsavecmd<cmd><param>{<defn>} + +Here <cmd> is the command name, <param> is the parameter list, and +<defn> is the replacement text. In \defsavecmd, the <param> list is +as in \def; in \newsavecmd and \renewsavecmd, the <param> list is +as in \newcommand. \defsavecmd will overwrite an existing command; +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. + +The package options are: + +neversave - Never save/store the new commands in the container + file or command. The new commands will still be defined. + Default: false + +storerenew - Allow the storage of a command that has already + been stored. This is used by \renewsavecmd. + Default: false. + +overwrite - Allow overwrite of an existing container file or + command. Default: false. + +storefile - Container file. Default: cmdnamesfile. + +storecmd - Container command. Default: cmdnamesmacro. + +verbose - Give extra information in the transcript file. + Default: true. Turn this off if you don't like + or need such information. + + +EXAMPLE FILE + +\begin{filecontents}{storecmd-example.tex} +\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 command is being refilled: +% \def\mycommands{} + +\usepackage[ + storerenew=true,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\cmdd[2][yy]{xxx#1#2} +\protectedcmd\globalcmd\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}} + +% Try \show\mycommands or see file 'mycommands.tex'. + +\begin{document} +Blackberry lily. +\end{document} +\end{filecontents} + + +LICENSE + +Copyright (c) October 2011 Ahmed Musa (amusa22@gmail.com) + +This work (ie, all the files in the storecmd manifest) may be +distributed and/or modified under the conditions of the LaTeX +Project Public License (LPPL), either version 1.3 of this license or +any later version. The latest version of this license is in +http://www.latex-project.org/lppl.txt and version 1.3 or later +is part of all distributions of LaTeX version 2005/12/01 or later. + +The LPPL maintenance status of this software is 'author-maintained'. + +This software is provided 'as it is', without warranty of any +kind, either expressed or implied, including, but not limited to, +the implied warranties of merchantability and fitness for a +particular purpose. + + + + diff --git a/Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex b/Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex new file mode 100644 index 00000000000..c1325c8d9f6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/storecmd/storecmd-example.tex @@ -0,0 +1,29 @@ +\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 command is being refilled: +% \def\mycommands{} + +\usepackage[ + 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\cmdd[2][yy]{xxx#1#2} +\protectedcmd\globalcmd\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}} + +% Try \show\mycommands or see file 'mycommands.tex'. + +\begin{document} + +Blackberry lily. + +\end{document} diff --git a/Master/texmf-dist/tex/latex/storecmd/storecmd.sty b/Master/texmf-dist/tex/latex/storecmd/storecmd.sty new file mode 100644 index 00000000000..9c8b410740c --- /dev/null +++ b/Master/texmf-dist/tex/latex/storecmd/storecmd.sty @@ -0,0 +1,224 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'storecmd.sty', version 0.0.1, October 2011. % +% % +% This package and accompanying files may be distributed and/or % +% modified under the conditions of the LaTeX Project Public License, % +% either version 1.3 of this license or any later version. The latest % +% version of this license is in http://www.latex-project.org/lppl.txt % +% and version 1.3 or later is part of all distributions of LaTeX % +% version 2005/12/01 or later. % +% % +% The LPPL maintenance status of this software is 'author-maintained'. % +% % +% This software is provided 'as it is', without warranty of any kind, % +% either expressed or implied, including, but not limited to, the % +% implied warranties of merchantability and fitness for a particular % +% purpose. % +% % +% Copyright (c) 2011 Ahmed Musa (amusa22@gmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{catoptions}{}{\RequirePackage{catoptions}[2011/08/07]} +\UseNormalCatcodes +\StyleFilePurpose{Store command name at definition time} +\StyleFileRCSInfo +$Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{storecmd}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2005/12/01] +\SetStyleFileMessages[stcmd@]{info}{warn}{err} +\RequirePackage{ltxtools}[2011/09/10] +\providecommand*\ifsentinelTF[1]{% + \edef\reserved@a{\unexpanded{#1}}% + \ifx\reserved@a\currsentinel\expandafter\@firstoftwo + \else\expandafter\@secondoftwo\fi +} +\robust@def*\stcmd@merge{\LTS@testopt\stcmd@m@rge,} +\robust@def*\stcmd@m@rge[#1]#2#3{% + \trim@@spaces{#3}\LTS@tempa + \ifdefTF#2{}{\def#2{}}% + \xifinsetTF{#1\@space\LTS@tempa#1}{#1\@space#2#1}{}{% + \xdef#2{\csliststack{#1\@space}#2\expandcsonce\LTS@tempa}% + }% +} +\newvariables{if}[stcmd@]{storefile,storecmd,storeescap,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}% + \lowercase\expandafter{\expandafter\def\expandafter + \@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}% + }{}% +} +\XDeclareSwitchOption{verbose}[true](stcmd@){% + \ifdefswitchTF{stcmd@verbose}{% + \stcmd@info{'verbose' set true\on@line}% + }{}% +} +\XDeclareCommandOption{storefile}[cmdnamesfile](stcmd@){% + \ifblankTF{#1}{% + \stcmd@err{No storage file name}\@ehc + \stcmd@storefilefalse + }{% + \if\stcmd@overwrite\else + \IfFileExists\stcmd@storefile{% + \message{^^J! File '\stcmd@storefile' already exists:}% + \stcmd@typeintocontinue + }{}% + \fi + \stcmd@storefiletrue + \NewWrites[stcmd@]{outputcheck}% + \immediate\openout\stcmd@outputcheck=\stcmd@storefile\@space + \immediate\write\stcmd@outputcheck{\relax}% + \LTS@AfterEndDocument{\immediate\closeout\stcmd@outputcheck}% + }% +} +\XDeclareCommandOption{storecmd}[cmdnamesmacro](stcmd@){% + \def\stcmd@tempa##1{% + \message{^^J! Command '##1\stcmd@storecmd' already exists:}% + \stcmd@typeintocontinue + }% + \ifblankTF{#1}{% + \stcmd@err{No storage command name}\@ehc + \stcmd@storecmdfalse + }{% + \stcmd@storecmdtrue + \ifescapedTF{#1}{% + \if\stcmd@overwrite\else + \ifdefFT{#1}{}{\stcmd@tempa\expandcsonce}% + \fi + \stcmd@storeescaptrue + \gdef#1{}% + }{% + \if\stcmd@overwrite\else + \ifcsndefFT{#1}{}{\stcmd@tempa\noexpandcsn}% + \fi + \stcmd@storeescapfalse + \csn@gdef{#1}{}% + }% + }% +} +\XDeclareOption*{\stcmd@warn{Unknown option '\CurrentOption' ignored}} +\XExecuteOptions{% + neversave=false,storerenew=false,overwrite=false,verbose=true +} +\XProcessOptions*\relax +\robust@def*\globalcmd{\stcmd@globaltrue} +\robust@def*\protectedcmd{\stcmd@protectedtrue} +\robust@def*\defsavecmd{\cpt@starorlong\stcmd@defsavecmd} +\robust@def*\newsavecmd{\cpt@starorlong\stcmd@newsavecmd} +\robust@def*\renewsavecmd{\cpt@starorlong\stcmd@renewsavecmd} +\robust@def*\stcmd@savecmd#1{% + \if\stcmd@neversave\else + \begingroup + \escapechar=92 + \xdef\@gtempa{\expandafter\@gobble\string#1}% + \endgroup + \ifstcmd@storefile + \immediate\write\stcmd@outputcheck{\@gtempa}% + \fi + \ifboolFT{stcmd@storecmd}{}{% + \cptexpanded{% + \stcmd@merge + \ifstcmd@storeescap + \expandcsonce\stcmd@storecmd + \else + \noexpandcsn\stcmd@storecmd + \fi + {\@gtempa}% + }% + }% + \fi +} +\robust@def*\stcmd@defsavecmd#1{% + \ifdefFT{#1}{}{% + \if\stcmd@verbose + \stcmd@info{Command '\string#1' is redefined\on@line}% + \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% +} +\robust@def*\stcmd@newsavecmd#1{% + \stcmd@savecmd{#1}% + \LTS@testopt{\stcmd@n@wc@mmand#1}{0}% +} +\robust@def*\stcmd@renewsavecmd#1{% + \ifdefTF{#1}{% + \if\stcmd@storerenew + \stcmd@savecmd{#1}% + \fi + \let\ifcsdefinable\rc@ifcsdefinable + \stcmd@n@wcommand#1% + }{% + \stcmd@err{Command '\string#1' is undefined: + \MessageBreak it can't be redefined}\@ehc + }% +} +\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]}% +} +\robust@def\stcmd@argdef#1[#2]#3{% + \ifcsdefinable#1{\stcmd@yargdef#1\@ne{#2}{#3}}% +} +\robust@def\stcmd@xargdef#1[#2][#3]#4{% + \ifcsdefinable#1{% + \ifstcmd@global\global\fi + \ifstcmd@protected\protected\fi + \expandafter\def\expandafter#1\expandafter{% + \expandafter\@protected@testopt\expandafter#1% + \csname\string#1\endcsname{#3}% + }% + \aftercsname\stcmd@yargdef{\string#1}\tw@{#2}{#4}% + }% +} +\robust@def\stcmd@yargdef#1#2#3{% + \ifx#2\tw@ + \def\reserved@b##11{[####1]}% + \else + \let\reserved@b\@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 + \fi + \ifstcmd@protected\stcmd@protectedfalse\protected\fi + \reserved@a\l@ngrel@x + \expandafter\def\expandafter#2\reserved@b##1#1% + }% + \reserved@a0##1##2##3##4##5##6##7##8##9###1% +} + +\endinput diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index a9e769b2c5c..3beaa9b1545 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -351,7 +351,7 @@ my @TLP_working = qw( srbook-mem srcltx sseq stack stage standalone starfont statistik statex statex2 staves stdclsdv stdpage steinmetz - stellenbosch stex stix stmaryrd storebox stringstrings struktex + stellenbosch stex stix stmaryrd storebox storecmd stringstrings struktex sttools stubs sty2dtx suanpan subdepth subeqn subeqnarray subfig subfigmat subfigure subfloat substr subsupscripts sudoku sudokubundle suftesi sugconf diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index 1088275c7eb..3375d7a3b6d 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -647,6 +647,7 @@ depend stdclsdv depend stdpage depend stex depend storebox +depend storecmd depend stringstrings depend sttools depend stubs diff --git a/Master/tlpkg/tlpsrc/storecmd.tlpsrc b/Master/tlpkg/tlpsrc/storecmd.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/storecmd.tlpsrc |