summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/everyhook/everyhook.sty
blob: 6f546801a64305dc411d7fd10545263d2f3a88e1 (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
%%
%% This is file `everyhook.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% everyhook.dtx  (with options: `package')
%% Copyright (C) 2010 by Stephen Checkoway
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%% 
%% http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status 'maintained'.
%% 
%% The Current Maintainer of this work is Stephen Checkoway.
%% 
%% This work consists of everyhook.dtx and the derived file
%% everyhook.sty.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\RequirePackage{svn-prov}
\ProvidesPackageSVN
{$Id: everyhook.dtx 9 2010-09-27 07:39:15Z steve $}
[v1.0 \revinfo\ Hooks for low level TeX everyX primitives.]
\RequirePackage{etoolbox}
\def\eh@definehook#1#2{%
\cslet{eh@every#1}#2%
\newtoks#2%
#2\csuse{eh@every#1}%
\csdef{eh@pre#1}{}%
\csdef{eh@post#1}{}%
\csuse{eh@every#1}\expandafter{\csname eh@pre#1\expandafter\endcsname
\expandafter\the\expandafter\expandafter\expandafter#2%
\csname eh@post#1\endcsname}%
}
\eh@definehook{par}\everypar
\eh@definehook{math}\frozen@everymath
\eh@definehook{display}\frozen@everydisplay
\eh@definehook{hbox}\everyhbox
\eh@definehook{vbox}\everyvbox
\eh@definehook{cr}\everycr
\undef\eh@definehook
\def\eh@hookseparator{}
\def\eh@checkhook#1#2{%
\ifcsdef{eh@every#1}{}{\PackageError{everyhook}{Argument #1 to
\protect#2\space is invalid}{There is no hook for
\protect\every#1.}}%
}
\def\eh@checkhooknotempty#1#2#3{%
\eh@checkhook{#2}#3%
\ifcsempty{eh@#1#2}{\PackageError{everyhook}{The #1 hook for
\protect\every#2\space is empty}{I have seen too many
\protect#3{#2}s.}{}}%
}
\newrobustcmd\PushPreHook[2]{%
\eh@checkhook{#1}\PushPreHook
\def\eh@tempi{#2}%
\letcs\eh@tempii{eh@pre#1}%
\expandafter\gdef\csname eh@pre#1\expandafter\expandafter
\expandafter\endcsname\expandafter\expandafter
\expandafter{\expandafter\eh@tempi\expandafter
             \eh@hookseparator\eh@tempii}%
\undef\eh@tempi
\undef\eh@tempii
}
\newrobustcmd\PopPreHook[1]{%
\eh@checkhooknotempty{pre}{#1}\PopPreHook
\expandafter\eh@popprehook\csname eh@pre#1\expandafter
\expandafter\expandafter\endcsname
\csname eh@pre#1\endcsname\eh@hookend
}
\def\eh@popprehook#1#2\eh@hookseparator#3\eh@hookend{\gdef#1{#3}}
\newrobustcmd\PushPostHook[2]{%
\eh@checkhook{#1}\PushPostHook
\letcs\eh@tempi{eh@post#1}%
\expandafter\gdef\csname eh@post#1\expandafter\endcsname
\expandafter{\eh@tempi\eh@hookseparator#2}%
\undef\eh@tempi
}
\newrobustcmd\PopPostHook[1]{%
\eh@checkhooknotempty{post}{#1}\PopPostHook
\letcs\eh@tempi{eh@post#1}%
\expandafter\eh@popposthook\csname eh@post#1\expandafter
\endcsname\expandafter{\expandafter}\eh@tempi
\eh@hookend\eh@hookseparator\eh@sentinel\eh@hookend
\undef\eh@tempi
}
\def\eh@popposthook#1#2\eh@hookseparator#3\eh@hookseparator#4\eh@hookend{%
\def\eh@tempi{#4}%
\ifdefequal\eh@sentinel\eh@tempi%
{\gdef#1{#2}\undef\eh@tempi}%
{\eh@popposthook#1{#2\eh@hookseparator#3}\eh@hookseparator#4\eh@hookend}%
}
\def\eh@sentinel{\eh@sentinel}
\newrobustcmd\ClearPreHook[1]{%
\eh@checkhook{#1}\ClearPreHook
\global\csdef{eh@pre#1}{}%
}
\newrobustcmd\ClearPostHook[1]{%
\eh@checkhook{#1}\ClearPostHook
\global\csdef{eh@post#1}{}%
}
\newrobustcmd\SavePreHook[2]{%
\eh@checkhook{#1}\SavePreHook
\letcs#2{eh@pre#1}%
}
\newrobustcmd\SavePostHook[2]{%
\eh@checkhook{#1}\SavePostHook
\letcs#2{eh@post#1}%
}
\newrobustcmd\RestorePreHook[2]{%
\eh@checkhook{#1}\RestorePreHook
\global\cslet{eh@pre#1}#2%
}
\newrobustcmd\RestorePostHook[2]{%
\eh@checkhook{#1}\RestorePostHook
\global\cslet{eh@post#1}#2%
}
\endinput
%%
%% End of file `everyhook.sty'.