summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gmutils/gmmeta.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-10-24 23:46:12 +0000
committerKarl Berry <karl@freefriends.org>2010-10-24 23:46:12 +0000
commite5d25989ee337ac9399ae9e50bed87559488814f (patch)
treee08fa9fe408fbbd07d82226b3fd8a059c8d39d7b /Master/texmf-dist/tex/latex/gmutils/gmmeta.sty
parent5d35798dc0ca224df75f912f020c70024e1a1169 (diff)
gmutils (24oct10)
git-svn-id: svn://tug.org/texlive/trunk@20183 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gmutils/gmmeta.sty')
-rw-r--r--Master/texmf-dist/tex/latex/gmutils/gmmeta.sty295
1 files changed, 295 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/gmutils/gmmeta.sty b/Master/texmf-dist/tex/latex/gmutils/gmmeta.sty
new file mode 100644
index 00000000000..b6bc0b2207b
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/gmutils/gmmeta.sty
@@ -0,0 +1,295 @@
+%%
+%% \iffalse ^^A we skip the debug setting
+\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{}
+%% \fi
+%% ^^A $Id: TheUltimateMaster.gmd,v 0.250 2010/10/24 14:42:35 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) o2 (dot) pl
+%%
+%% 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 the documentation please refer to the file(s)
+%% gmutils.{gmd,pdf}.
+%%
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{gmmeta}
+ [2010/10/24 v0.993 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|
+
+\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}%
+ \IfValueT{#1}%
+ {\metachar[\scanverb{*}\metachar]\def\next{1}}%
+ \IfValueT{#2}{\@oarg{#2}\def\next{1}}%
+ \IfValueT{#3}{\@parg{#3}\def\next{1}}%
+ \IfValueT{#4}{\marg{#4}\def\next{1}}%
+ \IfValueT{#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.
+
+
+%%% (For my GNU Emacs:)
+%%% Local Variables:
+%%% mode: doctex
+%%% coding: utf-8
+%%% End:
+\endinput
+%%
+%% End of file `gmmeta.sty'.