summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/storecmd
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-10-18 22:27:52 +0000
committerKarl Berry <karl@freefriends.org>2011-10-18 22:27:52 +0000
commit9034d579ec475d9282ef5566f4175debd5cfa818 (patch)
tree62a63a3f1539da20963b27fa0f0dca2d8fd431c4 /Master/texmf-dist/tex/latex/storecmd
parent86a5f1787b71ce0d2d78ec9cc32fe01f4b97d3ee (diff)
new latex package storecmd (18oct11)
git-svn-id: svn://tug.org/texlive/trunk@24317 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/storecmd')
-rw-r--r--Master/texmf-dist/tex/latex/storecmd/storecmd.sty224
1 files changed, 224 insertions, 0 deletions
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