summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gmverb
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-03-07 00:07:10 +0000
committerKarl Berry <karl@freefriends.org>2010-03-07 00:07:10 +0000
commite8561bf554a435898669614f4d6b1a0b12617cfe (patch)
treeb68484c46dd4f3e62afdde1c1e7615c3d2415db2 /Master/texmf-dist/tex/latex/gmverb
parent8c3ddd9a73576bcd8c7c63e5452b5b6fdbac670a (diff)
gmverb 0.93 update (5mar10)
git-svn-id: svn://tug.org/texlive/trunk@17344 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gmverb')
-rw-r--r--Master/texmf-dist/tex/latex/gmverb/gmverb.sty549
1 files changed, 468 insertions, 81 deletions
diff --git a/Master/texmf-dist/tex/latex/gmverb/gmverb.sty b/Master/texmf-dist/tex/latex/gmverb/gmverb.sty
index 1149781355b..b3d4cda16d2 100644
--- a/Master/texmf-dist/tex/latex/gmverb/gmverb.sty
+++ b/Master/texmf-dist/tex/latex/gmverb/gmverb.sty
@@ -2,7 +2,7 @@
% \GetFileInfo{gmverb.sty}
% \title{The \pk{gmverb} Package\thfileinfo}
% \author{Natror (Grzegorz Murzynowski)}
-% \date{\today}
+% \date{\fakeonum[0.6]{\today}}
% \maketitle
%%
%% This is (a~documentation of) file \pk{gmverb.sty},
@@ -16,11 +16,11 @@
%%Written by Natror (Grzegorz Murzynowski),
%% natror at o2 dot pl
%%
-%% \copyright\,2005, 2006, 2007, 2008 by Natror (Grzegorz Murzynowski).
+%% \copyright\,2005, 2006, 2007, 2008, 2009, 2010 by Natror (Grzegorz Murzynowski).
%%
%% This program is subject to the \LaTeX\ Project Public License.
%% See \url{http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html} ^^A
-%% for the details of that license.
+%% for the details of that license.\rrthis
%%
%% LPPL status: "author-maintained".\par
%%
@@ -49,12 +49,18 @@
% \chschange{v0.89}{2008/8/30}{686}
% \chschange{v0.90}{2008/10/8}{684}
% \chschange{v0.91}{2008/11/21}{686}
+% \toCTAN{2008/11/21 v0.91}
+% \chschange{v0.92}{2008/12/18}{979}
+% [\cmd\verbatimspecials, hyphenation in verbatims, low star in
+% verbatims, kerning of backslash in shrunk fonts]
+% \chschange{v0.93}{2010/3/4}{1035}
+% [ a bug fix in \cmd\scanverb\space (halfing the hashes)]
+% \toCTAN{2010/03/04 v0.93}
%
-
% \skiplines we skip the driver
\ifnum\catcode`\@=12
-\documentclass [countalllines, codespacesgrey, pagella] {gmdocc}
+\documentclass [debug, countalllines, codespacesgrey, pagella, trebuchet, cursor] {gmdocc}
\twocoltoc
\begin{document}
\DocInput{\jobname.sty}
@@ -72,7 +78,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmverb}
- [2008/11/12 v0.91 After shortvrb (FM) but my way (GM)]
+ [2010/03/04 v0.93 After shortvrb (FM) but my way (GM)]
%
% \tableofcontents
@@ -99,14 +105,14 @@
% and \<text>|\mymacro| breaks into \<text>|%|\par
% |\mymacro|.
%
-% (If you don't like linebreaking at backslash, there's the
-% \TextUsage\fixbslash\ declaration (observing the common scoping
+% (If you don't like line breaking at backslash, there's the
+% \TextUsage\nobreakbslash\ declaration (observing the common scoping
% rules, hence \acro{OCSR}) and an analogous
-% declaration for the left brace: \TextUsage\fixlbrace.)
+% declaration for the left brace: \TextUsage\nobreaklbrace.)
% \dekmedskip
%
% The default `hyphen' is |%| since it's the default comment char. If
-% you wish another char to appear at the linebreak, use the
+% you wish another char to appear at the line break, use the
% \TextUsage\VerbHyphen\ declaration that takes |\|\<char> as the only
% argument. This declaration is always global.
%
@@ -130,15 +136,14 @@
% as a~shorthand for \verb+\MakeShortVerb(*)\|+.
%
% Be careful because such active chars may interfere with other
-% things, e.g., the \verb+|+ with the vertical marker in tables and
-% with the \pk{tikz} package. If this happens, you can declare e.g.,
-% \TextUsage\DeleteShortVerb\verb+\|+ and the previous meaning of the
-% char used shall be restored.
+% things, e.g.\ \verb+|+ with the \pk{tikz} package. If this
+% happens, you can declare \TextUsage\DeleteShortVerb\verb+\|+
+% and the previous meaning of the char used shall be restored.
%
% One more difference between \pk{gmverb} and \pk{shortvrb} is that
% the chars |\active|ated by |\MakeShortVerb| in the math mode behave
-% as if they were `other', so you may type e.g., \verb+$|$+ to get
-% $|$ and |+| |\active|ated this way is in the math mode typeset properly
+% as if they were `other', so you may type e.g., \verb+$2|0$+ to get
+% $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
@@ -148,7 +153,7 @@
%
% There's one more declaration provided by \pk{gmverb}:
% \TextUsage\dekclubs, which is a~shorthand for
-% \verb+\MakeShortVerb\|+, \TextUsage\dekclubs*\ for
+% \verb+\MakeShortVerb\|+, \TextUsage*{\dekclubs*}\ for
% \verb+\MakeShortVerb*\|+ and \TextUsage\olddekclubs\ for
% \verb+\OldMakeShortVerb\|+.
%
@@ -173,10 +178,85 @@
% environments so I~bring here the declaration
% \TextUsage\VisSpacesGrey. It redefines only the visible spaces so
% affects \cs{verb*} and \env{verbatim*} and not the unstarred
-% versions. The colour of the visible spaces is named |visspacesgrey|
-% and you can redefine it \pk{xcolor} way.
+% versions. The colour of the visible spaces is named
+% \TextUsage*{visspacesgrey} and you can redefine it \pk{xcolor} way.
%
% \stanza
+% We also provide the \TextUsage\verbatimspecials\ declaration that
+% takes six arguments:
+% \begin{enumargs}
+% \dc * m a~char for verbatim escape char (for catcode 0), has to be
+% unbraced\qfootnote{To be precise, the arguments cannot be wrapped in
+% 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?},
+% \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
+% unbraced,
+% \opt (optional) a~char for verbatim math shift (for catcode 3); it has
+% to be in square brackets if present. If
+% absent, nothing is set for the verbatim math shift,
+% \opt (optional) a~char for the shorthand for |\metachar|; it has to be
+% in square brackets if present.
+% \dc b optional in curly braces, additional stuff (commands) to be
+% executed in a~verbatim.
+% \end{enumargs}
+% For example, after telling \TeX
+% \[|\verbatimspecials ⁄⁄ ⁄« ⁄» [ ⁄¿ ] [ ⁄› ] {\def⁄string⁄|{$\vert$}}|\] (the
+% 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|
+%
+% To get a~‘verbatim special’ verbatim, precede it with the ‘verbatim
+% escape’: |⁄⁄⁄⁄ ⁄⁄⁄« ⁄⁄⁄» ⁄⁄⁄¿ ⁄⁄⁄›| in the example above.
+%
+% Note also that \verb+⁄⁄|+ is a~control sequence so it doesn't
+% delimit the short verbatim \verb+|+'s argument.
+%
+% The \cmd\verbatimspecials\ declaration \acro{OCSR}. Subsequent uses
+% of it override the previous settings. If you specified the optionals
+% at first and then specify |\verbatimspecials| without optionals, the
+% previous optional settings are forgotten.
+%
+% To turn the ‘verbatim specials’ off write
+% \TextUsage\noverbatimspecials, which \acro{OCSR} too.
+%
+% Note that although we don't provide a~‘verbatim superscript’ nor
+% ‘verbatim subscript’, you have the \TextUsage\sups\ and
+% \TextUsage\subs\ \CS'es defined by \pk{gmutils}.
+%
+% The 4th argument for the math shift is optional because you can use
+% \TextMarginize*{\( \)} \LaTeX's |\(| and |\)|.
+%
+% The |\verbatimspecials| declaration goes a~step further than
+% \LaTeX's \TextUsage*{alltt} and Til Tantau's \pk{beamer}'s
+% \TextUsage*{semiverbatim} environments. To get their effect, declare
+%\[|\verbatimspecials\{}|\]
+%
+% \stanza
+% There is something for verbatims in arguments of commands:
+% \TextUsage\scanverb\arg*{text}. However there are some limitations:
+% if |%| is the comment char (which is usual situation), then you
+% cannot use |%| in \<text>, or rather, |%| will act as comment char
+% anyway. Moreover, spaces are ignored. This last limitation may be
+% worked around if you declare |\verbatimspecials|, say |⁄⁄| (fraction
+% slash) as the escape char. Then you can use |⁄⁄ | to put a~space
+% which will be typeset blank in the unstarred version and visible
+% with star.
+%
+% \stanza Not so long ago I started to use the ‘broken bar’ (U+00A6,
+% |¦|) character as a hyphen in hyperlinks, because it seems not to
+% occur in hyperlinks at all unlike hyphen. I suggest the same char
+% for verbatims, but if you don't like it, there's the
+% \TextUsage\verbDiscretionaryHyphen declaration that takes two
+% arguments. Broken bar is declared as
+% \[|\verbDiscretionaryHyphen{"A6}{¦}|\]
+%
+%
+%
+% \subdivision{The package options}
% As many good packages, this also does not support any options.
%
% \begin{gmlonely}
@@ -250,7 +330,9 @@
%
\RequirePackage{gmutils}[2008/10/08]
% For |\firstofone|, |\afterfi|, |\gmobeyspaces|, |\@ifnextcat|, |\foone| and
-% |\noexpand|'s and |\expandafter|'s shorthands |\@nx| and |\@xa| resp.
+% |\noexpand|'s and |\expandafter|'s shorthands |\@nx| and |\@xa|
+% resp.\rrthis
+
% Someone may want to use another char for comment, but we assume here
@@ -263,7 +345,7 @@
\let\verbhyphen\xiipercent
% Provide a~declaration for easy changing it. Its argument should be
-% of |\|\<char> form (of course, a~\<char>\catother is also allowed).
+% of |\|\<char> form (a~\<char>\catother\ is also allowed).
% \Define\VerbHyphen
% \changes{v0.78}{06/12/1}{added}
\def\VerbHyphen#1{%
@@ -278,7 +360,8 @@
% it turns |{%| at the end of line. We'll use it in almost Knuthian ^^A}
% |\ttverbatim|---it's part of this `almost'.
\def\breaklbrace{%
- \discretionary{\xiilbrace\verbhyphen}{}{\xiilbrace}}
+ \discretionary{\type@lbrace\verbhyphen}{}{\type@lbrace}%
+ \yeshy}
\foone{\catcode`\[=1 \catcode`\{=\active \catcode`\]=2 }%
@@ -288,7 +371,7 @@
[\breaklbrace\gm@lbracehook]]%\label{gm@lbracehook}
]
-% Now we only initialize the hook. Real use of it will be made in
+% Now we only initialise the hook. Real use of it will be made in
% \pk{gmdoc}.
\relaxen\gm@lbracehook
@@ -298,25 +381,34 @@
\foone{\catcode`\!=0 \@makeother\\}%\CodeEscapeChar\!
{%
!def!bslash{\}%^^A}
- !def!breakbslash{!discretionary{!verbhyphen}{\}{\}}%^^A}}
-}
+ }% of |\foone|.
%\CodeEscapeChar\\
%
-% Sometimes linebreaking at a~backslash may be unwelcome. The basic
-% case, when the first \CS in a~verbatim breaks at the lineend leaving
+\def\breakbslash{%
+ \discretionary{\verbhyphen}%
+ {\type@bslash}{\type@bslash}\yeshy% it seems that we allow
+ % hyphenation after backslash but hyphenation will be allowed
+ % iff \inverb|\hyphenchar\font| is nonnegative.
+}% of |\breakbslash|.
+
+% Sometimes line breaking at a~backslash may be unwelcome. The basic
+% case, when the first \CS in a~verbatim breaks at the line end leaving
% there |%|, is covered by line \ref{special opening bslash}. For the
-% others let's give the user a~countercrank:
-\newcommand*\fixbslash{\let\breakbslash=\bslash}% to use due to the
+% others let's give the user a~counter-crank:
+\pdef\nobreakbslash{\def\breakbslash{\type@bslash\yeshy}}% to use due to the
% common scoping rules. But for the special case of a~backslash
% opening a~verbatim scope, we deal specially in the line
% \ref{special opening bslash}.
+% \changes{v0.92}{2008/12/11}{renamed from \cmd\fixbslash}
%
-% Analogously, let's provide a~possibility of `fixing' the left brace:
-\newcommand*\fixlbrace{\let\breaklbrace=\xiilbrace}
+% Analogously, let's provide a~possibility of `nobreaking' the left brace:
+\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 rbrace is turned off for Emacs by |\{|.
+ % ^^A~One r-brace is turned off for Emacs by |\{|.
{%^^A{
!def!dobreakbslash{!catcode`!\=!active !def\{!breakbslash}}%
}
@@ -325,18 +417,17 @@
% The macros defined below, |\visiblebreakspaces| and |\xiiclub|
% we'll use in the almost Knuthian macro making verbatim. This `almost'
% makes a~difference.
-\foone{\catcode`\ =12 }% note this space is ${}_{10}$ and is gobbled
-% by parsing the number. \cs{visiblespace} is |\let| in \pk{gmutils}
-% to \cs{xiispace} or \cs{xxt@visiblespace} of \pk{xltxtra} if available.
+% ^^A \foone{\catcode`\ =12 }% note this space is ${}_{10}$ and is gobbled
+% ^^A % by parsing of the number.
\def\breakablevisspace{\discretionary{\visiblespace}{}{\visiblespace}}
-
+%\nostanza The \cs{visiblespace} macro is |\let| in \pk{gmutils}
+% to \cs{xiispace} or to \cs{xxt\-@\-⁄yeshy⁄‘visiblespace} of \pk{xltxtra} if available.
\foone\obeyspaces% it's just re|\catcode|'ing.
{%
-\newcommand*\activespace{ }%
\newcommand*\dobreakvisiblespace{\def {\breakablevisspace}\obeyspaces}%^^A
-% |%| |\def|ing it caused a~stack overflow disaster with \pk{gmdoc}.
+% |\def|ing it caused a~stack overflow disaster with \pk{gmdoc}.\ilrr
\newcommand*\dobreakblankspace{\let =\space\obeyspaces}%
}
@@ -349,16 +440,26 @@
% |\ttverbatim| comes from \TeXbook\ too, but I~add into it a~\LaTeX\
% macro changing the |\catcode|s and make spaces visible and breakable
% and left braces too.
-% \Define\ttverbatim
+%
% \changes{v0.80}{2007/2/27}{\cs{ttverbatim@hook} added}
-\newcommand*\ttverbatim{%
+\pdef\ttverbatim{%
\let\do=\do@noligs \verbatim@nolig@list
\let\do=\@makeother \dospecials
\dobreaklbrace\dobreakbslash
\dobreakspace
+ \makeatletter
+ % \chgs{2008/12/10 v0.92 added \cmd\makeatletter\ to sound with the
+ % ‘verbatim specials’, namely to allow control sequences containing
+ % \env @}
+ \ifhmode
+ \setspaceskip
+ \fi
\tt
+ \edef\gmv@storedhyphenchar{\the\hyphenchar\font}%
+ \hyphenchar\font=\gmv@hyphenchar
\ttverbatim@hook}
+
% While typesetting stuff in the \acro{QX} fontencoding I~noticed there were
% no spaces in verbatims. That was because the \acro{QX} encoding doesn't
% have any reasonable char at position 32. So we provide a~hook in
@@ -381,7 +482,7 @@
% \file{doc.pdf} and then is added my slight changes.
\def\MakeShortVerb{%
- \@ifstar
+ \gm@ifstar
{\def\@shortvrbdef{\verb*}\@MakeShortVerb}%
{\def\@shortvrbdef{\verb}\@MakeShortVerb}}
@@ -395,7 +496,7 @@
\@xa
\xdef\csname cc\string#1\endcsname{\the\catcode`#1}%
\begingroup
- \catcode`\~\active \lccode`\~`#1%
+ \catcode`\~\active \lccode`\~=`#1%
\lowercase{%
\global\@xa\let
\csname ac\string#1\endcsname~%
@@ -455,7 +556,7 @@
% otherwise. With |\do| defined this way the entire list is just
% globally expanded itself. Analogous hack is done to the |\@sanitize|
% list.
-% \Define\rem@special
+%
\def\rem@special#1{%
\def\do##1{%
\ifnum`#1=`##1 \else \@nx\do\@nx##1\fi}%
@@ -466,17 +567,17 @@
\xdef\@sanitize{\@sanitize}%
\endgroup}
-% And now the definition of \env{verbatim} itself. As you'll see (I~hope),
-% the internal macros of it look for the name of the current
-% environment (i.e., |\@currenvir|'s meaning) to set
-% their expectation of the environment's |\end| properly. This is done
-% to allow the user to define his/her own environments with
-% |\verbatim| inside them. I.e., as with the \pk{verbatim} package,
-% you may write |\verbatim| in the begdef of your environment and then
-% necessarily |\endverbatim| in its enddef. Of course (or maybe \emph{^^B
-% surprisingly}), the commands written in the begdef after |\verbatim|
-% will also be executed at \cs{begin\marg{environment}}.
-% \Define*{verbatim}
+% And now the definition of \env{verbatim} itself. As you'll see
+% (I~hope), the internal macros of it look for the name of the current
+% environment (i.e., |\@currenvir|'s meaning) to set their expectation
+% of the environment's |\end| properly. This is done to allow the user
+% to define his/her own environments with |\verbatim| inside
+% them. I.e., as with the \pk{verbatim} package, you may write
+% |\verbatim| in the begin definition of your environment and then
+% necessarily |\endverbatim| in its end definition. Of course (or
+% maybe \qemph{surprisingly}), the commands written in the begin
+% definition after |\verbatim| will also be executed at
+% \cs{begin\arg{environment}}. \Define*{verbatim}
\def\verbatim{%
\edef\gmv@hyphenpe{\the\hyphenpenalty}%
\edef\gmv@exhyphenpe{\the\exhyphenpenalty}%
@@ -484,15 +585,20 @@
\frenchspacing \gmobeyspaces \@xverbatim
\hyphenpenalty=\gmv@hyphenpe\relax
\exhyphenpenalty=\gmv@exhyphenpe
- \hyphenchar\font=\m@ne}% in the \LaTeX\ version
+ \hyphenchar\font=\m@ne
+}% in the \LaTeX\ version
% there's \incs{@vobeyspaces} instead of \incs{gmobeyspaces}.
% \changes{v0.73}{06/09/06}{\cs{@vobeyspaces} changed to
-% \cs{obeyspaces} to make the blank \cs{verb/atim} spaces breakable}
+% \cs{obeyspaces} to make the blank \cs{verb›[atim›]} spaces breakable}
% \Define*{verbatim*}
\@namedef{verbatim*}{\@beginparpenalty \predisplaypenalty \@verbatim
- \@sxverbatim}
+ \@sxverbatim % it's the same as |\@xverbatim| and defines the
+ % verbatim end (a~macro delimited with \inverb|\end{⁄<curr.envir.>}|).
+}
\def\endverbatim{\@@par
+ \hyphenchar\font=\gmv@storedhyphenchar % hyphenchar assignments are
+ % always global.
\ifdim\lastskip >\z@
\@tempskipa\lastskip \vskip -\lastskip
\advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip
@@ -511,10 +617,26 @@
\@makeother\}%
\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]%
+ ]% 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
+ % fully expanded but my active star is \incmd\protected.
+ !@xa]% and here a~little trick with groups:
+ !@xa!def!@xa!verbatim@currenvir
+ !@xa[!verbatim@currenvir]%
!edef!verbatim@edef[%
- !def!noexpand!verbatim@end%
- ####1!noexpand\end!noexpand{!@currenvir}[%
- ####1!noexpand!end[!@currenvir]]]%
+ !def!@nx!verbatim@end%
+ ####1!noexpand\end!@nx{%
+ !@xa!unexpanded!@xa[!verbatim@currenvir]%
+ }[%
+ ####1!@nx!end[!@currenvir]]]%
!verbatim@edef
!verbatim@end]%
!endgroup
@@ -553,7 +675,7 @@
\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(*)}.
+ % far as no inner environments are possible in \env{verbatim›[*›]}.
%^^A \rightskip\z@
%^^A \parindent\z@\parfillskip\@flushglue\parskip\z@
\@@par% most probably redundant.
@@ -568,9 +690,11 @@
\penalty\interlinepenalty \check@percent}%
\everypar{\@tempswatrue\hangindent\verbatimhangindent\hangafter\@ne}%^^A
% since several chars are breakable, there's a~possibility of
- % breaking some lines. We wish them to be hanging indented.
+ % breaking some lines. We wish them to be hanging indented.\ilrr
\obeylines
- \ttverbatim}
+ \ttverbatim
+ \verbatim@specials
+}
\@ifundefined{stanzaskip}{\newlength\stanzaskip}{}
\stanzaskip=\medskipamount
@@ -601,15 +725,21 @@
% Let's define the `short' verbatim command.
%
-% \Define*\verb*
-\def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi
+% \Define*{\verb*}
+\def\verb{%
+ \relax\ifmmode\hbox\else\leavevmode\null\fi
\bgroup
\ttverbatim
+ \verbatim@specials
\gm@verb@eol
- \@ifstar{\@sverb@chbsl}{\gmobeyspaces\frenchspacing\@sverb@chbsl}}%^^A
+ \gm@ifstar
+ {\verb@lasthook\@sverb@chbsl}%
+ {\gmobeyspaces\frenchspacing\verb@lasthook\@sverb@chbsl}}%\
% in the \LaTeX\ version there's |\@vobeyspaces| instead of
-% |\gmobeyspaces|.
-% \DefIndex\@sverb@chbsl
+% |\gmobeyspaces|.\ilrr
+
+\emptify\verb@lasthook
+
\def\@sverb@chbsl#1{\@sverb#1\check@bslash}
% \DefIndex\@def@breakbslash
@@ -618,18 +748,69 @@
% For the special case of a~backslash opening a~(short) verbatim, in
% which it shouldn't be breakable, we define the checking macro.
-% \Define\check@bslash
-\def\check@bslash{\@ifnextchar{\@def@breakbslash}{\bslash\@gobble}{}}
+
+
+\DeclareCommand\DefineTypeChar{mmo}{%
+ % \begin{enumargs}
+ % \dc m the char as a~\CS,
+ % \dc m short name of the char.
+ % \dc o the cs of the char in ‘other’ catcode.
+ % \end{enumargs}
+ % \stanza
+ \@namedef{gmu@#2wd@name}{#2 wd of
+ \@xa\meaning\the\font\space at \detoken@xa\f@size pt}
+ % \stanza
+ \@namedef{gmu@measure#2}{%
+ \unless\ifcsname\csname gmu@#2wd@name\endcsname\endcsname
+ \gmu@measurewd{#1}% |\edef|s \incs{gmu@tempa} as the width of
+ % the char and \incs{gmu@tempb} as the width of
+ % the char among 20 copies of itself.
+ \@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.
+ \typeout{@@@@ package gmverb:
+ \@xa\string
+ \csname\csname gmu@#2wd@name\endcsname\endcsname
+ \space is
+ \csname\csname gmu@#2wd@name\endcsname\endcsname}%
+ \fi
+ }% of |\gmu@measure⁄<char-name>|.
+ % \stanza
+ \@nameedef{type@#2}{%
+ \@nx\leavevmode
+ \@xa\@nx\csname gmu@measure#2\endcsname
+ \hbox to \@nx\csname
+ \@xa\@nx\csname gmu@#2wd@name\endcsname\@nx\endcsname
+ {\IfValueTF{#3}{\@nx#3}{\@xa\@nx\csname #2\endcsname}%
+ \@nx\hss}%
+ }% of |\type@⁄<char-name>|,
+}% of |\DefineTypeChar|.
+
+\DefineTypeChar\\{bslash}% this defines |\type@bslash| and its
+% aides \incs{gmu@measurebslash} and \incs{gmu@bslashwd@name}.
+
+\DefineTypeChar\{{lbrace}[\xiilbrace]% this defines \incs{type@lbrace}
+% and its auxilia analogous to the above.
+
+\def\check@bslash{%
+ \@ifnextchar\@def@breakbslash
+ {\type@bslash\yeshy\@gobble}% note we allow hyphenation but actually this
+ % will have effect if \inverb|\hyphenchar\font| allows hyphenation
+ % (when it's not $>0$ ).
+ {}}
% \label{special opening bslash}
% \changes{v0.70}{06/09/02}{Opening backslash made unbreakable.}
\let\verb@balance@group\@empty
% \Define\verb@egroup
-\def\verb@egroup{\global\let\verb@balance@group\@empty\egroup}
+\def\verb@egroup{\global\let\verb@balance@group\@empty
+ \hyphenchar\font=\gmv@storedhyphenchar
+ \egroup}
% \Define\gm@verb@eol
-%\changes[\verb]{v0.74}{06/09/07}{line end forbidden inside \*}
+%\changes[\verb]{v0.74}{06/09/07}{line end forbidden inside \texttilde}
\let\gm@verb@eol\verb@eol@error
% The latter is a~\LaTeXe\ kernel macro that |\active|ates line end
% and defines it to close the verb group and to issue an error
@@ -656,11 +837,13 @@
% \changes{v0.74}{06/09/07}{added}
% And back to the main matter,
\def\@sverb#1{%
- \catcode`#1\active \lccode`\~`#1%
+ \catcode`#1\active \lccode`\~=`#1%
\gdef\verb@balance@group{\verb@egroup
\@latex@error{Illegal use of \bslash verb command}\@ehc}%
\aftergroup\verb@balance@group
- \lowercase{\let~\verb@egroup}}
+ \lowercase{\let~\verb@egroup}% here we make the delimiter to be the
+ % macro closing the verbatim group.
+}
\def\verbatim@nolig@list{\do\`\do\<\do\>\do\,\do\'\do\-}
@@ -673,7 +856,7 @@
% And finally, what I~thought to be so smart and clever, now is just
% one of many possible uses of a~general almost Rainer Sch\"opf's
% macro:
-\def\dekclubs{\@ifstar{\MakeShortVerb*\|}{\MakeShortVerb\|}}
+\def\dekclubs{\gm@ifstar{\MakeShortVerb*\|}{\MakeShortVerb\|}}
\def\olddekclubs{\OldMakeShortVerb\|}
% But even if a~shortverb is unconditional, the spaces in the math
@@ -727,7 +910,7 @@
% \Define\OldMakeShortVerb
\def\OldMakeShortVerb{\begingroup
\let\@MakeShortVerb=\old@MakeShortVerb
- \@ifstar{\eg@MakeShortVerbStar}{\eg@MakeShortVerb}}
+ \gm@ifstar{\eg@MakeShortVerbStar}{\eg@MakeShortVerb}}
% \Define\eg@MakeShortVerbStar \Define\eg@MakeShortVerb
\def\eg@MakeShortVerbStar#1{\MakeShortVerb*#1\endgroup}
@@ -740,7 +923,7 @@
% the grey spaces so much that I~want provide them for any verbatim
% environments, so I~bring the definition here. The declaration, if
% put in the preamble, postpones redefinition of \cs{visiblespace}
-% till |\begin{document}| to recognize possible redefinition of
+% till |\begin{document}| to recognise possible redefinition of
% it when \pk{xltxtra} is loaded.
\let\gmd@preambleABD\AtBeginDocument
@@ -758,7 +941,204 @@
}}
+% \subdivision{Verbatim specials---\CSes in verbatims}
+
+\pdef\verbatimspecials{% This declaration only defines a~bearer\
+ % of the ‘verbatim specials’.\
+ % \begin{enumargs}
+ % \dc * m char for verbatim escape char (for catcode 0), has to be unbraced,
+ % \dc * m char for verbatim group begin (for catcode 1), has to be unbraced,
+ % \dc * m char for verbatim group end (for catcode 2), has to be unbraced,
+ % \dc o char for verbatim math shift (for catcode 3),
+ % \dc o char for a~shorthand for |\metachar|.
+ % \dc b (optional braced) additional stuff (commands) to be executed
+ % at the beginning of the verbatims.
+ % \end{enumargs}
+ \@bsphack
+ \begingroup
+ \let\do\@makeother
+ \dospecials
+ \catcode`\ =10
+ \verbatim@specials@iii}
+
+\pdef\verbatim@specials@iii#1#2#3{% as you see, we take only first
+ % three arguments in a~despecialized group. It's to avoid
+ % \incs{futurelet} of the optionals' parser to touch (and thus
+ % spoil) subsequent token. Yes, we could handle the case of a~space
+ % or single line end but handling the case of a~backslash would be
+ % somewhat difficult.
+ \endgroup
+ \def\verbatim@specials@list{#1#2#3}%
+ \@ifnextchar[%^^A]
+ {\begingroup\let\do\@makeother\dospecials
+ \catcode`\ =9
+ \verbatim@specials@iv}%
+ {\addtomacro\verbatim@specials@list{\NoValue\NoValue}%
+ \verbatim@specials@vi}%
+}% of |\verbatim@specials@iii|.
+
+\pdef\verbatim@specials@iv[#1]{%
+ \endgroup
+ \addtomacro\verbatim@specials@list{#1}%
+ \@ifnextchar[%^^A]
+ {\begingroup\let\do\@makeother\dospecials
+ \catcode`\ =9
+ \verbatim@specials@v}%
+ {\addtomacro\verbatim@specials@list{\NoValue}%
+ \verbatim@specials@vi}%
+}% of |\verbatim@specials@iv|.
+
+\pdef\verbatim@specials@v[#1]{%
+ \endgroup
+ \addtomacro\verbatim@specials@list{#1}%
+ \verbatim@specials@vi
+}% of |\verbatim@specials@v|.
+
+\DeclareCommand\verbatim@specials@vi\long{b}
+{\addtomacro\verbatim@specials@list{{#1}}%
+\@esphack}
+
+\def\verbatim@specials{% this is the macro that actually sets the
+ % chars given in \incs{verbatim@specials@list} as the escape char,
+ % group begin and group end.
+ \ifdefined\verbatim@specials@list
+ \@xa\verbatim@specials@\verbatim@specials@list
+ \fi
+}% of \cmd\verbatim@specials.
+
+\long\def\verbatim@specials@#1#2#3#4#5#6{%
+ % ^^A~\def\-{\discretionary{{\normalfont-}}{}{}}%
+ \catcode`#1=0
+ \protected\@namedef{#1}{#1}%
+ \catcode`#2=1
+ \protected\@namedef{#2}{#2}%
+ \catcode`#3=2
+ \protected\@namedef{#3}{#3}%
+ \edef\gmu@tempa{\the\endlinechar}%
+ \endlinechar\m@ne % we have to suppress adding of a~line end by
+ % \incs{scantokens} since it would turn into an
+ % active char |^^M| and raise an error (which actually did happen).
+ \scantokens{%
+ #1let#1bgroup=#2%
+ #1let#1egroup=#3%
+ #1catcode#1backquote#1h=6#1relax%
+ #1pdef#1<h1>#2#1meta#2h1#3#3%
+ #1catcode#1backquote#1h=11#1relax%
+ }%
+ \endlinechar\gmu@tempa\relax
+ \IfValueT{#4}{%
+ \catcode`#4=3
+ \protected\@namedef{#4}{#4}}%
+ \IfValueT{#5}{%
+ \begingroup
+ \lccode`\~=`#5\lowercase{\endgroup\let~\metachar}%
+ \protected\@namedef{#5}{#5}%
+ \catcode`#5=\active
+ }% of if value |#5|.
+ \PutIfValue{#6}%
+}
+
+\pdef\noverbatimspecials{\let\verbatim@specials@list\@undefined}
+
+
+\def\GMverbatimspecials{%
+ \gm@testdefined\XeTeXversion\iftrue
+ \verbatimspecials ⁄«»[¿][›]%
+ {\def\|{\metachar{$\vert$}}%
+ % ^^A \hyphenchar\font=\gmv@hyphenchar
+ \makestarlow
+ \relaxen\‘% to provide a~\CS\ separator (space is not $_{10}$\ in verbatims).
+ }% of |#6|.
+ \fi
+}% of |\GMverbatimspecials|.
+
+
+% \subdivision{Partial \cmd\verb\ in arguments}
+
+% Now command for partial verbatims in arguments of commands:
+\let\gmu@tempa\all@stars
+\@xa\addtomacro\@xa\gmu@tempa\@xa{\all@unders}
+
+\foone{\catcode`#=\active}
+{\def\gmv@hashhalfing{%
+ % \chgs{2010/03/01 v0.93 cut out as separate macro}
+ \def#{\xiihash\@ifnextchar#\gobble{}}%
+ \catcode`#\active}%
+}
+
+
+\foone{\@makeother\^^R}{%
+ \@xa\DeclareCommand\@xa\scanverb\@xa{%
+ % \chgs{2010/03/01 v0.93 mandatory argument made long (a bug fix)}
+ \@xa Q\@xa{\gmu@tempa}>Pm}{%\
+ % \begin{enumargs}
+ % \dc Q{*_}
+ % \dc m the stuff to be rescanned and typeset verbatim. Note that |%|
+ % will be executed during first scan so at best will disappear.
+ % \end{enumargs} Spaces are ignored (because of detokenizers that add
+ % a~space after a~\CS) but if you declare some
+ % \incmd\verbatimspecials, then you can use \inverb|⁄⁄ | where |⁄⁄| denotes
+ % the escape char in verbatim.
+ \begingroup
+ \gmu@septify
+ \endlinechar=\m@ne
+ \@xa\IfIntersect\@xa{\all@stars}{#1}%
+ {\def\ {\breakablevisspace}}%
+ {\let\ =\space}%
+ \@xa\IfIntersect\@xa{\all@unders}{#1}%
+ {}{% We make spaces ignored only if there was no underscore in
+ % \inhash1 and if \inhash2 doesn't contain \inverb|\ |.
+ \IfAmong\ \among{#2}%
+ {}{\addtomacro\verb@lasthook{\catcode`\ =9 }}}%
+ \addtomacro\verb@lasthook{\gmv@hashhalfing }%
+ \@makeother\^^R%
+ \edef\gmu@tempa{%
+ \@nx\scantokens{%
+ \bslash verb%
+ ^^R\detokenize{#2}^^R% we delimit the |\verb|'s argument with
+ % ‘other’ \inverb|^^R| assuming this char to be used very seldom
+ % if at all.
+ }% of |\scantokens|,
+ }\gmu@tempa
+ \endgroup
+ }% of |\scanverb|,
+}% of |\foone|.
+
+
+\def\verbDiscretionaryHyphen#1#2{%
+ % \chgs{2010/03/03 v0.93 added to synchronise hyphen chars in
+ % \pk{gmdoc}'s documentation}
+ \def\gmv@hyphenchar{\numexpr#1\relax}%
+ \def\gmv@hyphen{#2}%
+}
+
+\verbDiscretionaryHyphen{"A6}{¦}
+
+\def\gmu@tempa{%
+ \DeclareCommand\verbLongDashes{
+ >iS{–}% to memorise which dash we set
+ B{1.41} % expansion of en-dash
+ >iS{—} % as above
+ B{2} % expansion of em-dash
+ }%
+}
+
+\def\gmu@tempb{\catcode`–\active \catcode`—\active}
+
+\foone{\catcode`–\active\catcode`—\active}
+{%
+ \edef\gmu@tempa{\@xau\gmu@tempa
+ {%
+ \@nx\addtomacro\@nx\ttverbatim@hook{%
+ \@xau\gmu@tempb
+ \def\@nx–{\@nx\scalebox{##1}[1]{\string–}}%
+ \def\@nx—{\@nx\scalebox{##2}[1]{\string—}}%
+ }%
+ }%
+ }%
+}%
+\gmu@tempa
\endinput% for the Tradition.
@@ -777,8 +1157,8 @@
% \changes{v0.85}{2008/03/29}{added restoring of \cs{hyphenpenalty}
% and \cs{exhyphenpenalty} and setting \cs{hyphenchar!=-1}}
%
-% \changes{v0.87}{2008/08/06}{visible space tidyied and taken from
-% \pk{xltxtra} if available. \pk{gmutils} required. The \cs{xii...}
+% \changes{v0.87}{2008/08/06}{visible space tidied and taken from
+% \pk{xltxtra} if available. \pk{gmutils} required. The \cs{xii›…}
% \CSes moved to \pk{gmutils}. The documentation driver moved
% into the \file{.sty} file}
%
@@ -787,8 +1167,9 @@
% \cs{MakeShortVerb}\cmd\|, \cs{MakeShortVerb*}\cmd\| and
% \cs{OldMakeShortVerb}\cmd{\|} respectively.}
%
-% \changes{v0.90}{2008/10/08}{some \cs{b/egroup} changed to
-% \cs{begin/endgroup}}
+% \changes{v0.90}{2008/10/08}{some \cs{›(b⁄!|e›)group} changed to
+% \cs{›(begin⁄!|end›)group}}
+%
%
% \PrintChanges \PrintIndex
% \Finale
@@ -796,5 +1177,11 @@
% (For my GNU Emacs:)
%%% Local Variables:
%%% mode: doctex
+%%% mode: flyspell
+%%% ispell-local-dictionary: "british"
%%% TeX-master: "../../../../LaTeX/TeXGuru/gmverb/gmverbDoc.tex"
+%%% coding: utf-8
%%% End:
+
+% LocalWords: breakbslash dobreakbslash chbsl exhyphenpe hyphenpe lasthook
+% LocalWords: visspacesgrey sxverbatim septify measurewd bslashwd