How about the following change?
\def\includeonly#1{%
\@partswtrue
\edef\@partlist{\zap@space#1 \@empty}}
\@onlypreamble\includeonly
to be changed into
\def\includeonly{\@ifnextchar[\@nestedincludeonly
\@ordinaryincludeonly}
\def\@nestedincludeonly[#1]#2{\ifx\@nodocument\relax
\else
\def\jobname{#1}%
\@ordinaryincludeonly{#2}%
\def\next{\input{\jobname}}%
\expandafter\expandafter\expandafter\next
\expandafter\endinput
\fi}
\def\@ordinaryincludeonly#1{%
\@partswtrue
\edef\@partlist{\zap@space#1 \@empty}}
\@onlypreamble\@ordinaryincludeonly
That would mean that I could start an included file chapter2.tex
with
\includeonly[mainfile]{chapter2}
and compilation of chapter2.tex would then instead compile mainfile
with \includeonly{chapter2} active.
Something like that. This would make working with \includeonly a lot
more convenient.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum