Debian Codegraph @

texmf-dist/tex/context/base/mkii/supp-mis.mkii

raw
1 %D \module
2 %D [ file=supp-mis,
3 %D version=2004.10.26, % 1997.01.04,
4 %D title=\CONTEXT\ Support Macros,
5 %D subtitle=Missing (For Generic Use),
6 %D author=Hans Hagen,
7 %D date=\currentdate,
8 %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9 %C
10 %C This module is part of the \CONTEXT\ macro||package and is
11 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12 %C details.
13
14 %D I will clean up this module (a la supp-pdf.tex preamble).
15
16 %D Some support modules are more or less independant. This
17 %D module, which is not part of plain \CONTEXT, provides the
18 %D missing macros and declarations of registers.
19
20 \ifx \undefined \writestatus \else \expandafter \endinput \fi
21
22 %D Because \LATEX\ has no safe package loading mechanism, we
23 %D need to take care of possible interference.
24
25 \def\StartLatexHack % replace this by the one in supp-pdf
26 {\edef\StopLatexHack
27 {\catcode\string`\noexpand/=\the\catcode\string`/
28 \catcode\string`\noexpand-=\the\catcode\string`-
29 \catcode\string`\noexpand:=\the\catcode\string`:
30 \catcode\string`\noexpand;=\the\catcode\string`;
31 \catcode\string`\noexpand"=\the\catcode\string`"
32 \catcode\string`\noexpand<=\the\catcode\string`<
33 \catcode\string`\noexpand>=\the\catcode\string`>
34 \catcode\string`\noexpand`=\the\catcode\string``}%
35 \catcode\string`/=12 \catcode\string`-=12
36 \catcode\string`:=12 \catcode\string`;=12
37 \catcode\string`"=12 \catcode\string`<=12
38 \catcode\string`>=12 \catcode\string``=12 }
39
40 %D This hack is needed especially for \LATEX\ users who use
41 %D the Babel package. The Germans have active \type {"}'s, the
42 %D Poles have \type {/}, while the French have \type {:} and
43 %D \type {;} defines as command (thanks to Daniel Flipo for
44 %D pointing that out and testing). Potentially active \type
45 %D {?}'s and \type {!}'s are less dangerous since they are
46 %D handled by the \type {\protect} and \type {\unprotect}
47 %D macros.
48
49 \StartLatexHack
50
51 %D \macros
52 %D {ifnocontextobject}
53 %D
54 %D First we take care of redundant defining. The next set of
55 %D macros are a bit complicated by the fact that Plain
56 %D \TEX\ defines the \type{\new}||macros as being outer.
57 %D Furthermore nested \type{\if}'s can get us into
58 %D trouble.
59
60 \def\definecontextobject
61 {\iftrue}
62
63 \def\gobblecontextobject
64 {\setbox0\hbox
65 \bgroup
66 \long\def\gobblecontextobject##1\fi{\egroup}%
67 \expandafter\gobblecontextobject\string}
68
69 \long\def\ifnocontextobject#1\do
70 {\ifx#1\undefined
71 \expandafter\definecontextobject
72 \else
73 %\writestatus{system}{beware of conflicting \string#1}%
74 \expandafter\gobblecontextobject
75 \fi}
76
77 %D \macros
78 %D {beginETEX,beginTEX}
79 %D
80 %D Outside \CONTEXT\ we will not be \ETEX||aware.
81
82 \long\def\beginETEX #1\endETEX {}
83
84 \let\beginTEX\relax \let\endTEX\relax
85
86 %D \macros
87 %D {writestatus}
88 %D
89 %D We start each module with a message. Normally the output is
90 %D formatted, but here we keep things simple.
91
92 \ifnocontextobject \writestatus \do
93
94 \def\writestatus#1#2{\immediate\write16{#1 : #2}}
95
96 \fi
97
98 %D Let's see if it works.
99
100 \writestatus{loading}{ConTeXt Support Macros / Miscellaneous (2004.10.26)}
101
102 %D \macros
103 %D {protect,unprotect}
104 %D
105 %D Next we present a poor mans alternative for \type{\protect}
106 %D and \type{\unprotect}, two commands that enable us to use
107 %D the characters \type{@}, \type{!} and \type{?} in macro
108 %D names.
109
110 \ifnocontextobject \protect \do
111
112 \let\protect\relax
113
114 \fi
115
116 \newcount\protectiondepth
117
118 \ifnocontextobject \unprotect \do
119
120 \def\unprotect
121 {\advance\protectiondepth 1
122 \ifnum\protectiondepth=1
123 \let\normalprotect=\protect
124 \def\protect
125 {\ifnum\protectiondepth>0
126 \advance\protectiondepth -1
127 \ifnum\protectiondepth=0
128 \doprotect
129 \let\protect=\normalprotect
130 \fi
131 \fi}
132 \edef\doprotect
133 {\catcode`\noexpand @=\the\catcode`@\relax
134 \catcode`\noexpand !=\the\catcode`!\relax
135 \catcode`\noexpand ?=\the\catcode`?\relax}
136 \catcode`@=11
137 \catcode`!=11
138 \catcode`?=11
139 \fi}
140
141 \fi
142
143 %D We start using this one it at once.
144
145 \unprotect
146
147 %D \macros
148 %D {scratch...,if...,next...}
149 %D
150 %D We need some scratch registers. Users are free to use them,
151 %D but can never be sure of their value once another macro is
152 %D called. We only allocate things when they are yet
153 %D undefined. This way we can't mess up other macro packages,
154 %D but of course previous definitions can mess up our modules.
155
156 \ifnocontextobject \donetrue \do \newif\ifdone \fi
157
158 % no time now, will do a better test later (based on dimendef)
159
160 \def\!!stringa{plain} \ifx\!!stringa\fmtname \donetrue \else
161 \def\!!stringa{eplain} \ifx\!!stringa\fmtname \donetrue \else
162 \def\!!stringa{babel-plain} \ifx\!!stringa\fmtname \donetrue \else
163 \donefalse \fi \fi \fi
164
165 \ifdone
166 % plain defines some 15 dimens, so we need to define a few
167 % dummies in order to get out of the scratch area
168 \newdimen\scratchdimen % 16
169 \newdimen\scratchdimen % 17
170 \newdimen\scratchdimen % 18
171 \newdimen\scratchdimen % 19
172 \newdimen\scratchdimen % 20
173 \newdimen\scratchdimen % 21
174 \fi
175
176 \def\stripnewabove#1%
177 {\ifnum10<9#1 #1\else\expandafter\stripnewabove\fi}%
178
179 \def\newabove\csname#1\endcsname#2% \dimen \name
180 {\csname#1\endcsname#2%
181 \ifnum\expandafter\stripnewabove\meaning#2>20\else
182 \newabove\csname#1\endcsname#2%
183 \fi}
184
185 \ifnocontextobject \scratchcounter \do \newabove \csname newcount\endcsname \scratchcounter \fi
186 \ifnocontextobject \scratchtoks \do \newabove \csname newtoks\endcsname \scratchtoks \fi
187 \ifnocontextobject \scratchdimen \do \newabove \csname newdimen\endcsname \scratchdimen \fi
188 \ifnocontextobject \scratchskip \do \newabove \csname newskip\endcsname \scratchskip \fi
189 \ifnocontextobject \scratchmuskip \do \newabove \csname newmuskip\endcsname \scratchmuskip \fi
190 \ifnocontextobject \scratchbox \do \csname newbox\endcsname \scratchbox \fi
191 \ifnocontextobject \scratchread \do \csname newread\endcsname \scratchread \fi
192 \ifnocontextobject \scratchwrite \do \csname newwrite\endcsname \scratchwrite \fi
193
194 %D Watch out, in the past we ran into troubles with \type {\onepoint}
195 %D (and others) mening something different in \LATEX\ then here. In
196 %D such situations clashes are bound to happen. For this reason the
197 %D assignments are no inside the test. We try to catch those situations
198 %D but we cannot keep ahead of the future.
199
200 \ifnocontextobject \zeropoint \do \newdimen \zeropoint \zeropoint = 0pt \fi % else problems with dimen12
201 \ifnocontextobject \onepoint \do \newdimen \onepoint \onepoint = 1pt \fi
202 \ifnocontextobject \onebasepoint \do \newdimen \onebasepoint \onebasepoint = 1bp \fi
203 \ifnocontextobject \zerocount \do \chardef \zerocount = 0 \fi
204 \ifnocontextobject \plusone \do \chardef \plusone = 1 \fi
205 \ifnocontextobject \minusone \do \newcount \minusone \minusone = -1 \fi
206 \ifnocontextobject \thousandpoint \do \newdimen \thousandpoint \thousandpoint = 1000pt \fi
207 \ifnocontextobject \onerealpoint \do \newdimen \onerealpoint \onerealpoint = 1pt \fi % latex has a funny \onepoint
208
209 \ifnocontextobject \emptytoks \do \newtoks \emptytoks \fi
210 \ifnocontextobject \nextbox \do \newbox \nextbox \fi
211 \ifnocontextobject \nextdepth \do \newdimen \nextdepth \fi
212
213 \ifnocontextobject \CONTEXTtrue \do \newif\ifCONTEXT \fi
214 \ifnocontextobject \eightbitcharacterstrue \do \newif\ifeightbitcharacters \fi
215 \ifnocontextobject \MPdrawingdonetrue \do \newif\ifMPdrawingdone \fi
216
217 \ifnocontextobject \ifzeropt \do \let\ifzeropt\ifcase \fi
218
219 %D \macros
220 %D {@@...}
221 %D
222 %D We use symbolic name for \CATCODES. They can only be used
223 %D when we are in unprotected state.
224
225 \ifnocontextobject \@@escape \do \chardef\@@escape = 0 \fi
226 \ifnocontextobject \@@begingroup \do \chardef\@@begingroup = 1 \fi
227 \ifnocontextobject \@@endgroup \do \chardef\@@endgroup = 2 \fi
228 \ifnocontextobject \@@endofline \do \chardef\@@endofline = 5 \fi
229 \ifnocontextobject \@@ignore \do \chardef\@@ignore = 9 \fi
230 \ifnocontextobject \@@space \do \chardef\@@space = 10 \fi
231 \ifnocontextobject \@@letter \do \chardef\@@letter = 11 \fi
232 \ifnocontextobject \@@other \do \chardef\@@other = 12 \fi
233 \ifnocontextobject \@@active \do \chardef\@@active = 13 \fi
234 \ifnocontextobject \@@comment \do \chardef\@@comment = 14 \fi
235
236 \def\s!sp{sp}
237 \def\s!pt{pt}
238 \def\s!bp{bp}
239
240 %D \macros
241 %D {@EA,expanded,expandoneargafter,expandtwoargsafter}
242 %D
243 %D Also needed:
244
245 \let\@EA=\expandafter \let\@@expanded\empty
246
247 \def\expanded#1%
248 {\long\xdef\@@expanded{\noexpand#1}\@@expanded}
249
250 \def\expandoneargafter#1#2%
251 {\@EA#1\@EA{#2}}
252
253 \def\expandtwoargsafter#1#2#3%
254 {\@EA\@EA\@EA#1\@EA\@EA\@EA{\@EA#2\@EA}\@EA{#3}}
255
256 \def\@EAEAEA{\@EA\@EA\@EA}
257
258 %D \macros
259 %D {everyline,EveryLine,EveryPar}
260 %D
261 %D In \CONTEXT\ we use \type{\everypar} for special purposes
262 %D and provide \type{\EveryPar} as an alternative. The same
263 %D goes for \type{\everyline} and \type{\EveryLine}.
264
265 \ifnocontextobject \everyline \do \newtoks\everyline \fi
266 \ifnocontextobject \EveryPar \do \let\EveryPar =\everypar \fi
267 \ifnocontextobject \EveryLine \do \let\EveryLine=\everyline \fi
268
269 %D \macros
270 %D {globallet}
271
272 \def\globallet{\global\let}
273
274 %D \macros
275 %D {!!...}
276 %D
277 %D We reserve ourselves some scratch strings (i.e. macros)
278 %D and some more counters.
279
280 \ifnocontextobject \!!stringa \do \def\!!stringa {} \fi
281 \ifnocontextobject \!!stringb \do \def\!!stringb {} \fi
282 \ifnocontextobject \!!stringc \do \def\!!stringc {} \fi
283 \ifnocontextobject \!!stringd \do \def\!!stringd {} \fi
284
285 \ifnocontextobject \!!counta \do \newcount\!!counta {} \fi
286 \ifnocontextobject \!!countb \do \newcount\!!countb {} \fi
287
288 %D \macros
289 %D {!!...}
290 %D
291 %D The next set of definitions speed up processing a bit.
292 %D Furthermore it saves memory.
293
294 \ifnocontextobject \!!zeropoint \do \def\!!zeropoint {0pt} \fi
295 \ifnocontextobject \!!zerocount \do \def\!!zerocount {0} \fi
296 \ifnocontextobject \!!tenthousand \do \def\!!tenthousand {10000} \fi
297
298 \ifnocontextobject \!!width \do \def\!!width {width} \fi
299 \ifnocontextobject \!!height \do \def\!!height {height} \fi
300 \ifnocontextobject \!!depth \do \def\!!depth {depth} \fi
301
302 \ifnocontextobject \!!plus \do \def\!!plus {plus} \fi
303 \ifnocontextobject \!!minus \do \def\!!minus {minus} \fi
304 \ifnocontextobject \!!to \do \def\!!to {to} \fi
305
306 %D \macros
307 %D {smashbox}
308 %D
309 %D The system modules offer a range of smashing macros, of
310 %D which we only copied \type{\smashbox}.
311
312 \ifnocontextobject \smashbox \do
313
314 \def\smashbox#1%
315 {\wd#1\zeropoint
316 \ht#1\zeropoint
317 \dp#1\zeropoint}
318
319 \fi
320
321 %D \macros
322 %D {dowithnextbox}
323 %D
324 %D Also without further comment, we introduce a macro that
325 %D gets the next box and does something usefull with it.
326 %D Because the \type{\afterassignment} is executed inside the
327 %D box, we have to use a \type{\aftergroup} too.
328
329 \ifnocontextobject \dowithnextbox \do
330
331 \def\dowithnextbox#1%
332 {\def\dodowithnextbox{#1}%
333 \afterassignment\dododowithnextbox
334 \setbox\nextbox}
335
336 \def\dododowithnextbox%
337 {\aftergroup\dodowithnextbox}
338
339 \fi
340
341 %D \macros
342 %D {setvalue,setevalue,setxvalue,,setgvalue,
343 %D getvalue,
344 %D letvalue,letgvalue}
345 %D
346 %D The next two macros expand their argument to
347 %D \type{\argument}. The first one is used to define macro's
348 %D the second one executes them.
349
350 \ifnocontextobject \setvalue \do
351
352 \def\setvalue #1{\expandafter\def\csname#1\endcsname}
353 \def\setevalue#1{\expandafter\edef\csname#1\endcsname}
354 \def\setgvalue#1{\expandafter\gdef\csname#1\endcsname}
355 \def\setxvalue#1{\expandafter\xdef\csname#1\endcsname}
356 \def\getvalue #1{\csname#1\endcsname}
357 \def\letvalue #1{\expandafter\let\csname#1\endcsname}
358 \def\letgvalue#1{\global\expandafter\let\csname#1\endcsname}
359 \fi
360
361 %D \macros
362 %D {unexpanded}
363 %D
364 %D The next command can be used as prefixed for commands that
365 %D need protection during tests and writing to files. This
366 %D is a very \CONTEXT\ specific one.
367
368 \ifnocontextobject \unexpanded \do
369
370 \let\unexpanded\relax
371
372 \fi
373
374 %D \macros
375 %D {convertargument}
376 %D
377 %D The original one offers a bit more, like global assignment, the
378 %D the next implementation is however a bit more byte saving.
379
380 \ifnocontextobject \convertargument \do
381
382 \def\doconvertargument#1>{}
383
384 \long\def\convertargument#1\to#2%
385 {\long\def\@@convertedargument{#1}%
386 \edef#2{\expandafter\doconvertargument\meaning\@@convertedargument}}
387
388 \fi
389
390 %D \macros
391 %D {forgetall}
392 %D
393 %D Sometimes we have to disable interference of whatever kind
394 %D of skips and mechanisms. The next macro resets some.
395
396 \ifnocontextobject \forgetall \do
397
398 \def\forgetall
399 {\parskip\zeropoint
400 \leftskip\zeropoint
401 \parindent\zeropoint
402 \everypar{}}
403
404 \fi
405
406 %D \macros
407 %D {withoutpt,
408 %D ScaledPointsToBigPoints,ScaledPointsToWholeBigPoints}
409 %D
410 %D \TEX\ lacks some real datastructure. We can however use
411 %D \DIMENSIONS. This kind of trickery is needed when we want
412 %D \TEX\ to communicate with the outside world (by means of
413 %D \type{\specials}).
414
415 \ifnocontextobject \withoutpt \do
416
417 {\catcode`\.=\@@other
418 \catcode`\p=\@@other
419 \catcode`\t=\@@other
420 \gdef\WITHOUTPT#1pt{#1}}
421
422 \def\withoutpt#1%
423 {\expandafter\WITHOUTPT#1}
424
425 \def\ScaledPointsToBigPoints#1#2%
426 {\scratchdimen=#1sp\relax
427 \scratchdimen=.996264\scratchdimen
428 \edef#2{\withoutpt{\the\scratchdimen}}}
429
430 \def\ScaledPointsToWholeBigPoints#1#2%
431 {\scratchdimen=#1sp
432 \scratchdimen=.996264\scratchdimen
433 \scratchcounter=\scratchdimen
434 \advance\scratchcounter by 32768
435 \divide\scratchcounter by 65536
436 \edef#2{\the\scratchcounter}}
437
438 \fi
439
440 %D \macros
441 %D {doprocessfile}
442 %D
443 %D This macro takes three arguments: the file number, the
444 %D filename and a macro that handles the content of a read
445 %D line.
446
447 \newif\iffileprocessed
448
449 \ifnocontextobject \doprocessfile \do
450
451 \def\doprocessfile#1#2#3%
452 {\openin#1=#2\relax
453 \ifeof#1%
454 \fileprocessedfalse
455 \closein#1\relax
456 \else
457 \fileprocessedtrue
458 \gdef\dofinishfile%
459 {\closein#1\relax
460 \global\let\doprocessline\relax}%
461 \gdef\doprocessline%
462 {\ifeof#1%
463 \dofinishfile
464 \else
465 \global\read#1 to \fileline
466 #3\relax
467 \expandafter\doprocessline
468 \fi}%
469 \expandafter\doprocessline
470 \fi}
471
472 \fi
473
474 %D \macros
475 %D {uncatcodespecials}
476 %D
477 %D This one is taken from the \TEX\ book. The \CONTEXT\
478 %D alternative is a bit different, but we hope this one works
479 %D here.
480
481 \ifx\dospecials\undefined
482
483 \def\dospecials
484 {\do\ \do\\\do\{\do\}\do\$%
485 \do\#\do\^\do\_\do\&\do\%%
486 \do\~\do\^^A\do\^^K}
487
488 \fi
489
490 \ifnocontextobject \uncatcodespecials \do
491
492 \def\uncatcodespecials
493 {\def\do##1{\catcode`##1=12 }\dospecials
494 \catcode`\ =\@@space
495 \catcode`\^^L=\@@ignore
496 \catcode`\^^M=\@@endofline
497 \catcode`\^^?=\@@ignore}
498
499 \fi
500
501 \ifnocontextobject \setnaturalcatcodes \do
502
503 \def\setnaturalcatcodes
504 {\catcode`\!=\@@other \catcode`\?=\@@other \catcode`\@=\@@other
505 \catcode`\#=\@@other \catcode`\&=\@@other \catcode`\|=\@@other
506 \catcode`\$=\@@other \catcode`\^=\@@other \catcode`\_=\@@other
507 \catcode`\*=\@@other \catcode`\/=\@@other
508 \catcode`\-=\@@other \catcode`+=\@@other
509 \catcode`\==\@@other \catcode`\<=\@@other \catcode`\>=\@@other
510 \catcode`\"=\@@other \catcode`\'=\@@other \catcode`\`=\@@other
511 \catcode`\:=\@@other \catcode`\;=\@@other
512 \catcode`\,=\@@other \catcode`\.=\@@other \catcode`\~=\@@other
513 \catcode`\(=\@@other \catcode`\)=\@@other
514 \catcode`\{=\@@other \catcode`\}=\@@other
515 \catcode`\\=\@@other \catcode`\%=\@@other }
516
517 \fi
518
519 %D \macros
520 %D {doglobal}
521 %D
522 %D Some \CONTEXT\ low level macros can have a \type{\doglobal}
523 %D prefix. Let's just forget about that here:
524
525 \ifnocontextobject \doglobal \do \let\doglobal\relax \fi
526
527 %D The next obscure one is needed in the generic verbatim
528 %D environment. When we end up with more of these, it's time
529 %D to load the module \type{syst-gen}.
530
531 \ifnocontextobject \doifincsnameelse \do
532
533 \def\dodoifincsnameelse#1#2%
534 {\def\dododoifincsnameelse##1#1##2##3\war%
535 {\csname\if##2@iffalse\else iftrue\fi\endcsname}%
536 \expandafter\dododoifincsnameelse#2#1@@\war}
537
538 \long\def\doifincsnameelse#1#2#3#4%
539 {\edef\@@instring{#1}%
540 \expandafter\dodoifincsnameelse\expandafter{\@@instring}{#2}%
541 #3%
542 \else
543 #4%
544 \fi}
545
546 \fi
547
548 %D \macros
549 %D {dostepwiserecurse, dorecurse, doloop, exitloop}
550 %D
551 %D The next loop macro is a real weak one, and does not offer
552 %D the full \CONTEXT\ functionality, let alone nesting, but
553 %D for simple purposes, its behaviour is acceptable.
554
555 \newcount\recursecounter
556
557 \def\dostepwiserecurse#1#2#3#4% very weak and rubishly version
558 {\ifnum#2<#1\relax\else\dodostepwiserecurse{#1}{#2}{#3}{#4}\fi}
559
560 \def\dodostepwiserecurse#1#2#3#4% very weak and rubishly version
561 {\recursecounter=#1\relax
562 \loop
563 \edef\recurselevel{\the\recursecounter}%
564 #4\relax
565 \ifnum\recursecounter<#2\relax
566 \advance\recursecounter by #3\relax
567 \repeat}
568
569 \def\dorecurse#1%
570 {\dostepwiserecurse{1}{#1}{1}}
571
572 \def\doloop
573 {\dostepwiserecurse{1}{\maxdimen}{1}}
574
575 \def\exitloop
576 {\recursecounter=\maxdimen}
577
578 %D \macros
579 %D {ifundefined,doifdefined,doifundefined,
580 %D doifdefinedelse,doifundefinedelse}
581 %D
582 %D These alteratives are not robust but suitable for simple
583 %D usage. The official ones are a bit faster.
584
585 \ifnocontextobject \doifdefined \do
586
587 \def\ifundefined#1%
588 {\expandafter\ifx\csname#1\endcsname\relax}
589
590 \def\doifdefinedelse#1#2#3%
591 {\expandafter\ifx\csname#1\endcsname\relax#3\else#2\fi}
592
593 \def\doifundefinedelse#1#2#3%
594 {\expandafter\ifx\csname#1\endcsname\relax#2\else#3\fi}
595
596 \def\doifdefined#1#2%
597 {\expandafter\ifx\csname#1\endcsname\relax\else#2\fi}
598
599 \def\doifundefined#1#2%
600 {\expandafter\ifx\csname#1\endcsname\relax#2\fi}
601
602 \fi
603
604 %D \macros
605 %D {doifinstringelse}
606 %D
607 %D It seems like we end up with more and more macros here.
608 %D Sigh.
609
610 \ifnocontextobject \doifinstringelse \do
611
612 \def\p!doifinstringelse#1#2%
613 {\def\pp!doifinstringelse##1#1##2##3\war%
614 {\csname if\if##2@fals\else tru\fi e\endcsname}%
615 \expanded{\pp!doifinstringelse#2#1@@\noexpand\war}}
616
617 \long\def\doifinstringelse#1#2#3#4%
618 {\edef\@@@instring{#1}%
619 \@EA\p!doifinstringelse\@EA{\@@@instring}{#2}#3\else#4\fi}
620
621 \fi
622
623 %D \macros
624 %D {twodigitrounding}
625 %D
626 %D We don't support rounding outside \CONTEXT. Sorry.
627
628 \def\twodigitrounding#1{#1}
629
630 %D \macros
631 %D {lineheight}
632 %D
633 %D In \CONTEXT\ we have \type{\lineheight}, which in many
634 %D cases matches \type {\baselineskip}.
635
636 \ifnocontextobject \lineheight \do
637
638 \def\lineheight{\baselineskip}
639
640 \fi
641
642 %D \macros
643 %D {dohandletokens}
644 %D
645 %D The following macro is the simplified version, but good
646 %D enough for day to day hacks.
647 %D
648 %D \starttyping
649 %D \dohandletokens some text\with\somemacro
650 %D \stoptyping
651
652 \ifnocontextobject \dohandletokens \do
653
654 \def\dodohandletokens
655 {\ifx\next\end \else
656 \docommand{\next}%
657 \expandafter\dohandletokens
658 \fi}
659
660 \def\dohandletokens
661 {\afterassignment\dodohandletokens\let\next= }
662
663 \long\def\handletokens#1\with#2%
664 {\let\docommand=#2%
665 \dohandletokens#1\end}
666
667 \fi
668
669 %D Very reduced:
670
671 \long\def\appendtoks#1\to#2%
672 {\scratchtoks{#1}\expanded{#2{\the#2\the\scratchtoks}}}
673
674 %D Well, also handy.
675
676 \def\doiffileelse#1#2#3%
677 {\immediate\openin\scratchread=#1\relax
678 \ifeof\scratchread
679 \def\next{#3}%
680 \else
681 \def\next{#2}%
682 \fi
683 \immediate\closein\scratchread
684 \next}
685
686 %D New.
687
688 \let\donothing\empty
689
690 %D Also new:
691
692 \def\letempty #1{\let#1\empty}
693 \def\globalletempty#1{\global\let#1\empty}
694
695 \def\letvalueempty #1{\expandafter\let\csname#1\endcsname\empty}
696 \def\letgvalueempty#1{\global\expandafter\let\csname#1\endcsname\empty}
697
698 %D Sigh
699
700 \def\settrue #1{\chardef#1\zerocount}
701 \def\setfalse#1{\chardef#1\plusone}
702
703 \let\newconditional = \setfalse
704 \let\ifconditional = \ifcase
705
706 %D We could load \type {norm-tex} but this takes less hash space:
707
708 \let \normalif = \if
709 \let \normalifcase = \ifcase
710 \let \normalifcat = \ifcat
711 \let \normalifdim = \ifdim
712 \let \normalifeof = \ifeof
713 \let \normaliffalse = \iffalse
714 \let \normalifhbox = \ifhbox
715 \let \normalifhmode = \ifhmode
716 \let \normalifinner = \ifinner
717 \let \normalifmmode = \ifmmode
718 \let \normalifnum = \ifnum
719 \let \normalifodd = \ifodd
720 \let \normaliftrue = \iftrue
721 \let \normalifvbox = \ifvbox
722 \let \normalifvmode = \ifvmode
723 \let \normalifvoid = \ifvoid
724 \let \normalifx = \ifx
725 \let \normalfi = \fi
726 \let \normalelse = \else
727
728 \let \normalunexpanded = \unexpanded % beware the primitive, not the context one
729
730 %D That's it. Please forget this junk and take a look at how
731 %D it should be done.
732
733 \StopLatexHack \protect \endinput