-
-
Notifications
You must be signed in to change notification settings - Fork 248
/
ltcmdhooks-008.lvt
68 lines (47 loc) · 1.54 KB
/
ltcmdhooks-008.lvt
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
\RequirePackage[enable-debug,check-declarations]{expl3}
\ExplSyntaxOn
\debug_on:n { deprecation }
\ExplSyntaxOff
\input{regression-test}
\START
\typeout{=================================}
\def\foo{foo}
\AddToHook{\foo}{before} \ShowHook{\foo}
\DisableGenericHook{\foo} \ShowHook{\foo}
\AddToHook{\foo}{after} \ShowHook{\foo}
\typeout{=================================}
\def\foo{bar}
\AddToHook{\foo}{before} \ShowHook{\foo}
\NewHook{\foo} \ShowHook{\foo}
\DisableGenericHook{\foo} \ShowHook{\foo}
\typeout{=================================}
\def\foo{baz}
\DisableGenericHook{\foo} \ShowHook{\foo}
\AddToHookNext{\foo}{after} \ShowHook{\foo}
\typeout{=================================}
\def\foo{env/foo/before}
\DisableGenericHook{\foo} \ShowHook{\foo}
\AddToHookNext{\foo}{after} \ShowHook{\foo}
\typeout{=================================}
\def\foo{cmd/test/before}
\DisableGenericHook{\foo} \ShowHook{\foo}
\AddToHook{\foo}{after} \ShowHook{\foo}
\typeout{=================================}
\def\foo{cmd/mycmd/after}
\makeatletter
\def\mycmd{%
\@ifnextchar[{\mycmdaux}{\mycmdaux[]}}
\def\mycmdaux[#1]{\typeout{#1}}
\makeatother
\AddToHook{\foo}[XXX]{\ERROR 1}
\AddToHookNext{\foo}{\ERROR 2}
\ShowHook{\foo}
% This won't work, so we disable...
\DisableGenericHook{\foo}
% ... and try adding even more code nonetheless :)
\AddToHook{\foo}{\ERROR 3}
\ShowHook{\foo}
\ShowCommand\mycmd
% ... and what happens to this?
\UseHook{\foo} % not not execute hook so \ERROR should not happen
\END