%D \module %D [ file=file-job, % copied from main-001, later core-job %D version=1997.03.31, %D title=\CONTEXT\ Core Macros, %D subtitle=Job Handling, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. %D This module is still to be split and documented. \writestatus{loading}{ConTeXt File Macros / Job Handling} \unprotect \registerctxluafile{file-job}{1.001} % processing \unexpanded\def\doifinputfileelse#name% {\ctxcommand{doifinputfileelse("#name")}} \unexpanded\def\processfile#name% {\ctxcommand{processfile("#name")}} % path control \unexpanded\def\usepath[#path]% {\ctxcommand{usepath("#path")}} \unexpanded\def\usesubpath[#path]% {\ctxcommand{usesubpath("#path")}} \def\allinputpaths {\ctxcommand{allinputpaths()}} % helper (not really needed nowadays) \let\locatedfilepath\empty \unexpanded\def\locatefilepath#name% no [] ? {\edef\locatedfilepath{\ctxcommand{locatefilepath("#name")}}} % zip files are tree'd \unexpanded\def\usezipfile {\dodoubleempty\use_zip_file} \def\use_zip_file[#zipname][#subtree]% {\ctxcommand{usezipfile("#zipname","#subtree")}} % exa stuff might become obsolete: \unexpanded\def\loadexamodes {\dosingleempty\load_exa_modes} \def\load_exa_modes[#name]% {\ctxcommand{loadexamodes("#name")}} % runtime files (maybe also do this in lua?) % \def\doloadsystemfile#1% only mkiv files % {\readfile{sys:///#1.\mksuffix}{\showmessage\m!system2{#1.\mksuffix}}\donothing} \unexpanded\def\loadsystemfiles {\load_system_file\f!newfilename % new code, to be integrated at some point, plus fixes posted on the list \load_system_file\f!locfilename % new code, somewhat experimental, not distributed (outside the dev group) \load_system_file\f!expfilename % new code, very experimental, can be engine specific, mostly for me only \load_system_file\f!sysfilename} % local settings, but probably not that good an idea to use \def\load_system_file#name% only mkiv files {\readsysfile{#name.\mksuffix}{\showmessage\m!system2{#name.\mksuffix}}\donothing} \unexpanded\def\loadoptionfile {\readjobfile{\jobname.\f!optionextension} {\writestatus\m!system{\jobname.\f!optionextension\space loaded}% \ctxcommand{copyfiletolog("\jobname.\f!optionextension")}}% {\writestatus\m!system{no \jobname.\f!optionextension}}} % document structure \ifdefined\textlevel\else \newcount\textlevel \fi % might go away \def\dostarttext {\glet\dostarttext\relax \the\everystarttext \global\everystarttext\emptytoks} \def\dostoptext {\glet\dostoptext\relax \flushfinallayoutpage % optional \page % anyway \the\everystoptext \global\everystoptext\emptytoks \the\everybye \global\everybye\emptytoks \the\everygoodbye \global\everygoodbye\emptytoks \doifsometokselse\everynotabene{\writeline\the\everynotabene\writeline}\donothing \normalend} % tex's \end \unexpanded\def\starttext {\ctxcommand{starttext()}} \unexpanded\def\stoptext {\ctxcommand{stoptext()}} \unexpanded\def\forcequitjob {\ctxcommand{forcequitjob()}} \unexpanded\def\end {\ctxcommand{forceendjob()}} \unexpanded\def\autostarttext{\ctxcommand{autostarttext()}} \unexpanded\def\autostoptext {\ctxcommand{autostoptext()}} % protect structure \unexpanded\def\processfilemany #name{\ctxcommand{processfilemany("#name")}} \unexpanded\def\processfileonce #name{\ctxcommand{processfileonce("#name")}} \unexpanded\def\processfilenone #name{\ctxcommand{processfilenone("#name")}} \unexpanded\def\project {\doifnextoptionalelse\useproject \do_project} \unexpanded\def\product {\doifnextoptionalelse\useproduct \do_product} \unexpanded\def\component {\doifnextoptionalelse\usecomponent \do_component} \unexpanded\def\environment {\doifnextoptionalelse\useenvironment\do_environment} \def\do_project #name {\ctxcommand{useproject ("#name")}} \def\do_product #name {\ctxcommand{useproduct ("#name")}} \def\do_component #name {\ctxcommand{usecomponent ("#name")}} \def\do_environment #name {\ctxcommand{useenvironment("#name")}} \unexpanded\def\startproject {\doifnextoptionalelse\do_startproject \redo_startproject} \unexpanded\def\startproduct {\doifnextoptionalelse\do_startproduct \redo_startproduct} \unexpanded\def\startcomponent {\doifnextoptionalelse\do_startcomponent \redo_startcomponent} \unexpanded\def\startenvironment {\doifnextoptionalelse\do_startenvironment\redo_startenvironment} \def\redo_startproject #name {\ctxcommand{startproject ("#name")}} \def\redo_startproduct #name {\ctxcommand{startproduct ("#name")}} \def\redo_startcomponent #name {\ctxcommand{startcomponent ("#name")}} \def\redo_startenvironment #name {\ctxcommand{startenvironment("#name")}} \unexpanded\def\useproject [#name]{\ctxcommand{useproject ("#name")}} \unexpanded\def\useproduct [#name]{\ctxcommand{useproduct ("#name")}} \unexpanded\def\usecomponent [#name]{\ctxcommand{usecomponent ("#name")}} \unexpanded\def\useenvironment [#name]{\ctxcommand{useenvironment("#name")}} \unexpanded\def\do_startproject [#name]{\ctxcommand{startproject ("#name")}} \unexpanded\def\do_startproduct [#name]{\ctxcommand{startproduct ("#name")}} \unexpanded\def\do_startcomponent [#name]{\ctxcommand{startcomponent ("#name")}} \unexpanded\def\do_startenvironment[#name]{\ctxcommand{startenvironment("#name")}} \newconditional\endofinput % hack, needed because \endinput happens one level down in the input when we write from lua \unexpanded\def\signalendofinput#1% argument just for tracing {\global\settrue\endofinput} \unexpanded\def\honorendofinput {\ifconditional\endofinput \global\setfalse\endofinput \endinput \fi} \unexpanded\def\stopproject {\ctxcommand{stopproject ()}\honorendofinput} \unexpanded\def\stopproduct {\ctxcommand{stopproduct ()}\honorendofinput} \unexpanded\def\stopcomponent {\ctxcommand{stopcomponent ()}\honorendofinput} \unexpanded\def\stopenvironment {\ctxcommand{stopenvironment()}\honorendofinput} \def\currentproject {\ctxcommand{currentproject ()}} \def\currentproduct {\ctxcommand{currentproduct ()}} \def\currentcomponent {\ctxcommand{currentcomponent ()}} \def\currentenvironment {\ctxcommand{currentenvironment()}} \unexpanded\def\dostarttextfile #name{\ctxcommand{dostarttextfile(name)}} \unexpanded\def\dostoptextfile {\ctxcommand{dostoptextfile()}} \def\processedfile {\ctxcommand{processedfile()}} \def\processedfiles {\ctxcommand{processedfiles()}} \unexpanded\def\loadtexfile [#name]{\cxtcommand{usetexfile("#name")}} \unexpanded\def\loadluafile [#name]{\ctxcommand{useluafile("#name")}} \unexpanded\def\loadcldfile [#name]{\ctxcommand{usecldfile("#name")}} \unexpanded\def\loadanyfile [#name]{\ctxcommand{useanyfile("#name")}} \unexpanded\def\loadtexfileonce [#name]{\cxtcommand{usetexfile("#name",true)}} \unexpanded\def\loadluafileonce [#name]{\ctxcommand{useluafile("#name",true)}} \unexpanded\def\loadcldfileonce [#name]{\ctxcommand{usecldfile("#name",true)}} \unexpanded\def\loadanyfileonce [#name]{\ctxcommand{useanyfile("#name",true)}} %D Handy for modules that have a test/demo appended. \def\continueifinputfile#name{\doifnot\inputfilename{#name}\endinput} %def\processifinputfile #name{\doif \inputfilename{#name}} % \startproject test % 1: \startmode[*project] project \stopmode \endgraf % 2: \startmode[*product] product \stopmode \endgraf % \stopproject % replaced by modes: % % \setvalue{\e!start\v!localenvironment}[#1]% % {\let\loadedlocalenvironments\empty % \def\docommand##1% % {\beforesplitstring##1\at.\to\someevironment % \addtocommalist\someevironment\loadedlocalenvironments}% % \processcommalist[#1]\docommand % \doifcommonelse{\currentproject,\currentproduct,\currentcomponent,\currentenvironment}\loadedlocalenvironments % {\letvalue{\e!stop\v!localenvironment}\relax} % {\grabuntil{\e!stop\v!localenvironment}\gobbleoneargument}} % % \setvalue{\v!localenvironment}{\doifnextoptionalelse\uselocalenvironment\redolocalenvironment} % % \def\redolocalenvironment#1 {\uselocalenvironment[#1]} % \def\uselocalenvironment[#1]{\doexecutefileonce{#1}} % weird place: \neverypar\emptytoks %D Wrappers (the signal is a synchronization with lua hack): \newsystemmode\v!project \newsystemmode\v!product \newsystemmode\v!component \newsystemmode\v!environment \def\startprojectindeed {\starttext \pushsystemmode\v!project \setsystemmode\v!project} \def\stopprojectindeed {\popsystemmode\v!project \stoptext \signalendofinput\v!project} \def\startproductindeed {\starttext \pushsystemmode\v!product \setsystemmode\v!product} \def\stopproductindeed {\popsystemmode\v!product \stoptext \signalendofinput\v!product} \def\startcomponentindeed {\starttext \pushreferenceprefix\currentcomponent \pushsystemmode\v!component \setsystemmode\v!component} \def\stopcomponentindeed {\popsystemmode\v!component \popreferenceprefix \stoptext \signalendofinput\v!component} \def\startenvironmentindeed {\pushsystemmode\v!environment \setsystemmode\v!environment} \def\stopenvironmentindeed {\popsystemmode\v!environment \signalendofinput\v!environment} %D Relatively new (might move as it depends on setups): \newtoks\everysetupdocument \unexpanded\def\startdocument % todo: dostarttagged\t!document {\dosingleargument\start_document} \unexpanded\def\start_document[#settings]% {\setvariables[document][#settings]% \the\everysetupdocument\relax \starttext \documentvariable\c!before} \unexpanded\def\stopdocument % todo: dostoptagged\t!document {\documentvariable\c!after \stoptext} \def\documentvariable#name% {\getvariable{document}{#name}} \unexpanded\def\setupdocument[#1]% {\setvariables[document][#1]% \the\everysetupdocument\relax} \setvariables [document] [\c!before=\directsetup{document:start}, \c!after=\directsetup{document:stop}] %S The document: namespace will be used elsewhere too. \protect \endinput