summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gmutils/gmcommand.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-10-14 23:19:42 +0000
committerKarl Berry <karl@freefriends.org>2011-10-14 23:19:42 +0000
commit156a2b3e555456a90baac12411ebd5fcc7b9ef02 (patch)
tree3cf17f72769c1e200486df29e8d3b593feee7637 /Master/texmf-dist/tex/latex/gmutils/gmcommand.sty
parent000e5fcea9de9a48217705874f01a84133ddb70d (diff)
gmutils (14oct11)
git-svn-id: svn://tug.org/texlive/trunk@24287 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gmutils/gmcommand.sty')
-rw-r--r--Master/texmf-dist/tex/latex/gmutils/gmcommand.sty217
1 files changed, 155 insertions, 62 deletions
diff --git a/Master/texmf-dist/tex/latex/gmutils/gmcommand.sty b/Master/texmf-dist/tex/latex/gmutils/gmcommand.sty
index 574667d67bf..f83fc8a2c17 100644
--- a/Master/texmf-dist/tex/latex/gmutils/gmcommand.sty
+++ b/Master/texmf-dist/tex/latex/gmutils/gmcommand.sty
@@ -2,7 +2,7 @@
%% \iffalse ^^A we skip the debug setting
\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{}
%% \fi
-%% ^^A $Id: TheUltimateMaster.gmd,v 0.297 2011/02/02 18:13:11 natror Exp natror $
+%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $
%% This is file “gmcommand.sty” generated with the DocStrip utility.
%%
%%
@@ -13,7 +13,7 @@
%%
%% Copyright ©
%% by Grzegorz ‘Natror’ Murzynowski
-%% natror (at) o2 (dot) pl
+%% natror (at) gmail (dot) com
%%
%% This program is subject to the LaTeX Project Public License.
%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
@@ -23,20 +23,20 @@
%%
%%
%%
-%% For the documentation please refer to the file(s)
+%% For documentation please refer to the file(s)
%% gmutils.{gmd,pdf}.
%%
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmcommand}
- [2010/10/24 v0.993 definition of powerful \string \DeclareCommand \string &al. (GM)]
+ [2011/10/12 v0.996 definition of \string \DeclareCommand \string &al. based on the ancient xparse (pre-expl3) (GM)]
%%
%%
%% ^^A\typeout{\unexpanded{#4}}%%
-\RequirePackage{gmbase} % we require the tricky low-level macros.
+\RequirePackage{gmbase} % we require the low-level macros.
\unless\ifcsname ifgmu@quiet\endcsname
\Name\newif {ifgmu@quiet}% % it has to be at least (at highest) in
@@ -44,7 +44,6 @@
% % \pk{gmutils.sty} (a bug fix)}
\fi
- %
\unless\ifdefined\@temptokenb
\newtoks\@temptokenb
@@ -142,9 +141,11 @@
{\@dc@arguments{#2}#1\the\@dc@arguments}%
}
+\newtoks \@dc@ParsedSpecs
+
\def\@dc@ResetParseAuxilia{%
%
- \emptify\@dc@ParsedSpecs{}%
+ \@dc@ParsedSpecs={}%
%
\c@dc@catchernum\z@ % the count of catchers
\c@dc@argnum\z@ % the count of arguments (inner arity) (it may be
@@ -198,15 +199,15 @@
\def\@dc@argtypes{%
=\gobblespace \loop \lostwax \SameAs \Scope
- AaBbCcDdGgKkMmOo% ^^U Ôô
- QqSs*TtŤťUuǓǔWw%
+ AaBbCcDdGgKkMmOo%
+ QqSs*TtUuWw%
\drs
}
-\def\@dc@drses{\drs}
+\def\@dc@drses{\drs} % decimal respecting space
\@ifXeTeX
-{\addtomacro\@dc@argtypes{ďĎ}%
+{\addtomacro\@dc@argtypes{ďĎŤťǓǔÔô}%
\addtomacro\@dc@drses{ďĎ}%
}
{}
@@ -241,6 +242,7 @@
{\@dc@addtoparsed@BareSpace }
{}%
%
+ %
\gmu@ifsw {@dc@long@}%
{\@dc@addtospecs@bare{>P}}
{}%
@@ -399,6 +401,11 @@
\@dc@DeclareDefault Q {\NoValue}
+\@ifXeTeX {%
+ \@dc@DeclareDefault Ô{\NoValue}%
+}
+{}
+
\@dc@DeclareDefault U {\NoValue}
\long\def\@dc@maybe@expandafter #1{%
@@ -418,9 +425,9 @@
\long\def\@dc@addtospecs #1{%
\@dc@maybe@expandafter {#1}%
- {\@xa \addtomacro \@xa\@dc@ParsedSpecs\@xa{\@xa{#1}}%
+ {\@xa \addtotoks \@xa\@dc@ParsedSpecs\@xa{\@xa{#1}}%
}%
- {\addtomacro\@dc@ParsedSpecs{{#1}}}%
+ {\addtotoks\@dc@ParsedSpecs{{#1}}}%
}
\long\def\dc@addtoParsed@ #1{%
@@ -429,7 +436,7 @@
}
\long\def\@dc@addtospecs@bare #1{%
- \addtomacro\@dc@ParsedSpecs{#1}%
+ \addtotoks\@dc@ParsedSpecs{#1}%
}
\long\def\@dc@addtotoks@bare #1{%
@@ -465,11 +472,13 @@
\Restore@Macro\@dc@addargum}%
}
+\StoreMacro@nocat\gmu@passbraced
+
\pdef\@dc@BareSpaceArg{%
- \let \@dc@Loop@CareOfSpace \@dc@Loop@CareOfSpace@NoBraces
+ \let \gmu@passbraced \gmu@passbracedNotSp
\def\@dc@addargum {%
\Restore@Macro\@dc@addargum
- \Restore@Macro\@dc@Loop@CareOfSpace
+ \Restore@Macro\gmu@passbraced
\@dc@addargum
}%
}
@@ -537,6 +546,7 @@
{\BareSpace}
{\@dc@BareSpace@true}
%
+ %
\gmu@EatCases
{\IgnInfo{gmcommand}{while parsing arg specifiers}{#1}}%
\gmu@ESAC
@@ -638,7 +648,7 @@
\@dc@AliasPLower T
\long\def\ArgumentCatcher@Ť #1#2#3% as in |›…@T|
-{%
+{% one-token catcher that respects space.
\ArgumentCatcher@Loop
{StrX}{\any}{#1}{\any}{}{1}{#2}{% empty eacher
}{#3}%
@@ -694,7 +704,7 @@
% perform matching. \rrthis
%
\gmu@ifempty{#5}%
- {\gmu@if {strings} {\any #4}%
+ {\gmu@if {strings} {\none #4}%
{\@dc@Loop@addallfalse\@dc@Loop@drainalltrue}%
{\@dc@Loop@addalltrue\@dc@Loop@drainallfalse}%
}% of if |#5| empty
@@ -872,6 +882,27 @@
\@dc@AliasPLower Q
+\@ifXeTeX {%
+ \long\def\ArgumentCatcher@Ô
+ #1% list
+ #2% default (|\NoValue| by default, as in previous versions).
+ {%
+ \@dc@BareSpaceArg
+ \ArgumentCatcher@Loop
+ {str}%
+ \any
+ { #1}% note the space before |#1|—settheory sum of |#1| and drainers.
+ \any
+ { }% we ignore spaces—it's a legacy setting, maybe we'll optionise
+ % it in the future
+ \m@ne % we allow any number of tokens
+ {#2}% default, by default |\NoValue|, as defined in line \ref{Q-arg deft.}
+ {}% empty eacher
+ }%
+
+ \@dc@AliasPLower Ô
+
+}{}% of if \XeTeX
\def\ArgumentCatcher@D{% decimal argument (useful for dates e.g.)
\ArgumentCatcher@Q
@@ -890,7 +921,7 @@
{StrX}%
\any
{-+0123456789}%
- \none
+ \any
{}%
\m@ne
{#1}%
@@ -1067,7 +1098,7 @@
{\ArgumentCatcher@G{#2}{##1}}%
\Name\lpdef{ArgumentCatcher@P\strip@bslash{#1}}%
##1% default value
- {\ArgumentCatcher@G{#2}{##1}}%
+ {\ArgumentCatcher@PG{#2}{##1}}% »P« was missing. Fixed 2011/03/22, 16.14.
%
\gmu@if {cat}{a\@nx#1}%
{\@dc@LowerAliases #1}{}%
@@ -1139,13 +1170,11 @@
\@dc@AliasCatcher {PScope} \Scope
-\def\NoValue{-NoValue-}
-
-\long\def\IfNoValueTF#1{% % \chgs{2008/12/1 v0.98 the \pk{xparse} tests for
+\long\def\gmuIfNoValueTF#1{% % \chgs{2008/12/1 v0.98 the \pk{xparse} tests for
% the presence of value redefined and much simplified (43 \CS'es
- % less). Moreover, they are now fully expandable: \cmd\IfNoValueTF,
- % \cmd\IfNoValueT, \cmd\IfNoValueF, \cmd\IfValueTF, \cmd\IfValueT,
- % \cmd\IfValueF}
+ % less). Moreover, they are now fully expandable: \cmd\gmuIfNoValueTF,
+ % \cmd\gmuIfNoValueT, \cmd\gmuIfNoValueF, \cmd\gmuIfValueTF, \cmd\gmuIfValueT,
+ % \cmd\gmuIfValueF}
%
% \chgs{2010/05/27 v0.993 bug fix: order of \cmd\NoValue and
% \cs{@firstofmany} reversed after a catastrophal |{11}{11}| argument}
@@ -1153,17 +1182,17 @@
\else\afterfi\@secondoftwo
\fi}
-\long\def\IfNoValueT#1#2{\IfNoValueTF{#1}{#2}\@empty}
+\long\def\gmuIfNoValueT#1#2{\gmuIfNoValueTF{#1}{#2}\@empty}
-\long\def\IfNoValueF#1#2{\IfNoValueTF{#1}\@empty{#2}}
+\long\def\gmuIfNoValueF#1#2{\gmuIfNoValueTF{#1}\@empty{#2}}
-\long\def\IfValueTF#1#2#3{\IfNoValueTF{#1}{#3}{#2}}
+\long\def\gmuIfValueTF#1#2#3{\gmuIfNoValueTF{#1}{#3}{#2}}
-\long\def\PutIfValue#1{\IfValueT{#1}{#1}}
+\long\def\gmuPutIfValue#1{\gmuIfValueT{#1}{#1}}
-\let\IfValueT\IfNoValueF
+\let\gmuIfValueT\gmuIfNoValueF
-\let\IfValueF\IfNoValueT
+\let\gmuIfValueF\gmuIfNoValueT
\long\pdef\IfLong#1{%\
% \begin{enumargs}
@@ -1324,7 +1353,7 @@
\@dc@buckstopshere % it's the sentinel of parsing. Since the test
%
\@xa \Name \@xa \addtomacro \@xa \@dc@specsname
- \@xa {\@xa{\@dc@ParsedSpecs}}%
+ \@xa {\@xa{\the\@dc@ParsedSpecs}}%
%
\@xa\Name\@xa\addtomacro\@xa\@dc@specsname
\@xa{\@xa{\the \c@dc@argnum}}%
@@ -1360,7 +1389,7 @@
}
\def\@dc@DCprefixQlist{\global\protected\outer\long
- \relax % for the very tricky case when |\@dc@global| may be
+ \relax % for the somewhat perverse case when |\@dc@global| may be
!lL.qQiIwW\sphack\envhack}
\long\def\ShowCommand #1{%
@@ -1428,7 +1457,7 @@
{\unexpanded{#1}}%
{%
\@nx\@dc@addargum{{%
- \IfValueTF{#2}{%
+ \gmuIfValueTF{#2}{%
\gmu@if{@dc@xadefault@ii@}{}%
{\@xau{#2}}%
{\unexpanded{#2}}%
@@ -1441,6 +1470,16 @@
\@dc@global@ % set properly before |\@dc@ParseNextSpecifier #3⁄<buck>|.
\if P\@dc@long@letter\relax\long\fi
\gmu@tempa
+ %
+ \@dc@addtospecs {#1}%
+ %
+ \gmuIfValueTF{#2}{%
+ \gmu@if{@dc@xadefault@ii@}{}%
+ {\@xa\@dc@addtospecs\@xa{#2}}%
+ {\@dc@addtospecs{#2}}%
+ }
+ {\@xa\@dc@addtospecs\@xa{\@dc@K@defaultrepl}}%
+ %
% Now we clean up and continue construction of arguments parser. \nostanza
\@dc@ParseNextSpecifier
}% of |\@dc@define@K|
@@ -1454,8 +1493,8 @@
%
#2 >Pm % list of tokens to match for/against iteration
%
- >i T{\drain \drop \Drain \Drop}
- #3 T{\any \none }{\none} % the “sign” of matching for draining
+ >i T{\drain \drop \Drain \Drop \lost \Lost}
+ #3 T{\any \none }{\any} % the “sign” of matching for draining
%
#4 b{} % list of drainers, empty by default
%
@@ -1510,7 +1549,7 @@
\DeclareCommand\grab@LostWax {
>iT{\lost \Lost}
- #1 b{\lostwax@NoValue}
+ #1 b{\lostwax@NoVal}
>iT {\count \ubound}
#2 D{1}
>iT{\endlost \EndLost}
@@ -1519,7 +1558,7 @@
%
\def\@dc@LostWaxA{>iw}%
%
- \gmu@ifdetokens {\lostwax@NoValue}{#1}
+ \gmu@ifdetokens {\lostwax@NoVal}{#1}
{%
% if no particular value of the “lost wax” is provided, we assume
% the same as the “until” delimiter(s).
@@ -1712,7 +1751,7 @@
}{%
\def\gmu@DeclareEnvironment@resa{\envhack}% we add the information we define an
% environment.
- \IfValueT{#2}%
+ \gmuIfValueT{#2}%
{\addtomacro\gmu@DeclareEnvironment@resa{#2}}% we pass all the ‘prefixes’ to
% \incs{Decl\+are\+Comm\+and}
% \stanza
@@ -1814,7 +1853,7 @@
% to the redefinition of
% \cs{verb} in \pk{xlxtra} 2008/07/29}
\@ifXeTeX{%
- \IfValueT{#1}{\PassOptionsToPackage{#1}{fontspec}}%
+ \gmuIfValueT{#1}{\PassOptionsToPackage{#1}{fontspec}}%
\@ifpackageloaded{gmverb}%
{%
\Store@Macro\verb
@@ -1860,6 +1899,10 @@
{\spaceskip=\glueexpr\dimexpr#2*#1\relax plus\dimexpr #3*#1\relax
minus\dimexpr#4*#1\relax\relax}
+\pdef\unsetspaceskip{%
+ \spaceskip=\z@skip
+}
+
\def\makestarlow{%
\begingroup\lccode`\~=`\*\lowercase{%% \Define**
\endgroup\def~{\gmu@lowstar}}% 2009/10/19 |\let| changed to
@@ -1887,9 +1930,9 @@
#2 B{2\baselineskip}% (2) optional (formerly mandatory) long version of
% required room on a page
>is
- #3 B{} % (3) what if the room is enough
+ #3 >PB{} % (3) what if the room is enough
>is
- #4 B{\newpage} % (4) what if there's to little room on a page
+ #4 >PB{\newpage} % (4) what if there's to little room on a page
}{%
% \chgs{2009/03/18 v0.98 made \eTeX-ish}
% \chgs{2009/05/25 v0.98 made ifthenelse-like with ‘then’ and ‘else’
@@ -1903,7 +1946,7 @@
\gmu@pageremain
<%
\dimexpr
- (\IfValueTF{#1}{#1\baselineskip}{#2})*1%
+ (\gmuIfValueTF{#1}{#1\baselineskip}{#2})*1%
\endexpr
%
% \CH{2010/06/28 v0.993 I added |(›…)*1| to assure that |\relax|
@@ -1913,14 +1956,25 @@
\fi
*%
\ifdim \gmu@pageremain >-1sp
- 1\else 0%
+ 1% if the room left on current page is nonnegative,
+ % then we indeed are on current page so “enough” and
+ % “not enough” does make sense: Enough is enough.
+ \else 0% otherwise we are on next page (or further) and assume
+ % there is enough room for our purpose.
\fi
- >\z@
- }% of condition
- {\typeout{@@@@@ not enough page \on@line}%
- #4%
- }%
- {#3}%
+ *%
+ \ifdim \pagegoal <\maxdimen
+ 1 % if there are some boxes on current page, so checking room
+ % does make sense.
+ \else 0% otherwise (no boxes on current page) assume there's
+ % enough room
+ \fi
+ >\z@
+ }% of condition
+ {\typeout{@@@@@ not enough page \on@line}%
+ #4%
+ }%
+ {#3}%
}
\long\def\gmu@LC@LetInners
@@ -2032,7 +2086,7 @@
#2% a decimal number
{\edef\gmu@SC@grouplevel{%
\the\numexpr
- \IfValueTF{#1}%
+ \gmuIfValueTF{#1}%
{\currentgrouplevel#1#2+1}{#2}%
}% of the grouplevel-carrying macro
}
@@ -2219,7 +2273,7 @@
#2 b % enlargement (dim(expr)) for baselineskip (if absent, |#1| is used)
}{\edef\gmu@tempa{%
\@nx\fontsize{\the\dimexpr\f@size pt+#1}%
- {\the\dimexpr 1\baselineskip+ \IfValueTF{#2}{#2}{#1}}%
+ {\the\dimexpr 1\baselineskip+ \gmuIfValueTF{#2}{#2}{#1}}%
}\gmu@tempa\selectfont
}
@@ -2229,7 +2283,7 @@
\gobblespace
}{\edef\gmu@tempa{%
\@nx\fontsize{\the\dimexpr #1\dimexpr\f@size pt\relax}%
- {\the\dimexpr \IfValueTF{#2}{#2}{#1}\baselineskip}%
+ {\the\dimexpr \gmuIfValueTF{#2}{#2}{#1}\baselineskip}%
}\gmu@tempa\selectfont
}
@@ -2239,12 +2293,16 @@
\DeclareCommand\bihyphen{
O{*} % token that'll make the discretionary hyphen |\-| allow other break-points
}{%
- \DeclareCommand\gmu@discretionaryhyphen{T{#1}ca}{%
- \IfValueT{##2}{%
+ \DeclareCommand\gmu@discretionaryhyphen{%
+ T{#1}%
+ G{&&}%
+ a
+ }{%
+ \gmuIfValueT{##2}{%
\gmu@ifempty{##2}{}{%
\def\gmu@bihyphen@char{##2}}%
}%
- \IfValueT{##3}{%
+ \gmuIfValueT{##3}{%
\gmu@ifempty{##3}{}{%
\def\gmu@bihyphen@corr{##3}}%
}%
@@ -2253,9 +2311,9 @@
% hyphenation of the word's before- and
% after-parts or forbid it (if absent, then we take
% |\discretionary|).
- \IfValueTF{##1}\discre\discretionary
+ \gmuIfValueTF{##1}\discre\discretionary
{% before break
- \IfValueTF{##2}
+ \gmuIfValueTF{##2}
{%
\gmu@ifempty{##2}{\gmu@bihyphen@char}{##2}%
}%
@@ -2265,7 +2323,7 @@
\fi}%
}% end of before break
{%after break
- \IfValueT{##3}{%
+ \gmuIfValueT{##3}{%
\gmu@ifempty{##3}{\gmu@bihyphen@corr}{##3}%
}%
}%
@@ -2293,9 +2351,9 @@
}{% not in \XeTeX\ we use legacy |D| arg.\ specifiers:
\DeclareCommand\gmshowlists {
>iT{\depth}
- Ď{1}%
+ D{1}%
>iT{\breadth}
- Ď{10000000}
+ D{10000000}
}%
}
{\tracingonline=\@ne
@@ -2333,6 +2391,41 @@
\DeclareCommand \IgnorePars {m Q{\par}} {#1}
+\DeclareCommand\putpenalty {=}
+{%
+ \gmu@iflastglue
+ {\@tempskipa=\lastskip
+ \mode@skip -\@tempskipa
+ \penalty \@tempcnta
+ \mode@skip \@tempskipa
+ }%
+ {\gmu@iflastkern
+ {\@temdima=\lastkern
+ \kern-\@temdima
+ \penalty \@tempcnta
+ \kern \@temdima
+ }
+ {%
+ \penalty\@tempcnta
+ }%
+ }%
+}
+
+\newskip \gmu@TrashSkip
+
+\pdef \mode@skip {%
+ \ifvmode \vskip
+ \else
+ \ifhmode \hskip
+ \else
+ \ifmmode \mskip
+ \else
+ \gmu@TrashSkip
+ \fi
+ \fi
+ \fi
+}
+
\endinput
%%