From ab01dd7b261bcf433a2a09a7b14e087a0e072214 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 5 Jun 2018 21:52:57 +0200 Subject: [PATCH] A simple module system for maintaining dependencies --- test-ref.tex | 6 +++--- ucw-algo.tex | 2 ++ ucw-labels.tex | 2 ++ ucw-link.tex | 2 ++ ucw-luaofs.tex | 3 +++ ucw-ofs.tex | 5 ++--- ucw-paper.tex | 2 ++ ucw-pdfmeta.tex | 2 ++ ucw-ref.tex | 3 ++- ucw-verb.tex | 2 ++ ucwmac.tex | 16 ++++++++++++++++ 11 files changed, 38 insertions(+), 7 deletions(-) diff --git a/test-ref.tex b/test-ref.tex index cefb5dc..13f9e1c 100644 --- a/test-ref.tex +++ b/test-ref.tex @@ -1,7 +1,7 @@ \input ucwmac.tex -\input ucw-ofs.tex -\input ucw-ref.tex -\input ucw-pdfmeta.tex +\ucwmodule{ofs} +\ucwmodule{ref} +\ucwmodule{pdfmeta} % \clickablefalse diff --git a/ucw-algo.tex b/ucw-algo.tex index 6259fbc..b773396 100644 --- a/ucw-algo.tex +++ b/ucw-algo.tex @@ -2,6 +2,8 @@ % Written by Martin Mares in 2018 and placed into public domain % ------------------------------------------------------------------------- +\ucwdefmodule{algo} + % \algo{name of the algorithm}\algalias{a longer name} % \algin input description % \:step diff --git a/ucw-labels.tex b/ucw-labels.tex index f6730b5..58bf883 100644 --- a/ucw-labels.tex +++ b/ucw-labels.tex @@ -1,5 +1,7 @@ %% Macros for typesetting of labels +\ucwdefmodule{labels} + % Default page parameters. You can change them before calling \setuplabels. \setmargins{0pt} \setuppage diff --git a/ucw-link.tex b/ucw-link.tex index cbe4ec9..58f498f 100644 --- a/ucw-link.tex +++ b/ucw-link.tex @@ -2,6 +2,8 @@ % Written by Martin Mares in 2018 and placed into public domain % ------------------------------------------------------------------------- +\ucwdefmodule{link} + % Should clickable links be produced? \newif\ifclickable \clickabletrue diff --git a/ucw-luaofs.tex b/ucw-luaofs.tex index e21d658..5008bea 100644 --- a/ucw-luaofs.tex +++ b/ucw-luaofs.tex @@ -1,3 +1,6 @@ +\ucwdefmodule{luaofs} +\ucwdefmodule{ofs} + \input luaotfload.sty \input ofs.tex \nofontmessages diff --git a/ucw-ofs.tex b/ucw-ofs.tex index a5b21a7..5fae70d 100644 --- a/ucw-ofs.tex +++ b/ucw-ofs.tex @@ -2,15 +2,14 @@ % Written by Martin Mares in 2010 and placed into public domain % ------------------------------------------------------------------------- +\ucwdefmodule{ofs} + \ifx\OFSversion\undefined \input ofs.tex % \detailfontmessages \nofontmessages \fi -% Finish if either this or ucw-luaofs.tex is loaded -\ifx\setbaselines\undefined\else\endinput\fi - % We extend OFS's default CM family by several fonts: cmb, cmcsc \ofsputfamlist{^^JUCW:} diff --git a/ucw-paper.tex b/ucw-paper.tex index 242ccf2..9b656f0 100644 --- a/ucw-paper.tex +++ b/ucw-paper.tex @@ -1,5 +1,7 @@ %% ISO 216 paper sizes [ABC]{0..10} +\ucwdefmodule{paper} + \defpaper{a0}{840truemm}{1189truemm} \defpaper{a1}{594truemm}{840truemm} \defpaper{a2}{420truemm}{594truemm} diff --git a/ucw-pdfmeta.tex b/ucw-pdfmeta.tex index 4ac2277..31884e1 100644 --- a/ucw-pdfmeta.tex +++ b/ucw-pdfmeta.tex @@ -2,6 +2,8 @@ % Written by Martin Mares in 2018 and placed into public domain % ------------------------------------------------------------------------- +\ucwdefmodule{pdfmeta} + \ifx\directlua\undefined \def\pdfmetainfo#1#2{}% \def\pdfmetaoutline#1#2#3{}% diff --git a/ucw-ref.tex b/ucw-ref.tex index 74143e2..37f3721 100644 --- a/ucw-ref.tex +++ b/ucw-ref.tex @@ -2,7 +2,8 @@ % Written by Martin Mares in 2018 and placed into public domain % ------------------------------------------------------------------------- -\input ucw-link.tex +\ucwdefmodule{ref} +\ucwmodule{link} % We maintain a collection of objects. Each object has: % - type (namespace -- e.g., chapter) diff --git a/ucw-verb.tex b/ucw-verb.tex index ab89518..33a0ee3 100644 --- a/ucw-verb.tex +++ b/ucw-verb.tex @@ -2,6 +2,8 @@ % Written by Martin Mares in 2010 and placed into public domain % ------------------------------------------------------------------------- +\ucwdefmodule{verb} + % We'll use internal macros of plain TeX \catcode`@=11 diff --git a/ucwmac.tex b/ucwmac.tex index 5dd13f2..bbee36d 100644 --- a/ucwmac.tex +++ b/ucwmac.tex @@ -2,6 +2,8 @@ % Written by Martin Mares in 2010--2018 and placed into public domain % ------------------------------------------------------------------------------- +\ifx\ucwmodule\undefined\else\endinput\fi + %%% Prolog %%% % We'll use internal macros of plain TeX @@ -311,6 +313,20 @@ \fi } +%%% Modules %%% + +\def\ucwmodule#1{ + \ifcsname ucwmod:#1\endcsname + \else + \input ucw-#1.tex + \fi +} + +\def\ucwdefmodule#1{ + \ifcsname ucwmod:#1\endcsname\endinput\fi + \expandafter\let\csname ucwmod:#1\endcsname=\relax +} + %%% Epilog %%% % Let's hide all internal macros -- 2.39.2