summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gmutils/gmmeta.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/gmutils/gmmeta.sty')
-rw-r--r--macros/latex/contrib/gmutils/gmmeta.sty292
1 files changed, 292 insertions, 0 deletions
diff --git a/macros/latex/contrib/gmutils/gmmeta.sty b/macros/latex/contrib/gmutils/gmmeta.sty
new file mode 100644
index 0000000000..fa8b106d61
--- /dev/null
+++ b/macros/latex/contrib/gmutils/gmmeta.sty
@@ -0,0 +1,292 @@
+%%
+%% \iffalse ^^A we skip the debug setting
+\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{}
+%% \fi
+%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $
+%% This is file “gmmeta.sty” generated with the DocStrip utility.
+%%
+%%
+%% The original source files were:
+%%
+%% gmutils/gmutils.gmd (with options: `meta')
+%%
+%%
+%% Copyright ©
+%% by Grzegorz ‘Natror’ Murzynowski
+%% 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
+%% for the details of that license.
+%%
+%% LPPL status: "author-maintained".
+%%
+%%
+%%
+%% For documentation please refer to the file(s)
+%% gmutils.{gmd,pdf}.
+%%
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{gmmeta}
+ [2011/10/12 v0.996 meta-symbols for typesetting macros and arguments (GM)]
+
+
+%%
+%%
+%% ^^A\typeout{\unexpanded{#4}}%%
+\RequirePackage{gmcommand}
+\pdef\meta#1{%
+ % \begin{quotation}
+ % Since the old implementation of |\meta| could be used in math we better ensure
+ % that this is possible with the new one as well. So we use |\ensuremath| around
+ % |\langle| and |\rangle|. However this is not enough: if |\meta@font@select| below
+ % expands to |\itshape| it will fail if used in math mode. For this reason we hide
+ % the whole thing inside an |\nfss@text| box in that case.
+ % \end{quotation}
+ {\meta@fontsetting\ensuremath\langle}%
+ \ifmmode\@xa\nfss@text\fi
+ {% this has to be a~begin-group because \incmd{\nfss@text} becomes
+ % \incmd\hbox\ in math mode.
+ \gmu@activespaceblank
+ \meta@font@select
+ % Need to keep track of what we changed just in case the user changes font inside
+ % the argument so we store the font explicitly.
+ #1\/%
+ }%
+ {\meta@fontsetting\ensuremath\rangle}%
+}% of |\meta|.
+
+\pdef\gmu@activespaceblank{%
+ \@xa\def\gmu@activespace{\space\ignorespaces}% note the
+ % subtle perversity of this definition: if we meet more than one
+ % subsequent active spaces, then the first of them will
+ % typeset \incmd\space and its \incmd\ignorespaces\ will
+ % gobble \incmd\space\ of the second and will stop at
+ % \incs{ignorespaces} and this \incs{ignorespaces} will gobble
+ % the next \incs{space} and so on.
+}
+
+\def\meta@fontsetting{\color{red!85!black}}
+
+\def\meta@font@select{\meta@fontsetting\it}
+
+\def\<#1>{\meta{#1}}
+
+\pdef\metachar#1{\begingroup\metacharfont #1\endgroup}
+\def\metacharfont{\meta@fontsetting\rm}
+
+\pdef\vs{\discre{\visiblespace}{}{\visiblespace}}
+
+\def\printspaces#1{{\let~=\vs \let\ =\vs \gmu@pswords#1 \@nil}}
+\def\gmu@pswords#1 #2\@nil{%
+ \ifx\relax#1\relax\else#1\fi
+ \ifx\relax#2\relax\else\vs\penalty\hyphenpenalty\gmu@pswords#2\@nil\fi}% note
+
+\pdef\sfname#1{\textsf{\printspaces{#1}}}
+
+\def\gmu@discretionaryslash{\discre{/}{\hbox{}}{/}}% the second
+
+\pdef\file#1{\gmu@printslashes#1/\gmu@printslashes}
+
+\def\gmu@printslashes#1/#2\gmu@printslashes{%
+ \sfname{#1}%
+ \ifx\gmu@printslashes#2\gmu@printslashes
+ \else
+ \textsf{\gmu@discretionaryslash}%
+ \afterfi{\gmu@printslashes#2\gmu@printslashes}\fi}
+
+
+\pdef\pk#1{\textsf{#1}}
+
+\DeclareCommand\cs{O{\type@bslash\penalty\@M\hskip\z@skip}}{%\
+ % \begin{enumargs}
+ % \dc O{\bslash} the control sequence's prefix, by default it's
+ % \inverb|\| allowing hyphenation of subsequent word,
+ % \dc m the control sequence or anything to be typeset in
+ % typewriter font.
+ % \end{enumargs}
+ % \chgs{2008/12/12 v0.98 added \cs{verbatim@specials}}
+ % \chgs{2008/12/12 v0.98 made \cmd\- switch to \cmd\normalfont\
+ % because \IMHO\ this underlines the fact that a~\CS\ belongs to the
+ % narrative. \cmd\hyphenchar\ set to 45 as in usual texts}
+ \begingroup
+ \ifdefined\verbatim@specials\verbatim@specials\fi
+ \edef\-{\discretionary{%
+ \ifdefined\gmv@hyphen\gmv@hyphen
+ \else\unexpanded{{\normalfont-}}%
+ \fi}{}{}}%
+ \def\{{\type@lbrace\yeshy}\def\}{\char`\}}%
+ \narrativett
+ \edef\narrativett@storedhyphenchar{\the\hyphenchar\font}%
+ \hyphenchar\font=%
+ \ifdefined\gmv@hyphenchar\gmv@hyphenchar
+ \else "A6
+ \fi
+ \cs@inner{#1}%
+}% of |\cs|
+
+\let\type@bslash\bslash
+
+\pdef\cs@inner#1#2{%
+ #1#2%
+ \endgroup}
+
+\def\narrativett{\ttfamily}% such name because I~introduce it to
+
+\long\pdef\env{\cs[]}
+
+\foone{\@makeother\^}
+ {\pdef\hathat{\cs[^^]}}
+
+\AtBeginDocument{%
+ \@ifpackageloaded{gmdoc}{\def\hash{\cs[\#]}}{}}
+
+\def\possfil{\hfil\penalty1000\hfilneg}
+
+\def\possvfil{\vfil
+ \penalty\numexpr
+ \gmu@minnum{\clubpenalty+\widowpenalty}{9999}%
+ \relax % eaten by |\gmu@maxnum|
+ \relax % eaten by |\numexpr|
+ \vfilneg}
+
+
+\long\def\cmd#1{\@xa\cs\@xa{\@xa\cmd@to@cs\string#1}\spifletter}% it has to be
+
+\def\cmd@to@cs#1#2{\char\number`#2\relax}
+
+\pdef\marg#1{{\narrativett\type@lbrace}\arg@wrap{#1}{\narrativett\char`\}}}
+
+\pdef\oarg{\@ifnextchar[\@oargsq\@oarg}
+\pdef\@oarg#1{{\narrativett[}\arg@wrap{#1}{\narrativett]}}
+\pdef\@oargsq[#1]{\@oarg{#1}}
+
+\pdef\parg{\@ifnextchar(\@pargp\@parg}
+\def\@parg#1{{\narrativett(}\arg@wrap{#1}{\narrativett)}}
+\def\@pargp(#1){\@parg{#1}}
+
+\pdef\aarg{\@ifnextchar<\@aarga\@aarg}
+\def\@aarg#1{{\narrativett<}\arg@wrap{#1}{\narrativett>}}
+\def\@aarga<#1>{\@aarg{#1}}
+
+\def\@verbaarga#1#2>{\@aarg{#2}\arg@dc}
+
+\foone{\catcode`>\active}{%
+ \def\@verbaargact#1#2>{\@aarg{#2}\arg@dc}%
+}
+
+\foone{\@makeother\{\@makeother\}%
+ \catcode`[=\@ne\catcode`]=\tw@}
+[% ^^A{
+ \def\@verbmargm#1#2}[% for an argument in curly braces in a verbatim, where
+ % the braces are not groupers and not necessary ‘other’. We'll know
+ % by \incmd{\@ifnextif} that the future token is an opening
+ % brace. Note this macro has 2nd parameter delimited with ‘other’
+ % closing brace (so may not act correctly when braces are nested
+ % (then hide them with special verbatim groupers)).
+ \marg[#2]%
+ \arg@dc
+ ]%
+]% of |\foone|
+
+\def\arg@wrap{\meta}
+
+\DeclareCommand\arg@dc!{%
+ % \chgs{200/03/04 v0.991 added rcognising of verbatim braces and
+ % angles}
+ s % (1)
+ o % (2)
+ c % (3)
+ b % (4)
+ a % (5)
+ T{\arg} % (6) just gobbled (for backwards compatibility)
+}{% This command iterates while it
+ % has arguments and typesets them in brackets, parentheses or curly
+ % braces. Note it gobbles subsequent |\arg|s and just iterates.
+ \def\next{0}%
+ \gmuIfValueT{#1}%
+ {\metachar[\scanverb{*}\metachar]\def\next{1}}%
+ \gmuIfValueT{#2}{\@oarg{#2}\def\next{1}}%
+ \gmuIfValueT{#3}{\@parg{#3}\def\next{1}}%
+ \gmuIfValueT{#4}{\marg{#4}\def\next{1}}%
+ \gmuIfValueT{#5}{\aarg{#5}\def\next{1}}%
+ \@ifnextchar\egroup{\endgroup}{%
+ \if1\next\@xa\arg@dc
+ \else % it's crucial that we look for verbatim braces \emph{after}
+ % we checked there were no \inhash4, otherwise there would
+ % be an error.
+ \def\next{%
+ \@ifnextif\xiilbrace{\@verbmargm}%
+ {% not active or other lbrace
+ \@ifnextif<{% then we look for angles
+ \ifnum\catcode`>=\active
+ \@xa\@verbaargact
+ \else\@xa\@verbaarga
+ \fi}%
+ {% and if not angles neither verbatim braces, then
+ \endgroup % if we have no more arguments to typeset, we
+ % close the group opened in lines \ref{queer.group} and \ref{queer.group2}.
+ \spifletter
+ }%
+ }%
+ }%
+ \@xa \next
+ \fi
+ }% of not egroup
+}% of |\arg@dc|
+
+\foone{\obeylines\@makeother\^^C}{%
+ \AtBeginDocument{%
+ \let\math@arg\arg %
+ \pdef\arg{% This is |\arg| for meta-arguments.
+ \ifmmode\math@arg %
+ % \chgs{200/03/04 v0.991 added rcognising of verbatim braces and angles}
+ \else\afterfi{%
+ \begingroup %
+ % \label{queer.group}
+ \ifdefined\@ifQueerEOL\@ifQueerEOL{%
+ \def^^M{\unskip\space}% in the ‘queer’ \ac{EOL}s scope we
+ % keep line end active in case we have
+ % \incmd\arg\nlpercent\arg{arg.} ending a~line: the next
+ % char peeper touches line end or, if the line end was $_5$,
+ % gobbles the space it turns into so the comment layer would
+ % ‘leak’ to the code layer.
+ }{}\fi %
+ \arg@dc}%
+ \fi}% of |\arg|,
+ }% of |\AtBeginDocument|,
+ %
+ % \stanza
+ % And this is arg-typesetting command for verbatim arguments.
+ \pdef\argv{%
+ \begingroup %
+ % \label{queer.group2}
+ \@makeother\^^C%
+ \pdef\arg@wrap##1{%
+ \narrativett{##1}%
+ }%
+ \ifdefined\@ifQueerEOL\@ifQueerEOL{%
+ \def^^M{\unskip\space}% in the ‘queer’ \ac{EOL}s scope we
+ % keep line end active… as above
+ }{}%
+ \fi % of |\ifdefined|
+ \arg@dc}%
+}% of |\foone|.
+
+
+\DeclareCommand\cat{Q{'"0123456789ABCDEF}{0}}{%
+ ${}_{\the\numexpr#1}\m@th$\spifletter
+}
+
+\pdef\CS{% \changes{v0.99n}{2008/08/30}{added}
+ \acro{CS}%
+ \@ifnextcat a{ }{}}% we put a~space if the next token is
+
+\pdef\CSs{\CS{}es\@ifnextcat a{ }{}}% for pluralis.
+\pdef\CSes{\CS{}es\@ifnextcat a{ }{}}% for pluralis.
+
+
+\endinput
+%%
+%% End of file `gmmeta.sty'.