r3tex

custom LuaTeX format
git clone git://git.rr3.xyz/r3tex
Log | Files | Refs | README | LICENSE

commit 7d254873a82f9530586f61d2130d4b109314a200
parent 2a0afd7e8e5a1ad38a0902f5e424d2295ea06591
Author: robert <robertrussell.72001@gmail.com>
Date:   Fri, 17 Dec 2021 21:41:14 -0800

Remove residual \long's

Diffstat:
Mfont.tex | 38+++++++++++++++++++++-----------------
Mloop.tex | 6+++---
2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/font.tex b/font.tex @@ -11,11 +11,11 @@ An "M font set" is a tuple of three H font sets. (H = horizontal, M = math; we could call H fonts "text fonts", but that is too easily confusable with \textfont.) -\def\rm{\rminit \rmtext \rmmath} +\protected\def\rm{\rminit \rmtext \rmmath} % \eventdef defines an "event", which is a special type of macro. Events may % be treated like regular macros, except that -% - events are always \long and \global, +% - events are always \global, % - the expansion of an event is not simply its body, % - expanding an event in an expansion-only context (like \edef) is unsafe, % - the body of an event may not access tokens after its arguments from the @@ -29,36 +29,40 @@ easily confusable with \textfont.) % \myevent{abc}{xyz} % produces % Hello from my event! (#1 = abc) Hello from my hook! (#2 = xyz) -\newstack\@eventstack -\protected\long\def\eventdef#1#2#{\@eventdef{#1}{#2}} -\long\def\@eventdef#1#2#3{% +\newq\@eventstack +\newtoks\@eventhooks +\protected\def\eventdef#1#2#{\@eventdef{#1}{#2}} +\def\@eventdef#1#2#3{% % We can't refer to the hooks tokens register using a \toksdef'ed control % sequence based on \string#1, because then event aliases created using % \let wouldn't work in \addhook. Instead we "hard-code" the tokens % register number inside the event macro. \newtoks\csA \scantokens{\toksA={#2}}% Double hashes - \long\xdef#1{% + \xdef#1{% % No op. Used by \addhook to get hooks tokens register number. \noexpand\selectx{\number\allocnum}% \pushtok\@eventstack\noexpand\dohooks % Put start of \csB def in \csA, so we can \expandafter over it to % expand the hooks token list. - \def\noexpand\csA{\long\def\noexpand\csB\the\toksA}% + \def\noexpand\csA{\def\noexpand\csB\the\toksA}% \nea\noexpand\csA\nea{% - % Expand the hooks tokens register in a temporary tokens register - % instead of directly in the \dohooks macro so that doubled hashes - % in a hook body produce the more appropriate error of "you can't - % use `macro parameter character #' in horizontal mode" instead of - % "illegal parameter number in definition of \dohooks". - \nea\toksA\nea{\noexpand\the\toks\number\allocnum}% - \edef\noexpand\dohooks{\noexpand\the\toksA}% + % Expand the hooks tokens register in a tokens register instead of + % directly in the \dohooks macro so that doubled hashes in a hook + % body produce the more appropriate error of "you can't use `macro + % parameter character #' in horizontal mode" instead of "illegal + % parameter number in definition of \dohooks". We use an allocated + % register for this purpose, so that temporary registers may be + % used to pass information to the event body. The assignments to + % \@eventhooks and \dohooks are global to reduce save stack usage. + \nea\global\nea\@eventhooks\nea{\noexpand\the\toks\number\allocnum}% + \xdef\noexpand\dohooks{\noexpand\the\@eventhooks}% \unexpanded{#3\relax}% - \poptok\@eventstack \let\noexpand\dohooks\noexpand\ptok + \poptok\@eventstack \glet\noexpand\dohooks\noexpand\qtok }% \noexpand\csB }% } -\protected\long\def\addhook#1#2{\toksapp\ea\@hooknum#1{#2\relax}} -\long\def\@hooknum#1#2#3\csB{#2} +\protected\def\addhook#1#2{\toksapp\ea\@hooknum#1{#2\relax}} +\def\@hooknum#1#2#3\csB{#2} diff --git a/loop.tex b/loop.tex @@ -13,8 +13,8 @@ \newcount\@forcnt \newcount\@forlim \newcount\@forstep -\long\def\fornum#1=#2..#3\do{\fornumstep#1=#2..#3:1\do} -\long\def\fornumstep#1=#2..#3:#4\do#5{% +\def\fornum#1=#2..#3\do{\fornumstep#1=#2..#3:1\do} +\def\fornumstep#1=#2..#3:#4\do#5{% \@forsave \def\@body{\edef#1{\the\@forcnt}#5}% \@forcnt=\numexpr#2\relax @@ -44,7 +44,7 @@ \def\foreach#1\do#2#{\@foreachA{#1}{#2}} \def\@foreachA#1#2#3{% \pushtok\@loopstack\@body - \long\gdef\@body#2{#3\futurelet\@next\@foreachB}% + \gdef\@body#2{#3\futurelet\@next\@foreachB}% \@body#1\@foreachend \poptok\@loopstack \let\@body=\qtok }