Introduce maintain unincluded children "mostly"

This is a mode for includeonly handling that is effective and still outputs
at least mostly correct counters and references. This is intended for non-
final editing work.

File format change.
This commit is contained in:
Juergen Spitzmueller 2020-03-13 15:46:35 +01:00
parent 36208d488e
commit f4af191403
12 changed files with 370 additions and 90 deletions

View File

@ -7,6 +7,11 @@ changes happened in particular if possible. A good example would be
-----------------------
2020-03-13 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 593: Buffer param \maintain_unincluded_children is not longer a bool
(true|false) but has three states: "no" (formerly "false"), "strict" (formerly "true") and
"once" (a new intermediate state).
2020-01-11 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 592: Add tabular column/row tag changed="[added|deleted] id time"
which tracks whether a whole row/column has been inserted/deleted in ct.

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 571
\lyxformat 593
\begin_document
\begin_header
\save_transient_properties true
@ -157,7 +157,7 @@ initials
graphicboxes
varwidth
\end_modules
\maintain_unincluded_children false
\maintain_unincluded_children no
\language english
\language_package default
\inputencoding utf8
@ -169,7 +169,9 @@ varwidth
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_roman_osf false
\font_sans_osf false
\font_typewriter_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
@ -218,6 +220,7 @@ varwidth
\justification true
\use_refstyle 0
\use_minted 0
\use_lineno 0
\notefontcolor #0000ff
\index Index
\shortcut idx
@ -237,6 +240,8 @@ varwidth
\tablestyle default
\tracking_changes true
\output_changes false
\change_bars false
\postpone_fragile_content false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
@ -41274,23 +41279,118 @@ Input
\end_inset
).
\change_inserted -712698321 1584102244
\end_layout
\begin_layout Standard
\change_inserted -712698321 1584102427
In the section
\family sans
Global Counters & References
\family default
you can set how page numbers, references, section counters etc.
are handled.
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1584102377
With the option
\family sans
Strictly maintain
\family default
,
\change_deleted -712698321 1584102385
If the option
\family sans
Maintain counters and references
\family default
is enabled, \SpecialChar LyX
is enabled,
\change_unchanged
\SpecialChar LyX
will assure that all page numbers, references etc.
\begin_inset space ~
\end_inset
are correct as if the whole document was processed.
are correct as if the whole document was
\change_deleted -712698321 1584108508
processed
\change_inserted -712698321 1584108509
output
\change_unchanged
.
This is useful if you want the selected sub-documents to look exactly as
in the context of the whole document.
However, \SpecialChar LyX
needs to process the whole document in the background for this
feature.
So if you want to save compile time and if counters and references do not
need to be correct, disable this checkbox.
feature
\change_inserted -712698321 1584102406
, which can take a long time
\change_unchanged
.
\change_deleted -712698321 1584103026
\change_inserted -712698321 1584102447
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1584102489
With the option
\family sans
Do not maintain
\family default
,
\change_unchanged
\SpecialChar LyX
\change_inserted -712698321 1584103270
only compiles the master and the included documents.
Thus the counters will differ from the complete document, and references
to excluded child documents will not be resolved.
\change_deleted -712698321 1584102517
So i
\change_inserted -712698321 1584102518
I
\change_unchanged
f you want to save compile time and if counters and references do not need
to be correct,
\change_deleted -712698321 1584102523
disable this checkbox
\change_inserted -712698321 1584102546
use this option as this is the fastest one
\change_unchanged
.
\change_inserted -712698321 1584102550
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1584109486
The option
\family sans
Maintain mostly
\family default
is somewhat in-between the above two.
If this is selected, \SpecialChar LyX
will compile the whole document at the first output,
which sets up counters and references correctly.
In subsequent outputs, it will compile the whole document only if a change
has been made in an excluded child document.
As long as you only edit the included files, this approach is as fast as
the second one, while giving you more or less correct counters and references.
They are only more or less correct since the change of size of included
documents obviously also changes the pagination of excluded documents,
but this change cannot be tracked with this method.
\change_unchanged
\end_layout
\begin_layout Standard

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 571
\lyxformat 593
\begin_document
\begin_header
\save_transient_properties true
@ -160,7 +160,7 @@ initials
graphicboxes
varwidth
\end_modules
\maintain_unincluded_children false
\maintain_unincluded_children no
\language ngerman
\language_package default
\inputencoding utf8
@ -172,7 +172,9 @@ varwidth
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_roman_osf false
\font_sans_osf false
\font_typewriter_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
@ -199,7 +201,7 @@ varwidth
\pdf_backref false
\pdf_pdfusetitle false
\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false"
\papersize a4paper
\papersize a4
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
@ -221,6 +223,7 @@ varwidth
\justification true
\use_refstyle 1
\use_minted 0
\use_lineno 0
\notefontcolor #0000ff
\index Stichwortverzeichnis
\shortcut idx
@ -240,6 +243,8 @@ varwidth
\tablestyle default
\tracking_changes false
\output_changes false
\change_bars false
\postpone_fragile_content false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
@ -40926,22 +40931,40 @@ Einstellungen\SpecialChar menuseparator
Unterdokumente
\family default
.
Unterdokumente können unterdrückt/eingebunden werden, indem man doppelt
in die Spalte
Unterdokumente können unterdrückt/eingebunden werden, indem man in die
Spalte
\family sans
In Ausgabe einbinden
\family default
hinter dem jeweiligen Unterdokument klickt (beachten Sie, dass dies nur
für Unterdokumente möglich ist, die per
hinter dem jeweiligen Unterdokument doppelklickt (beachten Sie, dass dies
nur für Unterdokumente möglich ist, die per
\family sans
Input
\family default
eingebunden wurden).
Wenn die Option
\end_layout
\begin_layout Standard
Im Abschnitt
\family sans
Zähler und Querverweise wahren
Globale Zähler und Verweise
\family default
aktiviert ist, sorgt \SpecialChar LyX
können Sie einstellen, wie Seitenzahlen, Querverweise, Abschnittsnummern
u.
\begin_inset space \thinspace{}
\end_inset
ä.
behandelt werden.
\end_layout
\begin_layout Itemize
Mit der Option
\family sans
Strikt beibehalten
\family default
sorgt \SpecialChar LyX
dafür, dass alle Seitennummern, Querverweise usw.
\begin_inset space ~
\end_inset
@ -40950,13 +40973,44 @@ korrekt sind, so als würde das gesamte Dokument ausgegeben werden.
Dies ist nützlich wenn die gewählten Unterdokumente in der Ausgabe so aussehen
sollen, als wenn sie Teil des fertigen, ganzen Dokuments wären.
Dazu muss \SpecialChar LyX
intern allerdings das gesamte Dokument prozessieren.
Um Zeit beim Kompilieren zu sparen und wenn die Seitennummern nicht wichtig
sind, wählen sie die Option nicht.
intern allerdings das gesamte Dokument prozessieren, was viel
Zeit in Anspruch nehmen kann.
\end_layout
\begin_layout Itemize
Mit der Option
\family sans
Nicht beibehalten
\family default
verarbeitet \SpecialChar LyX
nut das Hauptdokument und die eingebundenen Unterdokumente.
Wenn Sie Zeit beim Kompilieren zu sparen möchten und wenn die Seitennummern
und Querverweise nicht wichtig sind, wählen sie diese Option, da sie die
schnellste ist.
\end_layout
\begin_layout Itemize
Die Option
\family sans
Weitgehend beibehalten
\family default
liegt zwischen den beiden genannten.
Wenn dies ausgewählt ist, verarbeitet \SpecialChar LyX
bei der Erstausgabe das Gesamtdokument;
dies initiiert die korrekten Zähler und Verweise.
In weiteren Ausgaben wird das Gesamtdokument dann aber nur noch dann mitverarbe
itet, wenn es Änderungen in nicht eingebundenen Unterdokumenten gibt.
So lange Sie nur die eingebettet Dokumente bearbeiten, ist diese Methode
so schnell wie die zweite, sie gibt Ihnen aber mehr oder weniger korrekte
Zähler und Verweise aus.
Mehr oder weniger korrekt sind sie deshalb, weil sich durch die Arbeit
an eingebundenen Dokumenten ja auch die Paginierung darauf folgender nicht
eingebundener Dokument ändern kann, und dies kann mit dieser Methode nicht
berücksichtigt werden.
\end_layout
\begin_layout Standard
Alternativ, können Sie eingefügte Dateien in einen Zweig setzen.
Alternativ können Sie eingefügte Dateien in einen Zweig setzen.
\begin_inset Foot
status collapsed

View File

@ -3635,6 +3635,7 @@ def revert_postpone_fragile(document):
del document.header[i]
def revert_colrow_tracking(document):
" Remove change tag from tabular columns/rows "
i = 0
@ -3654,6 +3655,38 @@ def revert_colrow_tracking(document):
if m:
document.body[k] = document.body[k].replace(' change="' + m.group(1) + '"', '')
def convert_counter_maintenance(document):
" Convert \\maintain_unincluded_children buffer param from boolean value tro tristate "
i = find_token(document.header, "\\maintain_unincluded_children", 0)
if i == -1:
document.warning("Malformed LyX document! Missing \\maintain_unincluded_children.")
return
val = get_value(document.header, "\\maintain_unincluded_children", i)
if val == "true":
document.header[i] = "\\maintain_unincluded_children strict"
else:
document.header[i] = "\\maintain_unincluded_children no"
def revert_counter_maintenance(document):
" Revert \\maintain_unincluded_children buffer param to previous boolean value "
i = find_token(document.header, "\\maintain_unincluded_children", 0)
if i == -1:
document.warning("Malformed LyX document! Missing \\maintain_unincluded_children.")
return
val = get_value(document.header, "\\maintain_unincluded_children", i)
if val == "no":
document.header[i] = "\\maintain_unincluded_children false"
else:
document.header[i] = "\\maintain_unincluded_children true"
##
# Conversion hub
#
@ -3707,10 +3740,12 @@ convert = [
[589, [convert_totalheight]],
[590, [convert_changebars]],
[591, [convert_postpone_fragile]],
[592, []]
[592, []],
[593, [convert_counter_maintenance]]
]
revert = [[591, [revert_colrow_tracking]],
revert = [[592, [revert_counter_maintenance]],
[591, [revert_colrow_tracking]],
[590, [revert_postpone_fragile]],
[589, [revert_changebars]],
[588, [revert_totalheight]],

View File

@ -4331,7 +4331,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
string & result_file) const
{
bool const update_unincluded =
params().maintain_unincluded_children
params().maintain_unincluded_children != BufferParams::CM_None
&& !params().getIncludedChildren().empty();
// (1) export with all included children (omit \includeonly)
@ -4619,7 +4619,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
Buffer::ExportStatus Buffer::preview(string const & format) const
{
bool const update_unincluded =
params().maintain_unincluded_children
params().maintain_unincluded_children != BufferParams::CM_None
&& !params().getIncludedChildren().empty();
return preview(format, update_unincluded);
}

View File

@ -413,7 +413,7 @@ BufferParams::BufferParams()
change_bars = false;
postpone_fragile_content = true;
use_default_options = true;
maintain_unincluded_children = false;
maintain_unincluded_children = CM_None;
secnumdepth = 3;
tocdepth = 3;
language = default_language;
@ -782,7 +782,14 @@ string BufferParams::readToken(Lexer & lex, string const & token,
} else if (token == "\\begin_includeonly") {
readIncludeonly(lex);
} else if (token == "\\maintain_unincluded_children") {
lex >> maintain_unincluded_children;
string tmp;
lex >> tmp;
if (tmp == "no")
maintain_unincluded_children = CM_None;
else if (tmp == "mostly")
maintain_unincluded_children = CM_Mostly;
else if (tmp == "strict")
maintain_unincluded_children = CM_Strict;
} else if (token == "\\options") {
lex.eatLine();
options = lex.getString();
@ -1235,8 +1242,19 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
os << c << '\n';
os << "\\end_includeonly" << '\n';
}
os << "\\maintain_unincluded_children "
<< convert<string>(maintain_unincluded_children) << '\n';
string muc = "no";
switch (maintain_unincluded_children) {
case CM_Mostly:
muc = "mostly";
break;
case CM_Strict:
muc = "strict";
break;
case CM_None:
default:
break;
}
os << "\\maintain_unincluded_children " << muc << '\n';
// local layout information
docstring const local_layout = getLocalLayout(false);

View File

@ -214,7 +214,12 @@ public:
void clearIncludedChildren() { included_children_.clear(); }
/// update aux files of unincluded children (with \includeonly)
bool maintain_unincluded_children;
enum ChildrenMaintenance {
CM_None,
CM_Mostly,
CM_Strict
};
ChildrenMaintenance maintain_unincluded_children;
/// returns the main font for the buffer (document)
Font const getFont() const;

View File

@ -17,6 +17,7 @@
#include "Buffer.h"
#include "BufferList.h"
#include "BufferParams.h"
#include "LaTeX.h"
#include "LyXRC.h"
#include "LyX.h"
@ -234,6 +235,17 @@ int LaTeX::run(TeXErrors & terr)
// (2) the master is always changed (due to the \includeonly line), and this alone would
// trigger a complete, expensive run each time
head.remove_file(file);
// Also remove all children which are included
Buffer const * buf = theBufferList().getBufferFromTmp(file.absFileName());
if (buf && buf->params().maintain_unincluded_children == BufferParams::CM_Mostly) {
for (auto const incfile : buf->params().getIncludedChildren()) {
string const incm =
DocFileName(changeExtension(makeAbsPath(incfile, path)
.absFileName(), ".tex")).mangledFileName();
FileName inc = makeAbsPath(incm, file.onlyPath().realPath());
head.remove_file(inc);
}
}
}
// Update the checksums
head.update();

View File

@ -889,12 +889,16 @@ GuiDocument::GuiDocument(GuiView & lv)
connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
masterChildModule->childrenTW, SLOT(setEnabled(bool)));
connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
masterChildModule->maintainAuxCB, SLOT(setEnabled(bool)));
masterChildModule->maintainGB, SLOT(setEnabled(bool)));
connect(masterChildModule->includeallRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(masterChildModule->includeonlyRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(masterChildModule->maintainAuxCB, SIGNAL(clicked()),
connect(masterChildModule->maintainCRNoneRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(masterChildModule->maintainCRMostlyRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(masterChildModule->maintainCRStrictRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
masterChildModule->childrenTW->setColumnCount(2);
masterChildModule->childrenTW->headerItem()->setText(0, qt_("Child Document"));
@ -3648,8 +3652,15 @@ void GuiDocument::applyView()
bp_.addIncludedChildren(*it);
}
}
if (masterChildModule->maintainCRNoneRB->isChecked())
bp_.maintain_unincluded_children =
masterChildModule->maintainAuxCB->isChecked();
BufferParams::CM_None;
else if (masterChildModule->maintainCRMostlyRB->isChecked())
bp_.maintain_unincluded_children =
BufferParams::CM_Mostly;
else
bp_.maintain_unincluded_children =
BufferParams::CM_Strict;
updateIncludeonlyDisplay();
// Float Settings
@ -4181,8 +4192,18 @@ void GuiDocument::paramsToDialog()
updateIncludeonlys();
updateIncludeonlyDisplay();
}
masterChildModule->maintainAuxCB->setChecked(
bp_.maintain_unincluded_children);
switch (bp_.maintain_unincluded_children) {
case BufferParams::CM_None:
masterChildModule->maintainCRNoneRB->setChecked(true);
break;
case BufferParams::CM_Mostly:
masterChildModule->maintainCRMostlyRB->setChecked(true);
break;
case BufferParams::CM_Strict:
default:
masterChildModule->maintainCRStrictRB->setChecked(true);
break;
}
// Float Settings
floatModule->setPlacement(bp_.float_placement);
@ -4521,11 +4542,11 @@ void GuiDocument::updateIncludeonlyDisplay()
if (includeonlys_.empty()) {
masterChildModule->includeallRB->setChecked(true);
masterChildModule->childrenTW->setEnabled(false);
masterChildModule->maintainAuxCB->setEnabled(false);
masterChildModule->maintainGB->setEnabled(false);
} else {
masterChildModule->includeonlyRB->setChecked(true);
masterChildModule->childrenTW->setEnabled(true);
masterChildModule->maintainAuxCB->setEnabled(true);
masterChildModule->maintainGB->setEnabled(true);
}
}

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MasterChildUi</class>
<widget class="QWidget" name="MasterChildUi">
@ -5,20 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>348</width>
<height>355</height>
<width>306</width>
<height>435</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="includeonlyGB">
<property name="title">
@ -27,13 +22,17 @@
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QRadioButton" name="includeallRB">
<property name="toolTip">
<string>Include all subdocuments in the output</string>
</property>
<property name="spacing" >
<number>6</number>
<property name="text">
<string>&amp;Include all children</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="includeonlyRB">
<property name="toolTip">
@ -45,28 +44,59 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="maintainAuxCB" >
<property name="toolTip" >
<string>Assure counters and references are as in the complete document (prolonges compilation)</string>
</property>
<widget class="QTreeWidget" name="childrenTW">
<column>
<property name="text">
<string>&amp;Maintain counters and references</string>
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="3" column="0">
<widget class="QTreeWidget" name="childrenTW" />
</item>
<item row="0" column="0" >
<widget class="QRadioButton" name="includeallRB" >
<widget class="QGroupBox" name="maintainGB">
<property name="toolTip">
<string>Include all subdocuments in the output</string>
<string>Here you can set up the handling of counters and references with regard to the excluded child documents.</string>
</property>
<property name="title">
<string>Global Counters &amp;&amp; References</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="maintainCRNoneRB">
<property name="toolTip">
<string>All counters and references of excluded child documents will be ignored, thus the counters in the output will differ from an output of the complete document.
This is the fastest method. Use this if you do not need correct counter values and references.</string>
</property>
<property name="text">
<string>&amp;Include all children</string>
<string>Do &amp;not maintain (fast)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="maintainCRMostlyRB">
<property name="toolTip">
<string>Counters and references of excluded child documents will be set up once and adapted if an excluded document has been modified. This sets up counters and references correctly in most cases, but it does not adjust page references to unincluded children that change due to changes of included files.
This is significantly faster than &quot;Strictly maintain&quot;. Use this if you need correct counters and more or less correct references.</string>
</property>
<property name="text">
<string>Maintain mostl&amp;y (medium)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="maintainCRStrictRB">
<property name="toolTip">
<string>Assure that all counters and references are identical to the complete document. This can be much slower than the first two methods.
Use this if you absolutely need correct counters.</string>
</property>
<property name="text">
<string>Strictly &amp;maintain (slow)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -550,7 +550,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
h_language = "english";
h_language_package = "none";
//h_listings_params;
h_maintain_unincluded_children = "false";
h_maintain_unincluded_children = "no";
//h_margins;
//h_notefontcolor;
//h_options;

View File

@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
#define LYX_FORMAT_LYX 592 // spitz: row/column change tracking
#define LYX_FORMAT_TEX2LYX 592
#define LYX_FORMAT_LYX 593 // spitz: maintain counter/references
#define LYX_FORMAT_TEX2LYX 593
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER