commit 14fc068001e2f1ca829fff47a24f8a2e3f84a188
parent cc489217aa978f84372c14c74c55468cdf18f5d9
Author: robert <robertrussell.72001@gmail.com>
Date: Sun, 16 Jan 2022 10:12:44 -0800
Events are global; hooks may be local
\newtoks is always global, so events can not be local without leaking a
tokens register. However, \addhook is already written in a way that
allows \global to work as expected.
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/util.tex b/util.tex
@@ -64,9 +64,11 @@
% \event[myevent]{abc}{xyz}
% produces
% Hello from my 1st hook! (#1 = abc)Hello from my 2nd hook! (#2 = xyz)
+% Events are always defined globally, but hooks can be local (the default) or
+% global (prefix \addhook with \global).
\protected\def\defevent#1[#2]{%
\toksA={#1}% Double hashes
- \ecsdef{event:#2}{\def\noexpand\@hooks\the\toksA}%
+ \xcsdef{event:#2}{\def\noexpand\@hooks\the\toksA}%
\ea\newtoks\begcs hooks:#2\endcs \cs{hooks:#2}={}%
}
\protected\def\event[#1]{%