diff options
author | Karl Berry <karl@freefriends.org> | 2011-10-14 23:19:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-10-14 23:19:55 +0000 |
commit | 895adaa5b890a2593a7da3e90d8f1d9a96c1220d (patch) | |
tree | fad21a6446c5c3a3497922b8d84c31bff6ee3b95 /Master/texmf-dist/tex/latex/gmverb | |
parent | 156a2b3e555456a90baac12411ebd5fcc7b9ef02 (diff) |
gmverb (14oct11)
git-svn-id: svn://tug.org/texlive/trunk@24288 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gmverb')
-rw-r--r-- | Master/texmf-dist/tex/latex/gmverb/gmverb.sty | 286 |
1 files changed, 164 insertions, 122 deletions
diff --git a/Master/texmf-dist/tex/latex/gmverb/gmverb.sty b/Master/texmf-dist/tex/latex/gmverb/gmverb.sty index fbeb084ac26..16a64651480 100644 --- a/Master/texmf-dist/tex/latex/gmverb/gmverb.sty +++ b/Master/texmf-dist/tex/latex/gmverb/gmverb.sty @@ -4,7 +4,7 @@ %% \iffalse ^^A we skip the debug setting \IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} %% \fi -%% ^^A $Id: TheUltimateMaster.gmd,v 0.298 2011/02/02 18:35:58 natror Exp natror $ +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ % \endskiplines % %% \BundleInfoFromName{gmverb} @@ -17,7 +17,7 @@ %% \begin{copyrnote} %% %% -%% Copyright ©\, 2005, 2006, 2007, 2008, 2009, 2010 +%% Copyright ©\, 2005, 2006, 2007, 2008, 2009, 2010, 2011 %% by Grzegorz ‘Natror’ Murzynowski %% natror (at) gmail (dot) com %% @@ -32,8 +32,8 @@ %% %% %% -%% For the documentation please refer to the file(s) -%% \file{gmverb.{gmd,pdf}}. +%% For documentation please refer to the file(s) +%% \file{gmverb.{sty,pdf}}. %% %% \end{copyrnote} %% @@ -48,7 +48,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{gmverb} - [2010/09/07 v0.95 After shortvrb (FM) but my way (GM)] + [2011/10/14 v0.98 After shortvrb (FM) but my way (GM)] %<*master> @@ -93,20 +93,47 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \usepackage{eufrak}% for |\continuum| in the commentary. \twocoltoc + +% % % +\ifdefined\XeTeXversion % was a switch |\ifgmuXeTeX|, but that caused + % an error when not defined (e.g., package \pk{gmmacros} loaded with a standard class). + +\verbLongDashes +\GMverbatimspecials + +\let\zwr\emph % for foreign phrases (in the narration layer of course) + +\fi % of if \XeTeX + + \begin{document} \addtocontents{toc}{\unexpanded{\let\thfileinfo\relax}} +\DefaultIndexExclusions + \def\gmdExt{% sty% } +\addtomacro\IndexParms {\noverbatimspecials} + \DocInput{\jobname.\gmdExt} +% ^^A \unless\ifcsname textfont@name\endcsname +% ^^A \Name\def{textfont@name}{\small} +% ^^A \fi +% ^^A \unless\ifcsname scriptfont@name\endcsname +% ^^A \Name\def{scriptfont@name}{\scriptsize} +% ^^A \fi + \PrintChanges +\let\hyperindexformat\firstofone +\PrintIndex + \thispagestyle{empty} \typeout{% Produce change log with^^J% @@ -124,6 +151,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % \enoughpage 18 % \tableofcontents % +% % \ChangesStart{}{1000/00/00} % % \chschange{v0.70}{06/8/15}{523} @@ -155,9 +183,10 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % \chschange{v0.94}{2010/07/07}{979} % [wrapping the \ac{UTF-8} dashes' setting in a \protect\XeTeX's conditional] % \toCTAN{2010/07/07 v0.94} -% % \chschange{}{2010/10/24}{1040} -% +% \toCTAN{2011/02/02 v0.95} +% \chschange{}{2011/10/14}{997} +% \toCTAN{2011/10/14 v0.98} % % \division{Intro, usage} % @@ -176,7 +205,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % The \pk{gmverb} package redefines the |\verb| command and the % \env{verbatim} environment in such a~way that | |, |{| and |\| are % breakable, the first with no `hyphen' and the other two with the -% comment char as a~hyphen. I.e. |{|\<subsequent text>|}| breaks into +% comment char as a~hyphen. I.e., |{|\<subsequent text>|}| breaks into % |{%|\par \<subsequent text>|}| ^^A] bal. braces for Emacs % and \<text>|\mymacro| breaks into \<text>|%|\par % |\mymacro|. @@ -222,9 +251,13 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % $2|0$ and |+| |\active|ated this way is in the math mode typeset properly % etc. % -% However, if you don't like such a~conditional behaviour, you may use -% \TextUsage\OldMakeShortVerb\ instead, what I~do when I~like to -% display short verbatims in displaymath. +% However, if you don't like such a~conditional behaviour, you may +% specify some |$$$$|'s (any nonempty seQuence) mixed with star(s) if +% you wish as an optional argument to keep the short-verbatim char +% behave as short-verbatim also in math mode. +% +% For compatibility with \pk{gmdoc} and for convenience there is a +% shorthand for that provided, \TextUsage\OldMakeShortVerb.% % % % There's one more declaration provided by \pk{gmverb}: @@ -266,7 +299,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % curly braces because those are recatcoded to % ‘other’. But if you make some other pair of chars category 1 and 2 % that are not on the \cmd\dospecials\ list, then you can wrap the -% arguments in those chars, but what for?}, +% arguments in those chars. But what for?}, % \dc * m a~char for group starter (for catcode 1), has to be % unbraced, % \dc * m a~char for group ender (for catcode 2), has to be @@ -290,9 +323,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % slash is Unicode Fractional Slash, spaces are ignored) you % can write \[\verb:|\macro⁄⁄arg⁄«arg. ⁄¿n+1⁄¿⁄»\⁄››[No⁄››]Value⁄››(T⁄⁄|F⁄››)|:\] to get % \[|\macro⁄arg«arg. ¿n+1¿»\›[No›]Value›(T⁄|F›)|\]%^^A| -% -% ^^A % To get a~‘verbatim special’ verbatim, precede it with the ‘verbatim -% ^^A % escape’: |⁄⁄⁄⁄ ⁄⁄⁄« ⁄⁄⁄» ⁄⁄⁄¿ ⁄⁄⁄›| in the example above. +%% % % Note also that \verb+⁄⁄|+ is a~control sequence so it doesn't % delimit the short verbatim \verb+|+'s argument. @@ -432,7 +463,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % \DoIndex{\verb \verb*} % \subdivision{Preliminaries} % -\RequirePackage{gmcommand}[2010/06/20] +\RequirePackage{gmcommand}[2011/10/12] % For |\firstofone|, |\afterfi|, |\gmobeyspaces|, |\@ifnextcat|, |\foone| and % |\noexpand|'s and |\expandafter|'s shorthands |\@nx| and |\@xa| % resp. and |\DeclareCommand|.\rrthis @@ -507,8 +538,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \pdef\nobreaklbrace{\def\breaklbrace{\type@lbrace\yeshy}} % \changes{v0.92}{2008/12/11}{renamed from \cmd\fixlbrace} -\foone{\catcode`\!=0 \catcode`\\=\active}%%\CodeEscapeChar\!^^A - % ^^A~One r-brace is turned off for Emacs by |\{|. +\foone{\catcode`\!=0 \catcode`\\=\active}%%\CodeEscapeChar\!^^A% {%^^A{ !def!dobreakbslash{!catcode`!\=!active !def\{!breakbslash}}% } @@ -516,9 +546,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % The macros defined below, |\visiblebreakspaces| and |\xiiclub| % we'll use in the almost Knuthian macro making verbatim. This `almost' -% makes a~difference. -% ^^A \foone{\catcode`\ =12 }% note this space is ${}_{10}$ and is gobbled -% ^^A % by parsing of the number. +% makes a~difference.% \def\breakablevisspace{\discretionary{\visiblespace}{}{\visiblespace}} %\nostanza The \cs{visiblespace} macro is |\let| in \pk{gmutils} @@ -589,52 +617,103 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % The below is copied verbatim ;-) from % \file{doc.pdf} and then is added my slight changes. -\def\MakeShortVerb{% - \gmu@ifstar - {\def\@shortvrbdef{\verb*}\@MakeShortVerb}% - {\def\@shortvrbdef{\verb}\@MakeShortVerb}} +\DeclareCommand \MakeShortVerb{ + #1 Q {*$} %^^A $ + #2 m % the char to be made shortverb. Has to be provided as |\⁄<char>| (backslashed). +}{% + \gmu@ifstrany {*}{#1} + {\def\@shortvrbdef{\verb*}}% + {\def\@shortvrbdef{\verb}} + % + \gmu@ifstrany {$}{#1}% ^^A$ + % + % Depending on whether |$| ^^A $ + % was specified as optional argument to + % |\MakeShortVerb|, we define the \CS\ |\gmV@mm\⁄<the char>| as + % either sth.\ special or sth.\ usual in the math mode: + % + {\gmV@MakeShortVerbAlsoInMath #2 }% extracted to a macro because we reassign + % it while typesetting \LaTeXe \ Sources. + {\gmV@MakeShortVerbNotInMath #2}% + % + \@MakeShortVerb #2% +}% of |\MakeShortVerb|. + +\pdef\gmV@MakeShortVerbAlsoInMath #1{% ^^A ( + % If some dollars were specified (paid ;-) ) in |#1|, then we direct the + % shortverb char to behave in the math mode the same as in normal + % text. + \Name\glet {gmV@mm\string#1}\@firstofone +}% + +\pdef\gmV@MakeShortVerbNotInMath #1{% ^^A ( + % If no dollar was paid ;-) in |#1|, we get vicious and define + % shortverb to act in math mode as normal (other) char. + \edef\gmV@tempA {\strip@bslash {#1}}% + % + \@XA {% + \Name\gdef {gmV@mm\string#1}}% + \@xa{\@xa % these two expandafters serve to get “other” version of + % (unbackslashed) |#1|. + \ifmmode \gmV@tempA + % Two subsequent expandafters become part of the definition + % and serve to gobble or execute the short-verbatim macro. + \@xa \@gobble + \else + \@xa \@firstofone + \fi + }% +}% of if to be normal in math mode +% We store the original catcode of a shortverb char in a \CS +% |\gmV@cc\⁄<the char>|. Moreover, if the char is originally active +% (of catcode 13), then we create another \CS to store its original +% meaning, |\gmV@ac\⁄<the char>|. +% % \Define\@MakeShortVerb \def\@MakeShortVerb#1{% - \@xa\ifx\csname cc\string#1\endcsname\relax - \@shortvrbinfo{Made }{#1}\@shortvrbdef - \add@special{#1}% - \AddtoPrivateOthers#1% a~macro to be \emph{really} defined in - % \pk{gmdoc}. - \@xa - \xdef\csname cc\string#1\endcsname{\the\catcode`#1}% - \begingroup - \catcode`\~\active \lccode`\~=`#1% - \lowercase{% - \global\@xa\let - \csname ac\string#1\endcsname~% - \@xa\gdef\@xa~\@xa{% - \@xa\ifmmode\@xa\string\@xa~% - \@xa\else\@xa\afterfi{\@shortvrbdef~}\fi}}% This - % terrible number of |\expandafter|s is to make the shortverb char - % just other in the math mode (my addition). - \endgroup - \global\catcode`#1\active - \else - \@shortvrbinfo\@empty{#1 already}{\@empty\verb(*)}% - \fi} + \@xa\ifx\csname gmV@cc\string#1\endcsname\relax + \@shortvrbinfo{Made }{#1}\@shortvrbdef + \add@special{#1}% + \AddtoPrivateOthers#1% a~macro to be \emph{really} defined in + % \pk{gmdoc}. + \@xa + \xdef\csname gmV@cc\string#1\endcsname{\the\catcode`#1}% + \begingroup + \catcode`\~\active \lccode`\~=`#1% + \lowercase{% + \Name\glet {ac\string#1}~% + \@xa\gdef\@xa~\@xa{% + \csname \strip@bslash{\gmV@mm}\string#1\endcsname + {\@shortvrbdef~}% + }% of active |#1| def + }% of lowercase + \endgroup + \global\catcode`#1\active + \else + \@shortvrbinfo\@empty{#1 already}{\@empty\verb(*)}% + \fi +}% of |\@MakeShortVerb|. % \Define\DeleteShortVerb \def\DeleteShortVerb#1{% - \@xa\ifx\csname cc\string#1\endcsname\relax - \@shortvrbinfo\@empty{#1 not}{\@empty\verb(*)}% + \@xa\ifx\csname gmV@cc\string#1\endcsname\relax + \@shortvrbinfo\@empty{#1 not}{\@empty\verb(*)}% \else - \@shortvrbinfo{Deleted }{#1 as}{\@empty\verb(*)}% - \rem@special{#1}% - \global\catcode`#1\csname cc\string#1\endcsname - \global \@xa\let \csname cc\string#1\endcsname \relax - \ifnum\catcode`#1=\active - \begingroup - \catcode`\~\active \lccode`\~`#1% - \lowercase{% - \global\@xa\let\@xa~% - \csname ac\string#1\endcsname}% - \endgroup \fi \fi} + \@shortvrbinfo{Deleted }{#1 as}{\@empty\verb(*)}% + \rem@special{#1}% + \global\catcode`#1\csname gmV@cc\string#1\endcsname + \global \@xa\let \csname gmV@cc\string#1\endcsname \relax + \ifnum\catcode`#1=\active + \begingroup + \catcode`\~\active \lccode`\~`#1% + \lowercase{% + \global\@xa\let\@xa~% + \csname gmV@ac\string#1\endcsname}% + \endgroup + \fi + \fi +} % My little addition % \DefIndex\gmv@packname @@ -667,7 +746,8 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % \def\rem@special#1{% \def\do##1{% - \ifnum`#1=`##1 \else \@nx\do\@nx##1\fi}% + \ifnum`#1=`##1 \else \@nx\do\@nx##1\fi + }% \xdef\dospecials{\dospecials}% \begingroup \def\@makeother##1{% @@ -720,7 +800,8 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \vskip\@tempskipa \fi \addvspace\@topsepadd - \@endparenv} + \@endparenv +} % \Define\endverbatim* \n@melet{endverbatim*}{endverbatim} @@ -733,12 +814,8 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \catcode`\\=\active%\CodeEscapeChar\! !gdef!@xverbatim[% [!endlinechar!m@ne !everyeof[!@nx]% - !edef!verbatim@currenvir[% - % ^^A !@xa!@xa!@xa!unexpanded - % ^^A !@xa!@xa!@xa[% - % ^^A - !@xa!scantokens!@xa[!@currenvir]% - % ^^A]% + !edef!verbatim@currenvir[%% + !@xa!scantokens!@xa[!@currenvir]%% ]% of |\verbatim@currenvir|. This macro is defined as the % meaning of \incs{@currenvir} rescanned. It's done specially % for the active star in my verbatims. \incs{@currenvir} is @@ -753,8 +830,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} }[% !@nx!verbatim@PitchContents ####1% !@nx!verbatim@PitchContents@Delim%added 2010/8/16 - ####1!@nx!end[!@currenvir]]]% -% ^^A !s how!verbatim@edef + ####1!@nx!end[!@currenvir]]]%% !verbatim@edef !verbatim@end]% !endgroup @@ -805,17 +881,14 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \@outerparskip \parskip % (End of |\trivlistlist| and |\@trivlist| highlights.) \@@par\addvspace\@topsep - \if@minipage\else\vskip\parskip\fi -%^^A \leftmargin\parindent% please notify me if it's a~bad idea. It is. + \if@minipage\else\vskip\parskip\fi% \advance\@totalleftmargin\verbatimleftskip \parskip\verbatimparskip % added 2010/6/2 \raggedright \leftskip\@totalleftmargin% so many assignments to preserve the % \env{list} thinking for possible future changes. However, we may % be sure no internal \env{list} shall use |\@totalleftmargin| as - % far as no inner environments are possible in \env{verbatim›[*›]}. -%^^A \rightskip\z@ -%^^A \parindent\z@\parfillskip\@flushglue\parskip\z@ + % far as no inner environments are possible in \env{verbatim›[*›]}.% \@@par% most probably redundant. \@tempswafalse \def\par{% but I~don't want the terribly ugly empty lines when @@ -905,12 +978,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \@xa\gn@melet\csname gmu@#2wd@name\endcsname{gmu@tempb}% here we % let the \CS\ with the name contained in |\gmu@⁄<char-name>wd@name| to % the expanded value of width of the char measured among copies of - % it. - % ^^A \typeout{@@@@ package gmverb: - % ^^A \@xa\string - % ^^A \csname\csname gmu@#2wd@name\endcsname\endcsname - % ^^A \space is - % ^^A \csname\csname gmu@#2wd@name\endcsname\endcsname}% + % it. % \fi }% of |\gmu@measure⁄<char-name>|. % \stanza @@ -919,7 +987,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \@xanxcs{gmu@measure#2}% \hbox to \@nx\csname \@xanxcs{gmu@#2wd@name}\@nx\endcsname - {\IfValueTF{#3}{\@nx#3}{\@xanxcs{#2}}% + {\gmuIfValueTF{#3}{\@nx#3}{\@xanxcs{#2}}% \@nx\hss}% }% of |\type@⁄<char-name>|, }% of |\DefineTypeChar|. @@ -976,8 +1044,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \def\verbeolOK{\let\gm@verb@eol\verb@eolOK} % \changes{v0.74}{06/09/07}{added} % And back to the main matter, -\def\@sverb#1{% - % ^^A \typeout{@@@@ \detokenize{#1} @@@@}% +\def\@sverb#1{%% \catcode`#1\active \lccode`\~=`#1% \gdef\verb@balance@group{\verb@egroup \@latex@error{Illegal use of \bslash verb command}\@ehc}% @@ -1014,9 +1081,9 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \relaxen\edverbs}% \def\gmv@disverb{% - \gmv@dismath - % ^^A \@xa\ verb\string - \hbox\bgroup\def\]{\egroup\gmv@edismath}} + \gmv@dismath% + \hbox\bgroup\def\]{\egroup\gmv@edismath}% +} %\subdivision{\pk{doc}- and \pk{shortvrb}-compatibility} % @@ -1026,36 +1093,11 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % thanks to |\string|. \pk{doc/shortvrb}'s concept is different, there % a~`shortverb' char should work as usual in the math mode. So let it % may be as they wish: -% \Define\old@MakeShortVerb - -\def\old@MakeShortVerb#1{% - \@xa\ifx\csname cc\string#1\endcsname\relax - \@shortvrbinfo{Made }{#1}\@shortvrbdef - \add@special{#1}% - \AddtoPrivateOthers#1% a~macro to be \emph{really} defined in - % \pk{gmdoc}. - \@xa - \xdef\csname cc\string#1\endcsname{\the\catcode`#1}% - \begingroup - \catcode`\~\active \lccode`\~`#1% - \lowercase{% - \global\@xa\let\csname ac\string#1\endcsname~% - \@xa\gdef\@xa~\@xa{% - \@shortvrbdef~}}% - \endgroup - \global\catcode`#1\active - \else - \@shortvrbinfo\@empty{#1 already}{\@empty\verb(*)}% - \fi} - +% +% % \Define\OldMakeShortVerb -\def\OldMakeShortVerb{\begingroup - \let\@MakeShortVerb=\old@MakeShortVerb - \gmu@ifstar{\eg@MakeShortVerbStar}{\eg@MakeShortVerb}} - -% \Define\eg@MakeShortVerbStar \Define\eg@MakeShortVerb -\def\eg@MakeShortVerbStar#1{\MakeShortVerb*#1\endgroup} -\def\eg@MakeShortVerb#1{\MakeShortVerb#1\endgroup} +\pdef\OldMakeShortVerb{\MakeShortVerb $$}% +% % \subdivision{Grey visible spaces} % In August 2008 Will Robertson suggested grey spaces for @@ -1145,8 +1187,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \fi }% of \cmd\verbatim@specials. -\long\def\verbatim@specials@#1#2#3#4#5#6{% - % ^^A~\def\-{\discretionary{{\normalfont-}}{}{}}% +\long\def\verbatim@specials@#1#2#3#4#5#6{%% \catcode`#1=0 \protected\@namedef{#1}{#1}% \catcode`#2=1 @@ -1165,16 +1206,16 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} #1catcode#1backquote#1h=11#1relax% }% \endlinechar\gmu@tempa\relax - \IfValueT{#4}{% + \gmuIfValueT{#4}{% \catcode`#4=3 \protected\@namedef{#4}{#4}}% - \IfValueT{#5}{% + \gmuIfValueT{#5}{% \begingroup \lccode`\~=`#5\lowercase{\endgroup\let~\metachar}% \protected\@namedef{#5}{#5}% \catcode`#5=\active }% of if value |#5|. - \PutIfValue{#6}% + \gmuPutIfValue{#6}% } \pdef\noverbatimspecials{\let\verbatim@specials@list\@undefined} @@ -1257,7 +1298,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} \verbDiscretionaryHyphen{"A6}{¦} -\XeTeXifprefix\iftrue +\ifgmuXeTeX % \CH{2010/06/28 v0.94 due to Will Robertson's remark that % recatcoding long (no-\acro{ASCII}) dashes works only under \XeTeX\ % and \LuaTeX, I embrace them in a \XeTeX\ conditional} @@ -1324,6 +1365,7 @@ pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} % % % +% \endinput %% %% End of file `gmverb.sty'. |