]> git.lyx.org Git - features.git/commitdiff
Add \save_transient_properties parameter (#9841)
authorGuillaume Munch <gm@lyx.org>
Sun, 20 Dec 2015 16:37:29 +0000 (16:37 +0000)
committerGuillaume Munch <gm@lyx.org>
Tue, 12 Jan 2016 21:25:34 +0000 (21:25 +0000)
Increment LyX format to 504.

With this new parameter, the user can indicate that some other parameters that
are frequently switched must not be recorded in the file (as if they were a
setting specific to the user or transient, rather than a document setting). This
will play nicer with version control systems.

See the discussion, e.g.:
http://thread.gmane.org/gmane.editors.lyx.devel/157824/focus=157993 (third
solution mentioned)

TODO:
* The interface remains to be set up. We cannot change this setting from LyX
  for now.
* If save_transient_properties is false, we should read the user setting as a
  per-user-per-document (session) setting (e.g. like the cursor position).
* Once the above is done, we can treat \justification the same way (but it would
  be even better if \justification was moved to lyxrc).

development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_2_2.py
src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/tex2lyx/Preamble.cpp
src/tex2lyx/Preamble.h
src/version.h

index c4d9b4d02f31ff57115491a92245a16de60100ac..cbd5064bfb504e5a04888c05b89a0641c9133456 100644 (file)
@@ -11,6 +11,13 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
 
 -----------------------
 
+2015-12-20 Guillaume Munch <gm@lyx.org>
+       * Format incremented to 504
+         New parameter "\save_transient_properties". When set to false, various
+         settings are no longer written to the file (only with a default
+         value). These include for now \tracking_changes and \output_changes.
+         Bug 9841.
+
 2015-11-24 Uwe Stöhr <uwestoehr@web.de>
        * Format incremented to 503
          No new parameters.
index d9ad0d6e41b1bf0b809be9ab49210af3328c3540..6bc0fb6f7c4bdec17bb3d5d13021744c03414217 100644 (file)
@@ -80,12 +80,13 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_1_6_3", [218], ["1.1", "1.1.6.3","1.1.6.4"]),
                    ("1_2",     [220], minor_versions("1.2" , 4)),
                    ("1_3",     [221], minor_versions("1.3" , 7)),
+                   # Note that range(i,j) is up to j *excluded*.
                    ("1_4", list(range(222,246)), minor_versions("1.4" , 5)),
                    ("1_5", list(range(246,277)), minor_versions("1.5" , 7)),
                    ("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
                    ("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
                    ("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
-                   ("2_2", list(range(475,504)), minor_versions("2.2" , 0))
+                   ("2_2", list(range(475,505)), minor_versions("2.2" , 0))
                   ]
 
 ####################################################################
index 5a639cd2393d18533af83e228d1f00f54c7ccbce..53614206f6a3affe8b98512ebd9ee758c1675790 100644 (file)
@@ -2184,6 +2184,23 @@ def revert_verbatim_star(document):
     revert_verbatim(document, True)
 
 
+def convert_save_props(document):
+    " Add save_transient_properties parameter. "
+    i = find_token(document.header, '\\origin', 0)
+    if i == -1:
+        document.warning("Malformed lyx document: Missing '\\origin'.")
+        return
+    document.header.insert(i, '\\save_transient_properties true')
+
+
+def revert_save_props(document):
+    " Remove save_transient_properties parameter. "
+    i = find_token(document.header, "\\save_transient_properties", 0)
+    if i == -1:
+        return
+    del document.header[i]
+
+
 ##
 # Conversion hub
 #
@@ -2221,10 +2238,12 @@ convert = [
            [500, []],
            [501, [convert_fontsettings]],
            [502, []],
-           [503, []]
+           [503, []],
+           [504, [convert_save_props]]
           ]
 
 revert =  [
+           [503, [revert_save_props]],
            [502, [revert_verbatim_star]],
            [501, [revert_solution]],
            [500, [revert_fontsettings]],
index 54a1ee4ac9631212e5d696d2b270cbbfcc3bfcfe..37dcbca01475f44539f97ec4a5b3f3e1b8808340 100644 (file)
@@ -2765,12 +2765,14 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
                break;
 
        case LFUN_CHANGES_TRACK:
-               undo().recordUndoBufferParams(CursorData());
+               if (params().save_transient_properties)
+                       undo().recordUndoBufferParams(CursorData());
                params().track_changes = !params().track_changes;
                break;
 
        case LFUN_CHANGES_OUTPUT:
-               undo().recordUndoBufferParams(CursorData());
+               if (params().save_transient_properties)
+                       undo().recordUndoBufferParams(CursorData());
                params().output_changes = !params().output_changes;
                if (params().output_changes) {
                        bool dvipost    = LaTeXFeatures::isAvailable("dvipost");
index 618aed3d3adeca0d58d421df583d775cd65d47ca..382d1f928b50019f0e13e3f478c84f4f128042cf 100644 (file)
@@ -369,6 +369,7 @@ BufferParams::BufferParams()
        biblio_style = "plain";
        use_bibtopic = false;
        use_indices = false;
+       save_transient_properties = true;
        track_changes = false;
        output_changes = false;
        use_default_options = true;
@@ -673,6 +674,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                        frontend::Alert::warning(_("Document class not available"),
                                       msg, true);
                }
+       } else if (token == "\\save_transient_properties") {
+               lex >> save_transient_properties;
        } else if (token == "\\origin") {
                lex.eatLine();
                origin = lex.getString();
@@ -1015,6 +1018,9 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
        // The top of the file is written by the buffer.
        // Prints out the buffer info into the .lyx file given by file
 
+       os << "\\save_transient_properties "
+          << convert<string>(save_transient_properties) << '\n';
+
        // the document directory (must end with a path separator)
        // realPath() is used to resolve symlinks, while addPath(..., "")
        // ensures a trailing path separator.
@@ -1273,9 +1279,15 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
                }
        }
 
-       os << "\\tracking_changes " << convert<string>(track_changes) << '\n'
-          << "\\output_changes " << convert<string>(output_changes) << '\n'
-          << "\\html_math_output " << html_math_output << '\n'
+       os << "\\tracking_changes "
+          << (save_transient_properties ? convert<string>(track_changes) : "false")
+          << '\n';
+
+       os << "\\output_changes "
+          << (save_transient_properties ? convert<string>(output_changes) : "false")
+          << '\n';
+
+       os << "\\html_math_output " << html_math_output << '\n'
           << "\\html_css_as_file " << html_css_as_file << '\n'
           << "\\html_be_strict " << convert<string>(html_be_strict) << '\n';
 
index 79af8f21a678bd60a28c5fd625fa5fbf8ff6e900..caae01dfec15535e847429326491d15cfbc5e7df 100644 (file)
@@ -381,11 +381,14 @@ public:
        bool use_bibtopic;
        /// Split the index?
        bool use_indices;
-       /// revision tracking for this buffer ?
+       /// Save trensient properties?
+       bool save_transient_properties;
+       /// revision tracking for this buffer ? (this is a transient property)
        bool track_changes;
        /** This param decides whether change tracking marks should be used
         *  in output (irrespective of how these marks are actually defined;
         *  for instance, they may differ for DVI and PDF generation)
+        *  This is a transient property.
         */
        bool output_changes;
        ///
index 01587cc02dfbbe0995cde64168ed7cca9e472129..05c3c406f6b1c0cbb7f014faf96e11924c227f10 100644 (file)
@@ -536,6 +536,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_secnumdepth             = "3";
        h_shortcut[0]             = "idx";
        h_spacing                 = "single";
+       h_save_transient_properties = "true";
        h_suppress_date           = "false";
        h_textclass               = "article";
        h_tocdepth                = "3";
@@ -1102,6 +1103,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
           << "\\lyxformat " << LYX_FORMAT << '\n'
           << "\\begin_document\n"
           << "\\begin_header\n"
+          << "\\save_transient_properties " << h_save_transient_properties << "\n"
           << "\\origin " << origin << "\n"
           << "\\textclass " << h_textclass << "\n";
        string const raw = subdoc ? empty_string() : h_preamble.str();
index 1c3fe66f23eef2802157a4a9ecde8586baeabd8d..a8bf4ee05956feb7bfc924d79973f236661f09ca 100644 (file)
@@ -191,6 +191,7 @@ private:
        std::string h_shortcut[99];
        std::string h_spacing;
        std::string h_suppress_date;
+       std::string h_save_transient_properties;
        std::string h_textclass;
        std::string h_tocdepth;
        std::string h_tracking_changes;
index fff8c5a0784357c826542303f70a6d9e464e7f1f..3f571d14f1d016bd2bfedd0456f8b35a916df271 100644 (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 503 // uwestoehr: support for verbatim* environment
-#define LYX_FORMAT_TEX2LYX 503
+#define LYX_FORMAT_LYX 504 // gm: add save_transient_properties parameter
+#define LYX_FORMAT_TEX2LYX 504
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER