commit 0ca600b93b57049819c114f442d7a5138fe10085
Author: Juergen Spitzmueller <[email protected]>
Date:   Thu Aug 22 05:35:47 2024 +0200

    \use_nomentbl -> \nomencl_opts
    
    This allows for support of more options
    
    As the param is only a few hours old, no lyx2lyx handling is needed
---
 lib/lyx2lyx/lyx_2_5.py          | 21 +++++++++++----------
 src/Buffer.cpp                  |  1 +
 src/BufferParams.cpp            | 10 ++++++----
 src/BufferParams.h              |  4 ++--
 src/LaTeXFeatures.cpp           |  4 ++--
 src/frontends/qt/GuiIndices.cpp |  5 +++--
 src/insets/InsetNomencl.cpp     |  2 +-
 src/tex2lyx/Preamble.cpp        | 19 ++++---------------
 src/tex2lyx/Preamble.h          |  4 ++--
 src/tex2lyx/text.cpp            |  2 +-
 10 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/lib/lyx2lyx/lyx_2_5.py b/lib/lyx2lyx/lyx_2_5.py
index cd224fe946..74a74339c7 100644
--- a/lib/lyx2lyx/lyx_2_5.py
+++ b/lib/lyx2lyx/lyx_2_5.py
@@ -717,18 +717,23 @@ def revert_index_sc(document):
 def revert_nomentbl(document):
     """Revert nomentbl inset to ERT."""
 
-    i = find_token(document.header, "\\use_nomentbl", 0)
+    # intermediate format
+    i = find_token(document.header, "\\nomencl_options", 0)
     if i == -1:
-        document.warning("Malformed document! Missing \\use_nomentbl")
-        return
-    if get_value(document.header, "\\use_nomentbl", i) == 0:
-        # just remove header
-        del document.header[i]
+        # nothing to do
         return
 
+    opts = get_value(document.header, "\\nomencl_options", i)
     # remove header
     del document.header[i]
 
+    # store options
+    document.append_local_layout([r"### Inserted by lyx2lyx (nomencl) ###",
+                                  r"PackageOptions nomencl %s" % opts])
+
+    if opts.find("nomentbl") == -1:
+        return
+    
     # revert insets to ERT
     have_nomencl = False
     i = 0
@@ -853,10 +858,6 @@ def revert_nomentbl(document):
         document.body[i : j + 1] = res
 
         i += 1
-        
-    if have_nomencl:
-        document.append_local_layout([r"### Inserted by lyx2lyx (nomencl) ###",
-                                      r"PackageOptions nomencl nomentbl"])
 
 
 ##
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index cdbfe5f0e2..6adafdf18e 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -969,6 +969,7 @@ int Buffer::readHeader(Lexer & lex)
        params().biblatex_citestyle.erase();
        params().multibib.erase();
        params().lineno_opts.clear();
+       params().nomencl_opts.clear();
        params().spellignore().clear();
 
        for (int i = 0; i < 4; ++i) {
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 8f1563e516..f14ae84190 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -492,7 +492,6 @@ BufferParams::BufferParams()
        use_formatted_ref = false;
        use_minted = false;
        use_lineno = false;
-       use_nomentbl = false;
 
        // map current author
        author_map_[pimpl_->authorlist.get(0).bufferId()] = 0;
@@ -1212,8 +1211,9 @@ string BufferParams::readToken(Lexer & lex, string const 
& token,
                lex >> use_formatted_ref;
        } else if (token == "\\use_minted") {
                lex >> use_minted;
-       } else if (token == "\\use_nomentbl") {
-               lex >> use_nomentbl;
+       } else if (token == "\\nomencl_options") {
+               lex.eatLine();
+               nomencl_opts = trim(lex.getString());
        } else if (token == "\\use_lineno") {
                lex >> use_lineno;
        } else if (token == "\\lineno_options") {
@@ -1442,13 +1442,15 @@ void BufferParams::writeFile(ostream & os, Buffer const 
* buf) const
           << "\n\\use_refstyle " << use_refstyle
           << "\n\\use_formatted_ref " << use_formatted_ref
           << "\n\\use_minted " << use_minted
-          << "\n\\use_nomentbl " << use_nomentbl
           << "\n\\use_lineno " << use_lineno
           << '\n';
 
        if (!lineno_opts.empty())
                os << "\\lineno_options " << lineno_opts << '\n';
 
+       if (!nomencl_opts.empty())
+               os << "\\nomencl_options " << nomencl_opts << '\n';
+
        if (isbackgroundcolor)
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) 
<< '\n';
        if (isfontcolor)
diff --git a/src/BufferParams.h b/src/BufferParams.h
index bef948330c..d7400e2f36 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -623,8 +623,8 @@ public:
        bool use_lineno;
        /// optional params for lineno package
        std::string lineno_opts;
-       /// use nomentbl nomenclature sty
-       bool use_nomentbl;
+       /// options for nomencl package
+       std::string nomencl_opts;
 
        /// Return true if language could be set to lang,
        /// otherwise return false and do not change language
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index b423437269..a6fc73ecc9 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -1498,8 +1498,8 @@ string const LaTeXFeatures::getPackages() const
 
        if (mustProvide("nomencl")) {
                packages << "\\usepackage";
-               if (params_.use_nomentbl)
-                       packages << "[nomentbl]";
+               if (!params_.nomencl_opts.empty())
+                       packages << "[" << params_.nomencl_opts << "]";
                packages << "{nomencl}\n";
                // Make it work with the new and old version of the package,
                // but don't use the compatibility option since it is
diff --git a/src/frontends/qt/GuiIndices.cpp b/src/frontends/qt/GuiIndices.cpp
index 2c3a0d78ce..f6003ec399 100644
--- a/src/frontends/qt/GuiIndices.cpp
+++ b/src/frontends/qt/GuiIndices.cpp
@@ -119,7 +119,7 @@ void GuiIndices::update(BufferParams const & params, bool 
const readonly)
                indexOptionsLE->clear();
        }
 
-       pos = (params.use_nomentbl) ? 1 : 0;
+       pos = (contains(params.nomencl_opts, "nomentbl")) ? 1 : 0;
        nomenclStyleCO->setCurrentIndex(pos);
 
        updateView();
@@ -169,7 +169,8 @@ void GuiIndices::apply(BufferParams & params) const
        params.use_indices = multipleIndicesCB->isChecked();
        params.indiceslist() = indiceslist_;
 
-       params.use_nomentbl = nomenclStyleCO->currentIndex() == 1;
+       if (nomenclStyleCO->currentIndex() == 1)
+               params.nomencl_opts = "nomentbl";
 
        string const index_command =
                fromqstr(indexCO->itemData(
diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp
index 4baa29ecfc..d694a166b7 100644
--- a/src/insets/InsetNomencl.cpp
+++ b/src/insets/InsetNomencl.cpp
@@ -154,7 +154,7 @@ void InsetNomencl::addToToc(DocIterator const & cpit, bool 
output_active,
 
 docstring InsetNomencl::layoutName() const
 {
-       return (buffer().params().use_nomentbl) ?
+       return (contains(buffer().params().nomencl_opts, "nomentbl")) ?
                                from_ascii("Nomenclature:nomentbl")
                              : from_ascii("Nomenclature");
 }
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index cb57d9115c..7802eae0b5 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -616,7 +616,6 @@ Preamble::Preamble() : one_language(true), 
explicit_babel(false),
        h_use_lineno              = "false";
        h_use_refstyle            = false;
        h_use_minted              = false;
-       h_use_nomentbl            = false;
        h_use_packages["amsmath"]    = "1";
        h_use_packages["amssymb"]    = "0";
        h_use_packages["cancel"]     = "0";
@@ -1780,19 +1779,8 @@ void Preamble::handle_package(Parser &p, string const & 
name,
        }
 
        else if (name == "nomencl") {
-               vector<string>::iterator it =
-                       find(options.begin(), options.end(), "nomentbl");
-               if (it != options.end()) {
-                       h_use_nomentbl = true;
-                       options.erase(it);
-               }
-               // Add the package options to the global document options
-               if (!options.empty()) {
-                       if (h_options.empty())
-                               h_options = join(options, ",");
-                       else
-                               h_options += ',' + join(options, ",");
-               }
+               h_nomencl_options = join(options, ",");
+               options.clear();
        }
 
        else if (name == "geometry")
@@ -2124,10 +2112,11 @@ bool Preamble::writeLyXHeader(ostream & os, bool 
subdoc, string const & outfiled
           << "\\justification " << h_justification << '\n'
           << "\\use_refstyle " << h_use_refstyle << '\n'
           << "\\use_minted " << h_use_minted << '\n'
-          << "\\use_nomentbl " << h_use_nomentbl << '\n'
           << "\\use_lineno " << h_use_lineno << '\n';
        if (!h_lineno_options.empty())
                os << "\\lineno_options " << h_lineno_options << '\n';
+       if (!h_nomencl_options.empty())
+               os << "\\nomencl_options " << h_nomencl_options << '\n';
        if (!h_fontcolor.empty())
                os << "\\fontcolor " << h_fontcolor << '\n';
        if (!h_notefontcolor.empty())
diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h
index 9177784771..01d29fcf54 100644
--- a/src/tex2lyx/Preamble.h
+++ b/src/tex2lyx/Preamble.h
@@ -51,7 +51,7 @@ public:
        ///
        bool minted() const { return h_use_minted; }
        ///
-       bool nomentbl() const { return h_use_nomentbl; }
+       std::string nomenclOpts() const { return h_nomencl_options; }
        /// The document language
        std::string docLanguage() const { return h_language; }
        /// The language of text which is not explicitly marked
@@ -257,7 +257,7 @@ private:
        std::vector<std::string> h_includeonlys;
        bool h_use_refstyle;
        bool h_use_minted;
-       bool h_use_nomentbl;
+       std::string h_nomencl_options;
 
        /*!
         * Add package \p name with options \p options to used_packages.
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index ee40d4a1ef..688286b710 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -5010,7 +5010,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
                        set<string> pass_thru_cmds = context.pass_thru_cmds;
                        // These commands have special meanings in Nomenclature
                        context.pass_thru_cmds.insert("%");
-                       if (preamble.nomentbl())
+                       if (contains(preamble.nomenclOpts(), "nomentbl"))
                                parse_text_in_inset(p, os, FLAG_ITEM, outer, 
context, "Nomenclature:nomentbl");
                        else
                                parse_text_in_inset(p, os, FLAG_ITEM, outer, 
context, "Nomenclature");
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to