summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gmverb/gmverb.sty
blob: 16a64651480656e7b9871714707eb737e2628f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
%% 
% \skiplines
%<*master>
%% \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 $
% \endskiplines
%
%% \BundleInfoFromName{gmverb}
%% \title{The \pk {gmverb} Package\thfileinfo }
%% \author{Grzegorz Murzynowski}
%% \maketitle
%%
%% \let\ty\emph \let\df\dekfracc
%%
%% \begin{copyrnote}
%%
%% 
%% Copyright ©\, 2005, 2006, 2007, 2008, 2009, 2010, 2011
%% by Grzegorz ‘Natror’ Murzynowski
%% natror (at) gmail (dot) com
%% 
%% This program is subject to the \LaTeX\ Project Public License.
%% See ^^A
%% \url{http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html} ^^A
%% for the details of that license.\rrthis
%%
%% \acro{LPPL} status: "author-maintained". \par
%%
%% 
%% 
%% 
%% 
%% For documentation please refer to the file(s)
%% \file{gmverb.{sty,pdf}}.
%%
%% \end{copyrnote}
%% 
%
%
% \skiplines
%</master>
% \endskiplines
%
%
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmverb}
    [2011/10/14 v0.98 After shortvrb (FM) but my way (GM)]


%<*master>
%
% (A handful of meta-settings skipped)
% \skiplines
\def\Name#1#2{\expandafter#1\csname#2\endcsname}

% The »v« letter before version number is obligatory and will be
% passed further.
\def\ProvideDateVersion#1[#2 v#3]{%
  \Name\def{#1Date}{#2}%
  \Name\def{#1Version}{v#3}%
}

\def\ProvideInfo#1[#2 v#3 #4]{%
  \ProvideDateVersion{#1}[#2 v#3]%
  \Name\def{#1Info}{#4}%
}

\def\ProvideLeafInfo#1[#2 v#3 #4]{%
  \ProvideDateVersion{#1}[#2 v#3]%
  \Name\def{#1LeafInfo}{#4}%
}

\def\gmutilsThanks{%
  Many thanks to my \TeX\ Guru Marcin Woliński for his \TeX nical
  support.%
}

% \endskiplines
%</master>
%\skiplines we skip the driver
%<*master>
\ifnum\catcode`\@=12


\documentclass[debug, countalllines, codespacesgrey, outeroff,
%
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%
  makeindex -r -s gmglo.ist -o \jobname.gls \jobname.glo^^J
  (gmglo.ist should be put into some texmf/makeindex directory.)^^J}
\typeout{%
  Produce index with^^J%
  makeindex -r \jobname^^J}
\afterfi{\end{document}}

\fi% of driver pass
%</master>
%\endskiplines
%
% \enoughpage 18
% \tableofcontents
%
%
% \ChangesStart{}{1000/00/00}
%
% \chschange{v0.70}{06/8/15}{523}
% \chschange{v0.71}{06/9/04}{596}
% \chschange{v0.72}{06/9/05}{660}
% \chschange{v0.73}{06/9/06}{671}
% \chschange{v0.74}{06/9/7}{678}
% \chschange{v0.76}{06/9/24}{679}
% \chschange{v0.77}{06/9/28}{639}
% \chschange{v0.78}{06/12/1}{648}
% \chschange{v0.80}{07/3/2}{683}
% \chschange{v0.80}{07/3/30}{667}
% \chschange{v0.82}{2007/4/26}{663}
% \chschange{v0.83}{2007/11/9}{666}
% \chschange{v0.84}{2007/11/13}{658}
% \chschange{v0.85}{2008/5/1}{673}
% \chschange{v0.87}{2008/8/6}{661}
% \chschange{v0.88}{2008/8/13}{682}
% \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}
% \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}
%
% This package redefines the |\verb| command and the \env{verbatim}
% environment so that the verbatim text can break into lines, with |%|
% (or another character chosen to be the comment char) as
% a~`hyphen'. Moreover, it allows the user to define \hisher\ own
% \env{verbatim}-like environments provided their contents would be not
% \emph{horribly} long (as long as a macro's argument may be at most).
%
% This package also allows the user to declare a chosen char(s) as
% a `short verb' e.g., to write \verb+|\a\verbatim\example|+ instead of
% \verb+\verb|\a\verbatim\example|+.
% \dekmedskip
%
% 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
% |{%|\par \<subsequent text>|}| ^^A]  bal. braces for Emacs
% and \<text>|\mymacro| breaks into \<text>|%|\par
% |\mymacro|.
%
% (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\nobreaklbrace.)
% \dekmedskip
%
% The default `hyphen' is |%| since it's the default comment char. If
% 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.
%
% \stanza
% Another difference is the \TextUsage\verbeolOK\ declaration
% (\acro{OCSR}). Within its scope, |\verb| allows an
% end of a~line in its argument and typesets it just as a~space.
%
% As in the standard version(s), the plain |\verb| typesets the spaces
% blank and |\verb*| makes them visible.
%
% Moreover, \pk{gmverb} provides the \TextUsage\MakeShortVerb\ macro
% that takes a~one-char control sequence as the only argument and
% turns the char used into a~short verbatim delimiter, e.g., after
% \verb+\MakeShortVerb*\|+ (as you guess, the declaration has its
% starred version, which is for visible spaces, and the non-starred for
% the spaces blank) you may type \verb+|\mymacro|+ to get |\mymacro|
% instead of typing |\verb+\mymacro+|. Because the char used in this
% example is my favourite and used just this way by DEK in the
% \TeXbook's format, \pk{gmverb} provides a~macro \TextUsage\dekclubs\
% as a~shorthand for \verb+\MakeShortVerb(*)\|+.
%
% Be careful because such active chars may interfere with other
% 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+$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
% 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}:
% \TextUsage\dekclubs, which is a~shorthand for
% \verb+\MakeShortVerb\|+, \TextUsage*{\dekclubs*}\ for
% \verb+\MakeShortVerb*\|+ and \TextUsage\olddekclubs\ for
% \verb+\OldMakeShortVerb\|+.
%
% There's one more declaration, \TextUsage\edverbs\ that makes
% \cs{[} %^^A]
% checks if the next token is an active char and opens an |\hbox| if
% so. That is done
% so that you can write (in  |\edverbs|' and |\dekclubs|' scope)
%\[\verb+\[|<verbatim stuff>|\]+\]
% instead of
%\[\verb+\[\hbox{|<verbatim stuff>|}\]+\]
% to get a~displayed shortverb.
%
% Both versions of |\dekclubs| \acro{OCSR}.
%
% The \env{verbatim} environment inserts |\topsep| before and after
% itself, just as in standard version (as if it was a~\env{list}).
%
% In August 2008 Will Robertson suggested grey visible spaces for
% \pk{gmdoc}. I~added a~respective option to \pk{gmdoc} but I~find
% them so nice that I~want to make them available for all verbatim
% 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
% \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. If provided, e.g., |⁄››| as I suggest
% in |\GMverbatimspecials|, then it itself becomes an active char
% let-equal to |\meta|, and a \CS made of it, |⁄›⁄›| in this example,
% becomes |\string|.
% \dc b optional in curly braces, additional stuff (commands) to be
% executed in a~verbatim.
% \end{enumargs}
% All the specials defined this way, except the meta char, if preceded
% with the escape char, will be typeset verbatim.
%
% For example, after telling \TeX
% \[|\verbatimspecials ⁄⁄ ⁄« ⁄» [ ⁄¿ ] [ ⁄›› ] {\def⁄›⁄|{$\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|
%%
%
% 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}{¦}|\]
%
% \stanza Since version 0.95 (August 2010) this package also provides
% the |\VerbatimPitch| declaration that modifies the \env{verbatim}
% environments and derivatives so that the environment contents
% (recatcoded, i.e.\ “sanitised”) are wrapped in the macro
% |\VerbatimContents| and therefore available after environment's end
% (after |\endverbatim| to be precise, so also in the end-def of a
% derivative verbatim).
%
% This may be useful for \TeX nical examples: you can  rescan the
% contents of a verbatim with |\scantokens| and execute/typeset it.
% Such a thing is done in the \pk{gmdoc} package, see the
% \env{verbatim@p} environment.
%
%
%
% \subdivision{The package options}
% As many good packages, this also does not support any options.
%
% \begin{gmlonely}
% \subdivision{Installation}
% 
% Unpack the \file{\jobname-tds.zip}
% archive (this is an archive that conforms the \acro{TDS} standard,
% see \file{CTAN/tds/tds.pdf}) in some texmf directory or just put
% the \pk{gmutils.sty} somewhere in the \file{texmf/\:tex/\:latex}
% branch. Creating a \file{texmf/\:tex/\:latex/\:gm} directory may
% be advisable if you consider using other packages written by me.
% 
% Then you should refresh your \TeX\ distribution's files' database
% most probably.
% \end{gmlonely}
% 
% \subdivision{Contents of the \pk{\jobname.zip} archive}
% 
% The distribution of the \pk{gmutils} package consists of the
% following three files and a \acro{TDS}-compliant archive.
% \begin{verse}
% \pk{\jobname.\gmdExt}\\
% \pk{README}\\
% \pk{\jobname.pdf}\\
% \pk{\jobname.tds.zip}
% \end{verse}
% 
% \begin{gmlonely}
% \subdivision{Compiling of the documentation}
% 
% The last of the above files (the \pk{.pdf}, i.e., \emph{this
% file}) is a documentation compiled from the \pk{.\gmdExt} file by
% running \LaTeX\ on the \pk{\jobname.\gmdExt} file twice
% (|xelatex ⁄jobname.⁄gmdExt| in the directory you wish the
% documentation to be in^^A
% \ifnum\numexpr\strcmp{\gmdExt}{sty}*\strcmp{cls}{\gmdExt}=0\relax^^A
%, you don't have copy the \file{.\gmdExt} file
% there, \TeX\ will find it\fi),
% then MakeIndex on the \file{\jobname.idx} file, and then \LaTeX\
% on \file{\jobname.\gmdExt} once more.
% 
%MakeIndex shell commands:
%\begin{verbatim}
%makeindex -r ⁄jobname
%makeindex -r -s gmglo.ist -o ⁄jobname.gls ⁄jobname.glo
%\end{verbatim}
% 
% The |-r| switch is to forbid MakeIndex to make implicit ranges since
% the (code line) numbers will be hyperlinks.
% 
% Compiling the documentation requires the packages:
% \pk{gmdoc} (\pk{gmdoc.sty} and \pk{gmdocc.cls}), \pk{gmverb.sty},
% the \pk{gmutils} bundle, \pk{gmiflink.sty}
% and also some standard packages:
% \pk{hyperref.sty}, \pk{color.sty}, \pk{geometry.sty},
% \pk{multicol.sty}, \pk{lmodern.sty}, \pk{fontenc.sty} that should
% be installed on your computer by default.
% 
% Moreover, you should put the \file{gmglo.ist} file, a MakeIndex
% style for the changes' history, into some \file{texmf/makeindex}
% (sub)directory.
% 
% Then you should refresh your \TeX\ distribution's files' database
% most probably.
% 
% If you had not installed the \pk{mwcls} classes (available on
% \acro{CTAN} and present in \TeX\ Live e.g.), the result of your
% compilation might differ a bit from the \pk{.pdf} provided in this
% \pk{.zip} archive in formatting: If you had not installed
% \pk{mwcls}, the standard \pk{article.cls} class would be used.
% \end{gmlonely}
% 
% 
%
%
% \division{The code}
%
% \DoIndex{\verb \verb*}
% \subdivision{Preliminaries}
%
\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
%
%
%
% Someone may want to use another char for comment, but we assume here
% `orthodoxy'. Other assumptions in \pk{gmdoc} are made. The `knowledge'
% what char is the comment char is used to put proper `hyphen' when
% a~\env{verbatim} line is broken.
% \Define\verbhyphen
% \changes{v0.75}{06/9/8}{renamed from a~rather confusing
% \cs{commentchar}}
\let\verbhyphen\xiipercent

% Provide a~declaration for easy changing it. Its argument should be
% of |\|\<char> form (a~\<char>\catother\ is also allowed).
% \Define\VerbHyphen
% \changes{v0.78}{06/12/1}{added}
\def\VerbHyphen#1{%
  {\escapechar\m@ne
    \@xa\gdef\@xa\verbhyphen\@xa{\string#1}}}
% As you see, it's always global.

% \subdivision{The breakables}
%
% Let's define a~|\discretionary| left brace such that if it breaks,
% 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{\type@lbrace\verbhyphen}{}{\type@lbrace}%
  \yeshy}

\foone{\catcode`\[=1 \catcode`\{=\active \catcode`\]=2 }%
[%
   \def\dobreaklbrace[\catcode`\{=\active
   \def{%^^A}
     [\breaklbrace\gm@lbracehook]]%\label{gm@lbracehook}
]

% Now we only initialise the hook. Real use of it will be made in
% \pk{gmdoc}.
\relaxen\gm@lbracehook

% The |\bslash| macro defined below I~use also in more `normal' \TeX ing, e.g.,
% to |\typeout| some |\outer| macro's name.
%\Define\bslash \Define\breakbslash
\foone{\catcode`\!=0 \@makeother\\}%\CodeEscapeChar\!
{%
  !def!bslash{\}%^^A}
  }% of |\foone|.
%\CodeEscapeChar\\
%
\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~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 `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{
  !def!dobreakbslash{!catcode`!\=!active !def\{!breakbslash}}%
}
%\CodeEscapeChar\\

% The macros defined below, |\visiblebreakspaces| and |\xiiclub|
% we'll use in the almost Knuthian macro making verbatim. This `almost'
% makes a~difference.%

\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*\dobreakvisiblespace{\def {\breakablevisspace}\obeyspaces}%^^A
% |\def|ing it caused a~stack overflow disaster with \pk{gmdoc}.\ilrr
\newcommand*\dobreakblankspace{\let =\space\obeyspaces}%
}

% \Define\xiiclub
\foone{\@makeother\|}{%
  \def\xiiclub{|}}

% \subdivision{Almost-Knuthian \cs{ttverbatim}}
%
% |\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.
%
% \changes{v0.80}{2007/2/27}{\cs{ttverbatim@hook} added}
\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
  \verbatimfont
  \xdef\gmv@storedhyphenchar{\the\hyphenchar\font}%
  % Assignment of the hyphenchar is always global so let the above
  % edefinition be also such.
  \hyphenchar\font=\gmv@hyphenchar
  \ttverbatim@hook
}% of |\ttverbatim|

% \CH{2010/08/14  v0.993 rigid \cmd\tt in \cmd\ttverbatim changed to
% redefinable \cmd\verbatimfont due to absurd problems with bad
% fontifying of \pk{gmdoc}}
%
\def\verbatimfont{\tt}

% 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
% the very core of the verbatim making macros to set proper
% fontencoding for instance.
\@emptify\ttverbatim@hook

% \Define*{\VerbT1}
\def\VerbT1{\def\ttverbatim@hook{\fontencoding{T1}\selectfont}}

% We wish the visible spaces to be the default.
% \DefIndex\dobreakspace
\let\dobreakspace=\dobreakvisiblespace
%
%^^A~|\meta| and pals moved to \pk{gmutils}

% \subdivision{The core: from \pk{shortvrb}}
%
% The below is copied verbatim ;-) from
% \file{doc.pdf} and then is added my slight changes.

\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 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 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 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
\@ifpackageloaded{gmdoc}{%
  \def\gmv@packname{gmdoc}}{%
  \def\gmv@packname{gmverb}}

% \Define\@shortvrbinfo
\def\@shortvrbinfo#1#2#3{%
  \PackageInfo{\gmv@packname}{%
   ^^J\@empty #1\@xa\@gobble\string#2 a short reference
    for \@xa\string#3}}

% \Define\add@special
\def\add@special#1{%
  \rem@special{#1}%
  \@xa\gdef\@xa\dospecials\@xa
  {\dospecials \do #1}%
  \@xa\gdef\@xa\@sanitize\@xa
  {\@sanitize \@makeother #1}}

% For the commentary on the below macro see the \pk{doc} package's
% documentation. Here let's only say it's just amazing: so tricky and
% wicked use of |\do|. The internal macro |\rem@special| defines |\do|
% to expand to nothing if the |\do|'s argument is the one to be
% removed and to unexpandable \CSs\ |\do| and \<\cs{do}'s argument>
% otherwise. With |\do| defined this way the entire list is just
% globally expanded itself. Analogous hack is done to the |\@sanitize|
% list.
%
\def\rem@special#1{%
  \def\do##1{%
    \ifnum`#1=`##1 \else \@nx\do\@nx##1\fi
  }%
  \xdef\dospecials{\dospecials}%
  \begingroup
  \def\@makeother##1{%
    \ifnum`#1=`##1 \else \@nx\@makeother\@nx##1\fi}%
  \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 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}%
  \@beginparpenalty \predisplaypenalty \@verbatim
  \frenchspacing \gmobeyspaces \@xverbatim
  \hyphenpenalty=\gmv@hyphenpe\relax
  \exhyphenpenalty=\gmv@exhyphenpe
  \hyphenchar\font=\m@ne
%
% The line below serves as the delimiter for
% |\verbatim@PitchContents|, to discard the stuff before it (see
% l.~\ref{verbatim@PitchContents:1/2}).
%
  \@gobble\verbatim
}% 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}
% \Define*{verbatim*}
\@namedef{verbatim*}{\@beginparpenalty \predisplaypenalty \@verbatim
  \@sxverbatim % it's the same as |\@xverbatim| and defines the
  % verbatim end (a~macro delimited with \inverb|\end{⁄<curr.envir.>}|).
}

\def\endverbatim{\@@par
% ^^V   \hyphenchar\font=\gmv@storedhyphenchar % hyphenchar assignments are
% ^^V   % always global. And for an entire paragraph works the one
% last in it so we hide it.
  \ifdim\lastskip >\z@
    \@tempskipa\lastskip \vskip -\lastskip
    \advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip
    \vskip\@tempskipa
  \fi
  \addvspace\@topsepadd
  \@endparenv
}

% \Define\endverbatim*
\n@melet{endverbatim*}{endverbatim}

% \Define\@xverbatim
\begingroup \catcode `!=0 %
\catcode `[= 1 \catcode`]=2 %
\catcode`\{=\active
\@makeother\}%
\catcode`\\=\active%\CodeEscapeChar\!
!gdef!@xverbatim[%
  [!endlinechar!m@ne !everyeof[!@nx]%
    !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
    % 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!@nx!verbatim@end%
  ####1!noexpand\end!@nx{%
    !@xa!unexpanded!@xa[!verbatim@currenvir]%
  }[%
    !@nx!verbatim@PitchContents ####1%
    !@nx!verbatim@PitchContents@Delim%added 2010/8/16
    ####1!@nx!end[!@currenvir]]]%%
  !verbatim@edef
  !verbatim@end]%
!endgroup
% \CodeEscapeChar\\

% \Define\@sxverbatim
\let\@sxverbatim=\@xverbatim

\def\verbatim@PitchContents@Left{%
  \long\def\verbatim@PitchContents
  ##1\@gobble\verbatim ##2\verbatim@PitchContents@Delim
}

% By default we make |\verbatim@PitchContents| a gobbler.
\verbatim@PitchContents@Left {}

\pdef\VerbatimPitch{%
% But in this declaration scope we make |\@xverbatim| pitch the contents of
% \env{verbatim}s in a macro. We use that in \pk{gmdoc} not to repeat
% examples' code.
% \label{verbatim@PitchContents:1/2}
  \verbatim@PitchContents@Left {%
    \gdef\VerbatimContents{##2}%
  }%
  %
}% of |\VerbatimThrow|.

% \Define\@verbatim
% F.\,Mittelbach says the below is copied almost verbatim from \LaTeX\
% source, modulo |\check@percent|.\Define\@verbatim
\def\@verbatim{%
  % \changes{v0.71}{06/09/04}{\cs{trivlist} substituted with
  % chosen explicit macros. Analogous in \cs{endverbatim}.}
  %
  % Originally here was just |\trivlist \item[]|, but it worked
  % badly in my document(s), so let's take just highlights of if.
  \parsep\parskip
  % From |\@trivlist|:
  \if@noskipsec \leavevmode \fi
  \@topsepadd \topsep
  \ifvmode
    \advance\@topsepadd \partopsep
  \else
    \unskip \par
  \fi
  \@topsep \@topsepadd
  \advance\@topsep \parskip
  \@outerparskip \parskip
  % (End of |\trivlistlist| and |\@trivlist| highlights.)
  \@@par\addvspace\@topsep
  \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›[*›]}.%
  \@@par% most probably redundant.
  \@tempswafalse
  \def\par{% but I~don't want the terribly ugly empty lines when
    % a~blank line is met. Let's make them \pk{gmdoc}-like
    % i.e., let a~vertical space be added as in between stanzas
    % of poetry. Originally |\if@tempswa\hbox{}\fi|, in my version will
    % be
    \ifvmode\if@tempswa\addvspace\stanzaskip\@tempswafalse\fi\fi
    \@@par
    \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.\ilrr
  \obeylines
  \ttverbatim
  \verbatim@specials
}

\@ifundefined{stanzaskip}{\newlength\stanzaskip}{}
\stanzaskip=\medskipamount

\newskip\verbatimleftskip
%\changes{v0.91}{2008/11/12}{added}
\verbatimleftskip\leftmargini

\newskip\verbatimhangindent
% \changes{v0.71}{06/09/04}{added to verbatim parameters.}
\verbatimhangindent=3em

\newskip\verbatimparskip
\verbatimparskip\z@skip

\providecommand*\check@percent{}
% In the \pk{gmdoc} package shall it be defined to check if the next
% line begins with a~comment char.
%
% Similarly, the next macro shall in \pk{gmdoc} be defined to update
% a~list useful to that package. For now let it just gobble its
% argument.
\providecommand*\AddtoPrivateOthers[1]{}
% Both of the above are |\provide|d to allow the user to load
% \pk{gmverb} after \pk{gmdoc} (which would be redundant since
% \pk{gmdoc} loads this package on its own, but anyway should be
% harmless).

% Let's define the `short' verbatim command.
%
% \Define*{\verb*}
\def\verb{%
  \relax\ifmmode\hbox\else\leavevmode\null\fi
  \bgroup
  \ttverbatim
  \verbatim@specials
  \gm@verb@eol
  \gmu@ifstar
  {\verb@lasthook\@sverb@chbsl}%
  {\gmobeyspaces\frenchspacing\verb@lasthook\@sverb@chbsl}}%\
% in the \LaTeX\ version there's |\@vobeyspaces| instead of
% |\gmobeyspaces|.\ilrr

\emptify\verb@lasthook

\def\@sverb@chbsl#1{\@sverb#1\check@bslash}

% \DefIndex\@def@breakbslash
\def\@def@breakbslash{\breakbslash}% because |\| is |\def|ined
% as \cs{break\-b\-slash} not \inverb|\let|.

% For the special case of a~backslash opening a~(short) verbatim, in
% which it shouldn't be breakable, we define the checking macro.

\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. %
    \fi
  }% of |\gmu@measure⁄<char-name>|.
  % \stanza
  \@nameedef{type@#2}{%
    \@nx\leavevmode
    \@xanxcs{gmu@measure#2}%
    \hbox to \@nx\csname
    \@xanxcs{gmu@#2wd@name}\@nx\endcsname
    {\gmuIfValueTF{#3}{\@nx#3}{\@xanxcs{#2}}%
      \@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
% ^^V   \hyphenchar\font=\gmv@storedhyphenchar % |\hyphenchar| behaves
% like |\hyphenpenalty| etc.: the last one in a paragraph is in charge
% for entire.
  \egroup
}

% \Define\gm@verb@eol
%\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
% message. We use a~separate \CS 'cause we are not quite positive to
% the forbidden line ends idea. (Although the allowed line ends with
% a~forgotten closing shortverb char caused funny disasters at my
% work a~few times.) Another reason is that \pk{gmdoc} wishes to
% redefine it for its own queer purpose.
%
% However, let's leave my former `permissive' definition under the
% |\verb@eol| name.
%
\begingroup
\obeylines\obeyspaces%
\gdef\verb@eolOK{\obeylines%
\def^^M{ \check@percent}%
}%
\endgroup
% The |\check@percent| macro here is |\provide|d to be |\@empty| but in
% \pk{gmdoc} employed shall it be.
%
% Let us leave (give?) a~user freedom of choice:
\def\verbeolOK{\let\gm@verb@eol\verb@eolOK}
% \changes{v0.74}{06/09/07}{added}
% And back to the main matter,
\def\@sverb#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}% here we make the delimiter to be the
  % macro closing the verbatim group.
}

\def\verbatim@nolig@list{\do\`\do\<\do\>\do\,\do\'\do\-}

\def\do@noligs#1{%
  \catcode`#1\active
  \begingroup
  \lccode`\~=`#1\relax
  \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1}}}

% 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{\gmu@ifstar{\MakeShortVerb*\|}{\MakeShortVerb\|}}
\def\olddekclubs{\OldMakeShortVerb\|}

% But even if a~shortverb is unconditional, the spaces in the math
% mode are not printed. So,
%\Define\edverbs
% \changes{v0.79}{2007/01/01}{added}
% \changes{v0.80}{2007/02/27}{debugged, i.e. \cs{hbox} added back and
% redefinition of \cs{[}}%^^A]
\newcommand*\edverbs{%
  \let\gmv@dismath\[%
  \let\gmv@edismath\]%
  \def\[{%^^A\]
    \@ifnextac\gmv@disverb\gmv@dismath}%
  \relaxen\edverbs}%

\def\gmv@disverb{%
  \gmv@dismath%
  \hbox\bgroup\def\]{\egroup\gmv@edismath}%
}

%\subdivision{\pk{doc}- and \pk{shortvrb}-compatibility}
%
% One of minor errors while \TeX ing \pk{doc.dtx} was caused by my
% understanding of a~`shortverb' char:  at my settings, in the math
% mode an active `shortverb' char expands to itself's `other' version
% 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\OldMakeShortVerb
\pdef\OldMakeShortVerb{\MakeShortVerb $$}%
%

% \subdivision{Grey visible spaces}
% In August 2008 Will Robertson suggested grey spaces for
% \pk{gmdoc}. I~added a~respective option to that package but I~like
% 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 recognise possible redefinition of
% it when \pk{xltxtra} is loaded.

\let\gmd@preambleABD\AtBeginDocument
\AtBeginDocument{\let\gmd@preambleABD\firstofone}

\RequirePackage{xcolor}% for \cs{providecolor}

\def\VisSpacesGrey{% \changes{v0.88}{2008/08/11}{added, or rather
  % moved here from \pk{gmdoc}}
  \providecolor{visspacesgrey}{gray}{0.5}%
  \gmd@preambleABD{%
    \edef\visiblespace{%
      \hbox{\@nx\textcolor{visspacesgrey}%
        {\@xa\unexpanded\@xa{\visiblespace}}}}%
  }}

% \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{%%
  \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
  \gmuIfValueT{#4}{%
    \catcode`#4=3
    \protected\@namedef{#4}{#4}}%
  \gmuIfValueT{#5}{%
    \begingroup
    \lccode`\~=`#5\lowercase{\endgroup\let~\metachar}%
    \protected\@namedef{#5}{#5}%
    \catcode`#5=\active
  }% of if value |#5|.
  \gmuPutIfValue{#6}%
}

\pdef\noverbatimspecials{\let\verbatim@specials@list\@undefined}

\def\GMverbatimspecials{%
  \gmu@ifCSdefined {\XeTeXversion}% ^^A \begingroup \let\do\@makeother
                                % ^^A \do\⁄ \do\« \do\» \do\¿ \do\›
  {\verbatimspecials
    ⁄% escape
    «»% |\bgroup| and |\egroup|
    [¿]% math shift
    [›]% meta-char
    {\def\|{\metachar{$\vert$}}%
      % ^^A    \hyphenchar\font=\gmv@hyphenchar
      \makestarlow
      \relaxen\‘% to provide a~\CS\ separator (space is not \cat 10 in
                % verbatims).
      \let\›\string
    }% of |#6|.
  }%
  {}% ^^A \endgroup
}% 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|\ |.
      \gmu@ifxany\ {#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}{¦}

\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}

\def\gmu@tempa{%
  \DeclareCommand\verbLongDashes{
    >iT{–}% to memorise which dash we set
    B{1.41} % expansion of en-dash
    >iT{—} % 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

\fi % of if \XeTeX.
%
% Note that we have two “hyphens”: one for places where a line may be
% broken with a comment char and another, provided as |\hyphenchar|,
% for discretionary hyphens at points where correct \TeX\ code cannot
% be broken, such as \CS names.
%
%
%
% \ChangesGeneral
%
% \changes{v0.81}{2007/04/13}{\cs{afterfi} made two-argument (first
% undelimited, the stuff to be put after \cs{fi}, and the other,
% delimited with \cs{fi}, to be discarded}
%
% \changes{v0.83}{2007/11/09}{added a~hook in the active left brace
% definition intended for \pk{gmdoc} automatic detection of
% definitions (in line \protect\ref{gm@lbracehook})}
%
% \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 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}
%
% \changes{v0.89}{2008/08/30}{\cs{dekclubs}, \cs{dekclubs*} and
% \cs{olddekclubs} made more consistent, shorthands for
% \cs{MakeShortVerb}\cmd\|, \cs{MakeShortVerb*}\cmd\| and
% \cs{OldMakeShortVerb}\cmd{\|} respectively.}
%
% \changes{v0.90}{2008/10/08}{some \cs{›(b⁄!|e›)group} changed to
% \cs{›(begin⁄!|end›)group}}
%
%
%
%
\endinput
%%
%% End of file `gmverb.sty'.