From: Juergen Spitzmueller Date: Fri, 13 Mar 2020 14:46:35 +0000 (+0100) Subject: Introduce maintain unincluded children "mostly" X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e400d5ac4046672eabe9e7252f1d6d3cd90cdf6d;p=features.git 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. --- diff --git a/development/FORMAT b/development/FORMAT index fb5e7dfc9d..75b5190061 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,6 +7,11 @@ changes happened in particular if possible. A good example would be ----------------------- +2020-03-13 Jürgen Spitzmüller + * 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 * 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. diff --git a/lib/doc/EmbeddedObjects.lyx b/lib/doc/EmbeddedObjects.lyx index 1e8188b4f6..029b9dd451 100644 --- a/lib/doc/EmbeddedObjects.lyx +++ b/lib/doc/EmbeddedObjects.lyx @@ -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 ). - If the option + +\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 diff --git a/lib/doc/de/EmbeddedObjects.lyx b/lib/doc/de/EmbeddedObjects.lyx index 862918e7d9..686ea6b9e2 100644 --- a/lib/doc/de/EmbeddedObjects.lyx +++ b/lib/doc/de/EmbeddedObjects.lyx @@ -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 +Globale Zähler und Verweise +\family default + 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 -Zähler und Querverweise wahren +Strikt beibehalten \family default - aktiviert ist, sorgt \SpecialChar LyX + 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 diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py index b5a03488fa..1b4c940589 100644 --- a/lib/lyx2lyx/lyx_2_4.py +++ b/lib/lyx2lyx/lyx_2_4.py @@ -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]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 8504c9e4e5..620f5c2904 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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); } diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 44847a9bdb..750c6e83fb 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -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(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); diff --git a/src/BufferParams.h b/src/BufferParams.h index c66dd6185a..84a5e58eab 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -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; diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp index c62535c56e..a7b39037fb 100644 --- a/src/LaTeX.cpp +++ b/src/LaTeX.cpp @@ -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(); diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index 5ffccdc25d..bd33d93d35 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -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); } } - bp_.maintain_unincluded_children = - masterChildModule->maintainAuxCB->isChecked(); + if (masterChildModule->maintainCRNoneRB->isChecked()) + bp_.maintain_unincluded_children = + 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); } } diff --git a/src/frontends/qt/ui/MasterChildUi.ui b/src/frontends/qt/ui/MasterChildUi.ui index 76ea30f17a..fb04909f62 100644 --- a/src/frontends/qt/ui/MasterChildUi.ui +++ b/src/frontends/qt/ui/MasterChildUi.ui @@ -1,70 +1,100 @@ - + + MasterChildUi - - + + 0 0 - 348 - 355 + 306 + 435 - + - - - 9 - - - 6 - - - - + + + + Master Document Output - + true - - - 9 - - - 6 - - - - - Include only the selected subdocuments in the output + + + + + Include all subdocuments in the output - - Include only &selected children + + &Include all children - - - - Assure counters and references are as in the complete document (prolonges compilation) + + + + Include only the selected subdocuments in the output - - &Maintain counters and references + + Include only &selected children - - + + + + + 1 + + + - - - - Include all subdocuments in the output + + + + Here you can set up the handling of counters and references with regard to the excluded child documents. - - &Include all children + + Global Counters && References + + + + + 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. + + + Do &not maintain (fast) + + + + + + + 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 "Strictly maintain". Use this if you need correct counters and more or less correct references. + + + Maintain mostl&y (medium) + + + + + + + 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. + + + Strictly &maintain (slow) + + + + @@ -73,7 +103,7 @@ - qt_i18n.h + qt_i18n.h diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 8b327b100d..5b93f98498 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -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; diff --git a/src/version.h b/src/version.h index df249ab526..a6649265c2 100644 --- a/src/version.h +++ b/src/version.h @@ -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