summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/minim/minim-hooks.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-06-10 03:01:49 +0000
committerNorbert Preining <norbert@preining.info>2021-06-10 03:01:49 +0000
commit2bd77f5a4d02b0d1649589aa7a548e79b198f6af (patch)
tree04786bcca2c349d0cb1373335978e03bb117df7b /macros/luatex/generic/minim/minim-hooks.tex
parentf7fc4ad3995d7f6ebbed20c20bf06e3a9176ea04 (diff)
CTAN sync 202106100301
Diffstat (limited to 'macros/luatex/generic/minim/minim-hooks.tex')
-rw-r--r--macros/luatex/generic/minim/minim-hooks.tex56
1 files changed, 56 insertions, 0 deletions
diff --git a/macros/luatex/generic/minim/minim-hooks.tex b/macros/luatex/generic/minim/minim-hooks.tex
new file mode 100644
index 0000000000..b3b8092654
--- /dev/null
+++ b/macros/luatex/generic/minim/minim-hooks.tex
@@ -0,0 +1,56 @@
+
+% The purpose of this module is allowing arbitrary code be run at specific
+% places. I have not yet included it in the manual, because I still am a bit
+% unsure about the details of the implementation.
+%
+% The first thing done here is inserting a callback into \shipout (and
+% tex.shipout) mirroring finish_pdf, allowing last-minute manipulation before
+% the pdf code will be assembled.
+%
+% The second feature is adding things to the beginning of a paragraph without
+% (seemingly) disturbing \everypar, and also adding things to the next
+% paragraph only.
+%
+% Both features are implemented in a way that is repeatable and should coexist
+% peacefully with other packages doing something of the same. But please let me
+% know if you run into any problems.
+
+\ifdefined\minimhooksloaded
+ \message{(skipped)}
+ \expandafter\endinput\fi
+\chardef\minimhooksloaded = \catcode`\:
+\catcode`\: = 11
+
+\input minim-alloc
+
+% 1 the pre_shipout callback
+
+\newbox\minim:shipout:box \let\minim:shipout:orig = \shipout
+\def\minim:shipout:do{\minim:shipout:orig\box\minim:shipout:box}
+\directlua{require('minim-hooks')} \let\shipout\minim:shipout
+
+% 1 invisibly adding to \everypar
+
+\let\minim:everypar = \everypar
+\newtoks\minim:ateverypar
+\newtoks\minim:atnextpar
+\newtoks\everypar \everypar\minim:everypar
+\minim:everypar\expandafter{\expandafter
+ \minim:changeparindent
+ % expansion makes this process repeatable
+ \expandafter\the\everypar
+ \the\minim:ateverypar
+ \minim:atnextpar\expandafter
+ {\expandafter}\the\minim:atnextpar}
+\let\minim:changeparindent = \relax % as of yet unused
+
+% There is no need for the following.
+
+%\let\minim:par = \par
+%\newtoks\minim:aftereverypar
+%\protected\def\par{\ifhmode \unskip
+% \the\minim:aftereverypar \fi \minim:par}
+
+\catcode`\: = \minimhooksloaded
+
+