summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-07-22 22:46:34 +0000
committerKarl Berry <karl@freefriends.org>2009-07-22 22:46:34 +0000
commit586bef91a24aca48fc2fe6f6d122746585d2baa5 (patch)
tree6c7b6bc23e193faf570f680f4a2b2cc17d9ee18b /Master/texmf-dist/tex/latex
parentad096edad39a94c7649a5a65bb33b7d88da8daea (diff)
new latex package ltxnew (22jul09)
git-svn-id: svn://tug.org/texlive/trunk@14371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/ltxnew/ltxnew.sty189
1 files changed, 189 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/ltxnew/ltxnew.sty b/Master/texmf-dist/tex/latex/ltxnew/ltxnew.sty
new file mode 100644
index 00000000000..83a34227d11
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/ltxnew/ltxnew.sty
@@ -0,0 +1,189 @@
+%%
+%% This is file `ltxnew.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% ltxnew.dtx (with options: `package')
+%%
+%% This is a generated file.
+%%
+%% ltxnew : provides the \new and \renew prefixes for checking definitions.
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3 of this license or (at your option) any later
+%% version. The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%%
+%% This work consists of the main source file ltxnew.dtx
+%% and the derived files
+%% ltxnew.sty, ltxnew.pdf, ltxnew.ins,
+%%
+%% ltxnew : an easy way to define commands with 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{ltxnew}
+ [2009/07/22 v1.0 provides the new and renew prefixes for checking definitions]
+
+\RequirePackage{etex}
+
+% \ltxn@expandonce is the copy of \expandonce from etoolbox.sty
+\def\ltxn@expandonce#1{\unexpanded\expandafter{#1}}
+
+% This is the entry point of the prefixes scanner:
+% The whole job is done by \futurelet
+\def\ltxn@prefix{\begingroup
+ \newif\ifglobal
+ \let\ltxn@prfx\@empty
+ \let\ltxn@rubbish\relax
+ \futurelet\x\ltxn@@prefix}
+% Here is the test macro: testing each prefix token one after another:
+% It consists in a long list of \ifx
+\def\ltxn@@prefix{%
+ \let\ltxn@next@addto\ltxn@next@prefix
+ \ifx\x\@sptoken \let\next\ltxn@space@prefix%%1
+ \else \let\next\ltxn@addto@prfx
+ \ifx\x\long \def\z{\long}%%2
+ \else\ifx\x\protected\def\z{\protected}%%3
+ \else\ifx\x\global \let\z\@empty\globaltrue%%4
+ \else\ifx\x\outer \def\z{\outer}%%5
+ \else
+ \ifx\x\expandafter \def\z{\expandafter}%%6
+ \else\ifx\x\noexpand \def\z{\noexpand}%%7
+ \else\ifx\x\relax \def\z{\relax}%%8
+ \else
+ \def\ltxn@next@addto{\expandafter\ltxn@def\noexpand}%
+ \ifx\x\let \def\z{\let}%%9
+ \let\ltxn@cancel\ltxn@cancel@let
+ \else \let\ltxn@cancel\ltxn@cancel@def
+ \ifx\x\def \edef\z{\ifglobal\global\fi\def}%%10
+ \else\ifx\x\edef \edef\z{\ifglobal\global\fi\edef}%%11
+ \else\ifx\x\gdef \def\z{\gdef}%%12
+ \else\ifx\x\xdef \def\z{\xdef}%%13
+ \else \let\ltxn@cancel\ltxn@cancel@new
+ \ifx\x\count \def\z{\newcount}%%14
+ \else\ifx\x\countdef%%15
+ \ifglobal\def\z{\globcount}\else\def\z{\loccount}\fi
+ \else\ifx\x\loccount%%16
+ \ifglobal\def\z{\globcount}\else\def\z{\loccount}\fi
+ \else\ifx\x\globcount \def\z{\globcount}%%17
+ \else\ifx\x\dimen \def\z{\newdimen}%%18
+ \else\ifx\x\dimendef%%19
+ \ifglobal\def\z{\globdimen}\else\def\z{\locdimen}\fi
+ \else\ifx\x\locdimen%%20
+ \ifglobal\def\z{\globdimen}\else\def\z{\locdimen}\fi
+ \else\ifx\x\globdimen \def\z{\globdimen}%%21
+ \else\ifx\x\skip \def\z{\newskip}%%22
+ \else\ifx\x\skipdef%%23
+ \ifglobal\def\z{\globskip}\else\def\z{\locskip}\fi
+ \else\ifx\x\locskip%%24
+ \ifglobal\def\z{\globskip}\else\def\z{\locskip}\fi
+ \else\ifx\x\globskip \def\z{\globskip}%%25
+ \else\ifx\x\muskip \def\z{\newmuskip}%%26
+ \else\ifx\x\muskipdef%%27
+ \ifglobal\def\z{\globmuskip}\else\def\z{\locmuskip}\fi
+ \else\ifx\x\locmuskip%%28
+ \ifglobal\def\z{\globmuskip}\else\def\z{\locmuskip}\fi
+ \else\ifx\x\globmuskip \def\z{\globmuskip}%%29
+ \else\ifx\x\savebox \def\z{\newsavebox}%%30
+ \else\ifx\x\box%%31
+ \ifglobal\def\z{\globbox}\else\def\z{\locbox}\fi
+ \else\ifx\x\locbox%%§32
+ \ifglobal\def\z{\globbox}\else\def\z{\locbox}\fi
+ \else\ifx\x\globbox \def\z{\globbox}%%33
+ \else\ifx\x\toksdef%%34
+ \ifglobal\def\z{\globtoks}\else\def\z{\loctoks}\fi
+ \else\ifx\x\toks \def\z{\newtoks}%%35
+ \else\ifx\x\loctoks%%36
+ \ifglobal\def\z{\globtoks}\else\def\z{\loctoks}\fi
+ \else\ifx\x\globtoks \def\z{\globtoks}%%37
+ \else\ifx\x\locmarks%%38
+ \ifglobal\def\z{\globmarks}\else\def\z{\locmarks}\fi
+ \else\ifx\x\marks \def\z{\newmarks}%%39 %\newmarks=\globmarks
+ \else\ifx\x\globmarks \def\z{\globmarks}%%40
+ \else\ifx\x\font \def\z{\font}%%41
+ \else\ifx\x\protect \ltxn@error@prefix%%42
+ \else
+ \let\ltxn@next@addto\ltxn@next@prefix
+ \ifx\y\x\ltxn@error@prefix
+ \else\let\y\x
+ \fi
+ \let\next\ltxn@expand@prefix
+ \fi\fi\fi\fi\fi\fi\fi\fi
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \fi\fi\fi\fi
+ \fi
+ \fi\fi\fi
+ \fi\fi\fi\fi% so many fees...
+ \fi\next}
+\def\ltxn@next@prefix{\futurelet\x\ltxn@@prefix}
+\def\ltxn@expand@prefix{%
+ \expandafter\futurelet\expandafter\x\expandafter\ltxn@@prefix}
+\def\ltxn@addto@prfx#1{\let\y\relax
+ \edef\ltxn@prfx{\ltxn@expandonce{\ltxn@prfx}\ltxn@expandonce{\z}}%
+ \ltxn@next@addto}
+\expandafter\def\expandafter\ltxn@space@prefix\space{\ltxn@next@prefix}
+\def\ltxn@error@prefix{\@latex@error{A \string\def\space
+ (or \string\countdef\space or\string\toksdef\space etc.)\MessageBreak
+ was expected after \string\new\MessageBreak
+ I found a \meaning\x!\MessageBreak
+ see ltxnew documentation for more information}\@ehd}
+
+% These are the macros used in case we have to cancel definition (nonstopmode)
+% #1 is always the control sequence not to redefine
+\def\ltxn@cancel@let{\afterassignment\endgroup\let\ltxn@rubbish}
+\def\ltxn@cancel@def{\afterassignment\endgroup\def\ltxn@rubbish}
+\def\ltxn@cancel@new{\endgroup}
+
+% new: Do define or cancel, depending on the result of \@ifdefinable
+\def\ltxn@new#1{%
+ \let\next\ltxn@cancel
+ \ifdefined#1\unless\ifx#1\relax\def#1{ltxn@throw@error}\fi\fi
+ \expandafter\@ifdefinable\noexpand#1{%
+ \expandafter\let\noexpand#1=\relax
+ \edef\next{\endgroup\ltxn@expandonce{\ltxn@prfx}\noexpand#1}}%
+ \next}
+
+% renew: Throws an error in case the control sequence is unknown or \relax
+\def\ltxn@renew#1{%
+ \edef\ltxn@name{\string#1 }%
+ \ifdefined#1 \ifx#1\relax \ltxn@error{renew: \ltxn@name undefined}\fi
+ \else \ltxn@error{renew: \ltxn@name undefined}%
+ \fi
+ \let#1=\relax
+ \def\next{\ltxn@new#1}%
+ \next}
+
+% provide: Never throw an error but conditionally defines the control sequence
+\def\ltxn@provide#1{%
+ \let\next\ltxn@cancel
+ \edef\ltxn@name{\string#1}%
+ \ifdefined#1 \ifx#1\relax \ltxn@provide@new\fi
+ \else \ltxn@provide@new
+ \fi
+ \next}
+\def\ltxn@provide@new{%
+ \edef\next{\noexpand\ltxn@new\csname\expandafter\@gobble\ltxn@name\endcsname}}
+
+% \new: the entry point:
+% just let the definition macro to be \ltxn@new and start scanning prefixes.
+\def\new{\let\ltxn@def\ltxn@new\ltxn@prefix}
+
+% \renew: the entry point:
+% just let the definition macro to be \ltxn@renew and start scanning prefixes.
+\def\renew{\let\ltxn@def\ltxn@renew\ltxn@prefix}
+
+% \provide: the entry point:
+% just let the definition macro to be |\ltxn@provide| and start scanning prefixes.
+\def\provide{\let\ltxn@def\ltxn@provide\ltxn@prefix}
+
+% In case of redefinition, throws an |\ehc|-type error:
+\def\ltxn@error#1{\@latex@error{#1}\@ehc}
+\endinput
+%%
+%% End of file `ltxnew.sty'.