The branch, biblatex2, has been updated.

- Log -----------------------------------------------------------------

commit ce8929e9b237af569934b434154d199634363268
Merge: 74f774d a7aef29
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Thu Jan 12 09:05:28 2017 +0100

    Merge branch 'master' into biblatex2


commit a7aef29600ee5cb01212e2fa9316f57c5b979b27
Author: Richard Heck <rgh...@lyx.org>
Date:   Wed Jan 11 14:15:51 2017 -0500

    Update tex2lyx tests.

diff --git a/src/tex2lyx/test/CJK.lyx.lyx b/src/tex2lyx/test/CJK.lyx.lyx
index a4ad55d..3280138 100644
--- a/src/tex2lyx/test/CJK.lyx.lyx
+++ b/src/tex2lyx/test/CJK.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/CJKutf8.lyx.lyx b/src/tex2lyx/test/CJKutf8.lyx.lyx
index bed4ba2..e13eaae 100644
--- a/src/tex2lyx/test/CJKutf8.lyx.lyx
+++ b/src/tex2lyx/test/CJKutf8.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/DummyDocument.lyx.lyx 
b/src/tex2lyx/test/DummyDocument.lyx.lyx
index e0f9880..fc40455 100644
--- a/src/tex2lyx/test/DummyDocument.lyx.lyx
+++ b/src/tex2lyx/test/DummyDocument.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/Dummy~Document.lyx.lyx 
b/src/tex2lyx/test/Dummy~Document.lyx.lyx
index c1974d3..30c9aae 100644
--- a/src/tex2lyx/test/Dummy~Document.lyx.lyx
+++ b/src/tex2lyx/test/Dummy~Document.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx 
b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
index 52c20c7..510f56d 100644
--- a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
+++ b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/algo2e.lyx.lyx b/src/tex2lyx/test/algo2e.lyx.lyx
index 10e1de4..8c19e5a 100644
--- a/src/tex2lyx/test/algo2e.lyx.lyx
+++ b/src/tex2lyx/test/algo2e.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx 
b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
index aa86a1b..a85d6d6 100644
--- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
+++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-insets-basic.lyx.lyx 
b/src/tex2lyx/test/test-insets-basic.lyx.lyx
index c75d58c..8296c79 100644
--- a/src/tex2lyx/test/test-insets-basic.lyx.lyx
+++ b/src/tex2lyx/test/test-insets-basic.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -206,6 +206,7 @@ LatexCommand ref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -232,6 +233,7 @@ LatexCommand pageref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -246,6 +248,7 @@ LatexCommand eqref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -260,6 +263,7 @@ LatexCommand vref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -274,6 +278,7 @@ LatexCommand vpageref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -288,6 +293,7 @@ LatexCommand formatted
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -302,6 +308,7 @@ LatexCommand nameref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx 
b/src/tex2lyx/test/test-insets.lyx.lyx
index 6e9cf5c..141b8c6 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -186,6 +186,7 @@ LatexCommand ref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -212,6 +213,7 @@ LatexCommand pageref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -226,6 +228,7 @@ LatexCommand eqref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -240,6 +243,7 @@ LatexCommand vref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -254,6 +258,7 @@ LatexCommand vpageref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -268,6 +273,7 @@ LatexCommand formatted
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -282,6 +288,7 @@ LatexCommand nameref
 reference "lab:test"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
diff --git a/src/tex2lyx/test/test-memoir.lyx.lyx 
b/src/tex2lyx/test/test-memoir.lyx.lyx
index 6dc7596..3030694 100644
--- a/src/tex2lyx/test/test-memoir.lyx.lyx
+++ b/src/tex2lyx/test/test-memoir.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-modules.lyx.lyx 
b/src/tex2lyx/test/test-modules.lyx.lyx
index d0f6e0e..9b1834c 100644
--- a/src/tex2lyx/test/test-modules.lyx.lyx
+++ b/src/tex2lyx/test/test-modules.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx 
b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
index 6a35e47..71a918b 100644
--- a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
+++ b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -97,6 +97,7 @@ LatexCommand formatted
 reference "part:part"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -121,6 +122,7 @@ LatexCommand formatted
 reference "chap:chapter"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -145,6 +147,7 @@ LatexCommand formatted
 reference "sec:Section"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -169,6 +172,7 @@ LatexCommand formatted
 reference "subsec:subsection"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -193,6 +197,7 @@ LatexCommand formatted
 reference "subsec:Subsubsection"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -217,6 +222,7 @@ LatexCommand formatted
 reference "par:paragraph"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -241,6 +247,7 @@ LatexCommand formatted
 reference "par:subparagraph"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -299,6 +306,7 @@ LatexCommand formatted
 reference "fig:figure"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -357,6 +365,7 @@ LatexCommand formatted
 reference "tab:table"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -415,6 +424,7 @@ LatexCommand formatted
 reference "alg:algorithm"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -450,6 +460,7 @@ LatexCommand formatted
 reference "fn:foot"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -485,6 +496,7 @@ LatexCommand ref
 reference "margin"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -509,6 +521,7 @@ LatexCommand formatted
 reference "enu:item"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -532,6 +545,7 @@ LatexCommand formatted
 reference "eq:A=00003DB"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -556,6 +570,7 @@ LatexCommand formatted
 reference "lem:lemma"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -580,6 +595,7 @@ LatexCommand formatted
 reference "thm:theorem"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -604,6 +620,7 @@ LatexCommand formatted
 reference "cor:corollary"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -628,6 +645,7 @@ LatexCommand formatted
 reference "prop:proposition"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -652,6 +670,7 @@ LatexCommand ref
 reference "conjecture"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -676,6 +695,7 @@ LatexCommand ref
 reference "fact"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -700,6 +720,7 @@ LatexCommand ref
 reference "definition"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -724,6 +745,7 @@ LatexCommand ref
 reference "example"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -748,6 +770,7 @@ LatexCommand ref
 reference "problem"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -772,6 +795,7 @@ LatexCommand ref
 reference "exercise"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -796,6 +820,7 @@ LatexCommand ref
 reference "remark"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -820,6 +845,7 @@ LatexCommand ref
 reference "claim"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -844,6 +870,7 @@ LatexCommand ref
 reference "proof"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
diff --git a/src/tex2lyx/test/test-scr.lyx.lyx 
b/src/tex2lyx/test/test-scr.lyx.lyx
index f88fc40..1cdc71a 100644
--- a/src/tex2lyx/test/test-scr.lyx.lyx
+++ b/src/tex2lyx/test/test-scr.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test-structure.lyx.lyx 
b/src/tex2lyx/test/test-structure.lyx.lyx
index 1e1510b..c98448e 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
diff --git a/src/tex2lyx/test/test.lyx.lyx b/src/tex2lyx/test/test.lyx.lyx
index 7b0ea70..c259bf8 100644
--- a/src/tex2lyx/test/test.lyx.lyx
+++ b/src/tex2lyx/test/test.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -425,6 +425,7 @@ LatexCommand ref
 reference "sec:mysection"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
@@ -434,6 +435,7 @@ LatexCommand pageref
 reference "sec:mysection"
 plural "false"
 caps "false"
+noprefix "false"
 
 \end_inset
 
diff --git a/src/tex2lyx/test/verbatim.lyx.lyx 
b/src/tex2lyx/test/verbatim.lyx.lyx
index 80338d0..da790a5 100644
--- a/src/tex2lyx/test/verbatim.lyx.lyx
+++ b/src/tex2lyx/test/verbatim.lyx.lyx
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.3
-\lyxformat 526
+\lyxformat 527
 \begin_document
 \begin_header
 \save_transient_properties true

commit 89662a6852ca8f68caa557808d7b7e1d669344d4
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Fri Jan 6 09:52:10 2017 +0100

    Re-implement math markers logic.
    
    The goal of this patch is to be able to properly remove the space
    needed for markers in the case of insets that are inside macros and do
    not need these markers. This was attempted at 9a9a6a8, but did not
    work reliably.
    
    To this end, the following simplifications are made:
    
    * instead of drawing its own markers, each inset has a virtual method
      marker() which prescribes either NO_MARKER, MARKER (normal bottom
      marker) or MARKER2 (top and bottom marker). All explicit calls to
      (draw|metrics)Markers(|2) are removed.
    
    * the space necessary for the markers is now counted in the
      before/above margins in the row structure. Therefore painting will
      not happen at (x + 1, y), but just (x,y).
    
    * the methods drawDecoration are removed.
    
    * the helper methods InsetMath::(draw|metrics)Markers(|2) are removed
      and replaced by a new function drawMarkers in MathRow.cpp.
    
    Now the marker type is kept in the MathRow::Element object (and set to
    NO_MARKER in not editable context) and the marker is accounted for in
    MathRow::(metrics|draw).
    
    Moreover, the extra pixel for the marker is taken on the before/After
    space if possible. The marker will only require extra space when
    before/after is 0.
    
    See comment 168 of #8883 to understand what issues are fixed.

diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 0922b4a..0783ec1 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -198,17 +198,19 @@ public:
        ///
        virtual bool showInsetDialog(BufferView *) const;
 
-       /// draw inset decoration if necessary.
-       /// This can use \c drawMarkers() for example.
-       virtual void drawDecoration(PainterInfo &, int, int) const {}
-       /// draw four angular markers
-       void drawMarkers(PainterInfo & pi, int x, int y) const;
+       // The possible marker types for insets
+       enum marker_type { NO_MARKER, MARKER2, MARKER };
        /// draw two angular markers
+       void drawMarkers(PainterInfo & pi, int x, int y) const;
+       /// draw four angular markers
        void drawMarkers2(PainterInfo & pi, int x, int y) const;
        /// add space for markers
        void metricsMarkers(Dimension & dim, int framesize = 1) const;
        /// add space for markers
        void metricsMarkers2(Dimension & dim, int framesize = 1) const;
+       /// draw inset decoration if necessary.
+       /// This can use \c drawMarkers() for example.
+       virtual void drawDecoration(PainterInfo &, int, int) const {}
 
        /// last metrics computed for the inset
        Dimension const dimension(BufferView const &) const;
diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index 093dcda..e3b46b9 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -58,44 +58,21 @@ MathClass InsetMath::mathClass() const
 }
 
 
+InsetMath::marker_type InsetMath::marker() const
+{
+       return nargs() > 0 ? MARKER : NO_MARKER;
+}
+
+
 bool InsetMath::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
 {
        MathRow::Element e(mi, MathRow::INSET, mathClass());
        e.inset = this;
+       e.marker = mi.base.macro_nesting ? NO_MARKER : marker();
        mrow.push_back(e);
        return true;
 }
 
-void InsetMath::metricsMarkers(MetricsInfo & mi, Dimension & dim,
-                           int framesize) const
-{
-       if (!mi.base.macro_nesting)
-               Inset::metricsMarkers(dim, framesize);
-}
-
-
-void InsetMath::metricsMarkers2(MetricsInfo & mi, Dimension & dim,
-                            int framesize) const
-{
-       if (!mi.base.macro_nesting)
-               Inset::metricsMarkers2(dim, framesize);
-}
-
-
-void InsetMath::drawMarkers(PainterInfo & pi, int x, int y) const
-{
-       if (!pi.base.macro_nesting)
-               Inset::drawMarkers(pi, x, y);
-}
-
-
-void InsetMath::drawMarkers2(PainterInfo & pi, int x, int y) const
-{
-       if (!pi.base.macro_nesting)
-               Inset::drawMarkers2(pi, x, y);
-}
-
-
 
 void InsetMath::dump() const
 {
diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h
index e8c893b..68cd597 100644
--- a/src/mathed/InsetMath.h
+++ b/src/mathed/InsetMath.h
@@ -114,6 +114,9 @@ public:
        /// this is overridden by specific insets
        virtual mode_type currentMode() const { return MATH_MODE; }
 
+       /// this is overridden by insets with specific edit marker type
+       virtual marker_type marker() const;
+
        /// the ascent of the inset above the baseline
        /// compute the size of the object for text based drawing
        virtual void metricsT(TextMetricsInfo const & mi, Dimension & dim) 
const;
@@ -169,15 +172,6 @@ public:
        /// Add this inset to a math row. Return true if contents got added
        virtual bool addToMathRow(MathRow &, MetricsInfo & mi) const;
 
-       /// draw four angular markers
-       void drawMarkers(PainterInfo & pi, int x, int y) const;
-       /// draw two angular markers
-       void drawMarkers2(PainterInfo & pi, int x, int y) const;
-       /// add space for markers
-       void metricsMarkers(MetricsInfo & mi, Dimension & dim, int framesize = 
1) const;
-       /// add space for markers
-       void metricsMarkers2(MetricsInfo & mi, Dimension & dim, int framesize = 
1) const;
-
        /// identifies things that can get scripts
        virtual bool isScriptable() const { return false; }
        /// will this get written as a single block in {..}
diff --git a/src/mathed/InsetMathBoldSymbol.cpp 
b/src/mathed/InsetMathBoldSymbol.cpp
index d820519..62f8098 100644
--- a/src/mathed/InsetMathBoldSymbol.cpp
+++ b/src/mathed/InsetMathBoldSymbol.cpp
@@ -53,7 +53,6 @@ void InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension 
& dim) const
        Changer dummy = mi.base.changeEnsureMath();
        //Changer dummy = mi.base.changeFontSet("mathbf");
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
        ++dim.wid;  // for 'double stroke'
 }
 
@@ -62,9 +61,8 @@ void InsetMathBoldSymbol::draw(PainterInfo & pi, int x, int 
y) const
 {
        Changer dummy = pi.base.changeEnsureMath();
        //Changer dummy = pi.base.changeFontSet("mathbf");
+       cell(0).draw(pi, x, y);
        cell(0).draw(pi, x + 1, y);
-       cell(0).draw(pi, x + 2, y);
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index aff3fb6..4c832f0 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -83,7 +83,6 @@ void InsetMathBox::metrics(MetricsInfo & mi, Dimension & dim) 
const
 {
        Changer dummy = mi.base.changeFontSet("textnormal");
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
@@ -91,12 +90,11 @@ void InsetMathBox::draw(PainterInfo & pi, int x, int y) 
const
 {
        Changer dummy = pi.base.changeFontSet("textnormal");
        cell(0).draw(pi, x, y);
-       drawMarkers(pi, x, y);
 }
 
 
 void InsetMathBox::infoize(odocstream & os) const
-{      
+{
        os << bformat(_("Box: %1$s"), name_);
 }
 
@@ -135,7 +133,10 @@ void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & 
dim) const
 {
        Changer dummy = mi.base.changeFontSet("textnormal");
        cell(0).metrics(mi, dim);
-       metricsMarkers2(mi, dim, 3); // 1 pixel space, 1 frame, 1 space
+       // 1 pixel space, 1 frame, 1 space
+       dim.wid += 2 * 3;
+       dim.asc += 3;
+       dim.des += 3;
 }
 
 
@@ -219,23 +220,23 @@ InsetMathMakebox::InsetMathMakebox(Buffer * buf, bool 
framebox)
 void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        Changer dummy = mi.base.changeFontSet("textnormal");
-       
+
        Dimension wdim;
        static docstring bracket = from_ascii("[");
        metricsStrRedBlack(mi, wdim, bracket);
        int w = wdim.wid;
-       
+
        Dimension dim0;
        Dimension dim1;
        Dimension dim2;
        cell(0).metrics(mi, dim0);
        cell(1).metrics(mi, dim1);
        cell(2).metrics(mi, dim2);
-       
+
        dim.wid = w + dim0.wid + w + w + dim1.wid + w + 2 + dim2.wid;
-       dim.asc = std::max(std::max(wdim.asc, dim0.asc), std::max(dim1.asc, 
dim2.asc)); 
+       dim.asc = std::max(std::max(wdim.asc, dim0.asc), std::max(dim1.asc, 
dim2.asc));
        dim.des = std::max(std::max(wdim.des, dim0.des), std::max(dim1.des, 
dim2.des));
-       
+
        if (framebox_) {
                dim.wid += 4;
                dim.asc += 3;
@@ -244,26 +245,22 @@ void InsetMathMakebox::metrics(MetricsInfo & mi, 
Dimension & dim) const
                dim.asc += 1;
                dim.des += 1;
        }
-       
-       metricsMarkers(mi, dim);
 }
 
 
 void InsetMathMakebox::draw(PainterInfo & pi, int x, int y) const
 {
-       drawMarkers(pi, x, y);
-       
        Changer dummy = pi.base.changeFontSet("textnormal");
        BufferView const & bv = *pi.base.bv;
        int w = mathed_char_width(pi.base.font, '[');
-       
+
        if (framebox_) {
                Dimension const dim = dimension(*pi.base.bv);
                pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
                                  dim.width() - 2, dim.height() - 2, 
Color_foreground);
                x += 2;
        }
-       
+
        drawStrBlack(pi, x, y, from_ascii("["));
        x += w;
        cell(0).draw(pi, x, y);
@@ -359,7 +356,10 @@ InsetMathBoxed::InsetMathBoxed(Buffer * buf)
 void InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        cell(0).metrics(mi, dim);
-       metricsMarkers2(mi, dim, 3); // 1 pixel space, 1 frame, 1 space
+       // 1 pixel space, 1 frame, 1 space
+       dim.wid += 2 * 3;
+       dim.asc += 3;
+       dim.des += 3;
 }
 
 
diff --git a/src/mathed/InsetMathBox.h b/src/mathed/InsetMathBox.h
index 2f6ba48..e898a35 100644
--- a/src/mathed/InsetMathBox.h
+++ b/src/mathed/InsetMathBox.h
@@ -58,6 +58,8 @@ public:
        ///
        mode_type currentMode() const { return TEXT_MODE; }
        ///
+       marker_type marker() const { return NO_MARKER; }
+       ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
@@ -116,6 +118,8 @@ public:
        ///
        InsetMathBoxed(Buffer * buf);
        ///
+       marker_type marker() const { return NO_MARKER; }
+       ///
        void validate(LaTeXFeatures & features) const;
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
diff --git a/src/mathed/InsetMathBrace.cpp b/src/mathed/InsetMathBrace.cpp
index 6870fa6..3a452c0 100644
--- a/src/mathed/InsetMathBrace.cpp
+++ b/src/mathed/InsetMathBrace.cpp
@@ -55,7 +55,6 @@ void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & 
dim) const
        dim.asc = max(dim0.asc, t.asc);
        dim.des = max(dim0.des, t.des);
        dim.wid = dim0.width() + 2 * t.wid;
-       metricsMarkers(mi, dim);
 }
 
 
@@ -70,7 +69,6 @@ void InsetMathBrace::draw(PainterInfo & pi, int x, int y) 
const
        cell(0).draw(pi, x + t.wid, y);
        Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
        pi.pain.text(x + t.wid + dim0.width(), y, '}', font);
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathCancel.cpp b/src/mathed/InsetMathCancel.cpp
index e0c8611..098f2a8 100644
--- a/src/mathed/InsetMathCancel.cpp
+++ b/src/mathed/InsetMathCancel.cpp
@@ -39,7 +39,6 @@ void InsetMathCancel::metrics(MetricsInfo & mi, Dimension & 
dim) const
 {
        Changer dummy = mi.base.changeEnsureMath();
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
@@ -48,7 +47,7 @@ void InsetMathCancel::draw(PainterInfo & pi, int x, int y) 
const
        Changer dummy = pi.base.changeEnsureMath();
        // We first draw the text and then an arrow
        ColorCode const origcol = pi.base.font.color();
-       cell(0).draw(pi, x + 1, y);
+       cell(0).draw(pi, x, y);
        Dimension const dim = dimension(*pi.base.bv);
        int const t = pi.base.solidLineThickness();
 
@@ -75,8 +74,6 @@ void InsetMathCancel::draw(PainterInfo & pi, int x, int y) 
const
                pi.pain.line(x2, y1, x1, y2, origcol, pi.pain.line_solid, t);
                pi.pain.line(x2, y2, x1, y1, origcol, pi.pain.line_solid, t);
        }
-
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathCancelto.cpp b/src/mathed/InsetMathCancelto.cpp
index 283a971..f3ead3c 100644
--- a/src/mathed/InsetMathCancelto.cpp
+++ b/src/mathed/InsetMathCancelto.cpp
@@ -48,7 +48,6 @@ void InsetMathCancelto::metrics(MetricsInfo & mi, Dimension & 
dim) const
        dim.asc = max(dim0.ascent() + 2, dim0.ascent() + dim1.ascent()) + 2 + 8;
        dim.des = max(dim0.descent() - 2, dim1.descent()) + 2;
        dim.wid = dim0.width() + dim1.width() + 10;
-       metricsMarkers(mi, dim);
 }
 
 
@@ -59,11 +58,11 @@ void InsetMathCancelto::draw(PainterInfo & pi, int x, int 
y) const
 
        // We first draw the text and then an arrow
        Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
-       cell(0).draw(pi, x + 1, y);
-       cell(1).draw(pi, x + dim0.wid + 2 + 8, y - dim0.asc - 8);
-               
+       cell(0).draw(pi, x, y);
+       cell(1).draw(pi, x + dim0.wid + 1 + 8, y - dim0.asc - 8);
+
        //Dimension const dim = dimension(*pi.base.bv);
-       
+
        // y3____ ___
        //          /|
        // y2_     / |
@@ -86,8 +85,6 @@ void InsetMathCancelto::draw(PainterInfo & pi, int x, int y) 
const
        // the arrow bars
        pi.pain.line(x3, y3, x2 + 2, y3, origcol);
        pi.pain.line(x3, y3, x3 - 2, y2 - 2, origcol);
-
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathClass.cpp b/src/mathed/InsetMathClass.cpp
index 0237f25..2327cbe 100644
--- a/src/mathed/InsetMathClass.cpp
+++ b/src/mathed/InsetMathClass.cpp
@@ -31,14 +31,12 @@ Inset * InsetMathClass::clone() const
 void InsetMathClass::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
 void InsetMathClass::draw(PainterInfo & pi, int x, int y) const
 {
-       cell(0).draw(pi, x + 1, y);
-       drawMarkers(pi, x, y);
+       cell(0).draw(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathColor.cpp b/src/mathed/InsetMathColor.cpp
index ea4f4ef..6cb9960 100644
--- a/src/mathed/InsetMathColor.cpp
+++ b/src/mathed/InsetMathColor.cpp
@@ -49,7 +49,6 @@ Inset * InsetMathColor::clone() const
 void InsetMathColor::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
@@ -57,9 +56,8 @@ void InsetMathColor::draw(PainterInfo & pi, int x, int y) 
const
 {
        ColorCode origcol = pi.base.font.color();
        pi.base.font.setColor(lcolor.getFromLaTeXName(to_utf8(color_)));
-       cell(0).draw(pi, x + 1, y);
+       cell(0).draw(pi, x, y);
        pi.base.font.setColor(origcol);
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathComment.cpp b/src/mathed/InsetMathComment.cpp
index b8c157b..ea502d1 100644
--- a/src/mathed/InsetMathComment.cpp
+++ b/src/mathed/InsetMathComment.cpp
@@ -50,14 +50,12 @@ Inset * InsetMathComment::clone() const
 void InsetMathComment::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
 void InsetMathComment::draw(PainterInfo & pi, int x, int y) const
 {
-       cell(0).draw(pi, x + 1, y);
-       drawMarkers(pi, x, y);
+       cell(0).draw(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathDecoration.cpp 
b/src/mathed/InsetMathDecoration.cpp
index e4cb25a..4779249 100644
--- a/src/mathed/InsetMathDecoration.cpp
+++ b/src/mathed/InsetMathDecoration.cpp
@@ -119,8 +119,6 @@ void InsetMathDecoration::metrics(MetricsInfo & mi, 
Dimension & dim) const
                dy_ = dim.des + 1;
                dim.des += dh_ + 2;
        }
-
-       metricsMarkers(mi, dim);
 }
 
 
@@ -128,14 +126,13 @@ void InsetMathDecoration::draw(PainterInfo & pi, int x, 
int y) const
 {
        Changer dummy = pi.base.changeEnsureMath(currentMode());
 
-       cell(0).draw(pi, x + 1, y);
+       cell(0).draw(pi, x, y);
        Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
        if (wide())
                mathed_draw_deco(pi, x + 1, y + dy_, dim0.wid, dh_, key_->name);
        else
                mathed_draw_deco(pi, x + 1 + (dim0.wid - dw_) / 2,
                        y + dy_, dw_, dh_, key_->name);
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathEnsureMath.cpp 
b/src/mathed/InsetMathEnsureMath.cpp
index 1897781..8bd685c 100644
--- a/src/mathed/InsetMathEnsureMath.cpp
+++ b/src/mathed/InsetMathEnsureMath.cpp
@@ -40,7 +40,6 @@ void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension 
& dim) const
 {
        Changer dummy = mi.base.changeEnsureMath();
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
@@ -48,7 +47,6 @@ void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int 
y) const
 {
        Changer dummy = pi.base.changeEnsureMath();
        cell(0).draw(pi, x, y);
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathEnv.cpp b/src/mathed/InsetMathEnv.cpp
index 4126356..2eea5ac 100644
--- a/src/mathed/InsetMathEnv.cpp
+++ b/src/mathed/InsetMathEnv.cpp
@@ -42,15 +42,13 @@ void InsetMathEnv::metrics(MetricsInfo & mi, Dimension & 
dim) const
 {
        Changer dummy = mi.base.changeEnsureMath();
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
 void InsetMathEnv::draw(PainterInfo & pi, int x, int y) const
 {
        Changer dummy = pi.base.changeEnsureMath();
-       cell(0).draw(pi, x + 1, y);
-       drawMarkers(pi, x, y);
+       cell(0).draw(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp
index 05f9e66..9876123 100644
--- a/src/mathed/InsetMathFont.cpp
+++ b/src/mathed/InsetMathFont.cpp
@@ -86,15 +86,13 @@ void InsetMathFont::metrics(MetricsInfo & mi, Dimension & 
dim) const
 {
        Changer dummy = mi.base.changeFontSet(font());
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
 void InsetMathFont::draw(PainterInfo & pi, int x, int y) const
 {
        Changer dummy = pi.base.changeFontSet(font());
-       cell(0).draw(pi, x + 1, y);
-       drawMarkers(pi, x, y);
+       cell(0).draw(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathFontOld.cpp b/src/mathed/InsetMathFontOld.cpp
index 11ba283..cde3888 100644
--- a/src/mathed/InsetMathFontOld.cpp
+++ b/src/mathed/InsetMathFontOld.cpp
@@ -62,7 +62,6 @@ void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & 
dim) const
        Changer dummy = really_change_font ? mi.base.changeFontSet(fontname)
                : Changer();
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
@@ -79,8 +78,7 @@ void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) 
const
 
        Changer dummy = really_change_font ? pi.base.changeFontSet(fontname)
                : Changer();
-       cell(0).draw(pi, x + 1, y);
-       drawMarkers(pi, x, y);
+       cell(0).draw(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index ada6476..465d1fa 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -261,7 +261,6 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & 
dim) const
                dim.des = max(0, dim1.height() + dy/2 - dy + t);
        }
        } //switch (kind_)
-       metricsMarkers(mi, dim);
 }
 
 
@@ -278,12 +277,12 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) 
const
                // is there an extra cell holding the value being given a 
dimension?
                // (this is \unittwo)
                if (nargs() == 2) {
-                       cell(0).draw(pi, x + 1, y);
+                       cell(0).draw(pi, x, y);
                        xx += dim0.wid + 4;
                        unit_cell = 1;
                }
                Changer dummy = pi.base.font.changeShape(UP_SHAPE);
-               cell(unit_cell).draw(pi, xx + 1, y);
+               cell(unit_cell).draw(pi, xx, y);
        }
                break;
 
@@ -295,24 +294,24 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) 
const
                // is there an extra cell holding the value being given a 
dimension?
                // (this is \unitfracthree)
                if (kind_ == UNITFRAC && nargs() == 3) {
-                       cell(2).draw(pi, x + 1, y);
+                       cell(2).draw(pi, x, y);
                        xx += cell(2).dimension(*pi.base.bv).wid + 4;
                }
                Changer dummy = (kind_ == UNITFRAC) ? 
pi.base.font.changeShape(UP_SHAPE)
                        : Changer();
                // nice fraction
                Changer dummy2 = pi.base.changeScript();
-               cell(0).draw(pi, xx + 2, y - dy);
+               cell(0).draw(pi, xx, y - dy);
                // reference LaTeX code from nicefrac.sty:
                //    \mkern-2mu/\mkern-1mu
                if (latexkeys const * slash = slash_symbol()) {
                        int mkern = mathed_mu(pi.base.font, 2.0);
-                       mathedSymbolDraw(pi, xx + 2 + dim0.wid - mkern, y, 
slash);
+                       mathedSymbolDraw(pi, xx + 1 + dim0.wid - mkern, y, 
slash);
                        Dimension dimslash;
                        mathedSymbolDim(pi.base, dimslash, slash);
                        xx += dimslash.wid - mathed_mu(pi.base.font, 3.0);
                }
-               cell(1).draw(pi, xx + 2 + dim0.wid, y);
+               cell(1).draw(pi, xx + 1 + dim0.wid, y);
        }
                break;
 
@@ -339,7 +338,7 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) 
const
                int const m = x + dim.wid / 2;
                int const xx =
                        // align left
-                       (kind_ == CFRACLEFT) ? x + 2 :
+                       (kind_ == CFRACLEFT) ? x + 1 :
                        // align right
                        (kind_ == CFRACRIGHT) ? x + dim.wid - dim0.wid - 2 :
                        // center
@@ -355,11 +354,10 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) 
const
                cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + dy/2 - dy + 
t);
                // horizontal line
                if (kind_ != ATOP)
-                       pi.pain.line(x + 1, y - dy, x + dim.wid - 2, y - dy,
+                       pi.pain.line(x, y - dy, x + dim.wid - 2, y - dy,
                                     pi.base.font.color(), pi.pain.line_solid, 
t);
        }
        } //switch (kind_)
-       drawMarkers(pi, x, y);
 }
 
 
@@ -660,7 +658,6 @@ void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & 
dim) const
        dim.asc = dim0.height() + 1 + dy/2 + dy;
        dim.des = max(0, dim1.height() + 1 + dy/2 - dy);
        dim.wid = max(dim0.wid, dim1.wid) + 2 * dw(dim.height()) + 4;
-       metricsMarkers2(mi, dim);
 }
 
 
@@ -693,7 +690,6 @@ void InsetMathBinom::draw(PainterInfo & pi, int x, int y) 
const
                dim.height(), bra);
        mathed_draw_deco(pi, x + dim.width() - dw(dim.height()),
                y - dim.ascent(), dw(dim.height()), dim.height(), ket);
-       drawMarkers2(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathFrac.h b/src/mathed/InsetMathFrac.h
index 9d54844..b43180c 100644
--- a/src/mathed/InsetMathFrac.h
+++ b/src/mathed/InsetMathFrac.h
@@ -125,12 +125,11 @@ public:
        /// Generalized fractions are of inner class (see The TeXbook, p.292)
        MathClass mathClass() const { return MC_INNER; }
        ///
+       marker_type marker() const { return MARKER2; }
+       ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
        void draw(PainterInfo &, int x, int y) const;
-       /// draw decorations.
-       void drawDecoration(PainterInfo & pi, int x, int y) const
-       { drawMarkers2(pi, x, y); }
        ///
        bool extraBraces() const;
        ///
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 07a67c7..6730040 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -588,7 +588,6 @@ void InsetMathGrid::metrics(MetricsInfo & mi, Dimension & 
dim) const
        }
 */
        dim.wid += leftMargin() + rightMargin();
-       metricsMarkers2(mi, dim);
 }
 
 
@@ -653,8 +652,6 @@ void InsetMathGrid::draw(PainterInfo & pi, int x, int y) 
const
                        pi.pain.line(xx1, yy, xx2, yy, Color_foreground);
                }
        }
-
-       drawMarkers2(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathGrid.h b/src/mathed/InsetMathGrid.h
index 4300dc3..886d03a 100644
--- a/src/mathed/InsetMathGrid.h
+++ b/src/mathed/InsetMathGrid.h
@@ -103,9 +103,6 @@ public:
        void metrics(MetricsInfo & mi, Dimension &) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
-       /// draw decorations.
-       void drawDecoration(PainterInfo & pi, int x, int y) const
-       { drawMarkers2(pi, x, y); }
        ///
        void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
        ///
@@ -248,9 +245,9 @@ protected:
        /// Width of cell, taking combined columns into account
        int cellWidth(idx_type idx) const;
        ///
-       virtual int leftMargin() const { return 1; }
+       virtual int leftMargin() const { return 0; }
        ///
-       virtual int rightMargin() const { return 1; }
+       virtual int rightMargin() const { return 0; }
 
        /// returns proper 'end of line' code for LaTeX
        virtual docstring eolString(row_type row, bool fragile, bool latex,
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 61e0210..b326aeb 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -567,8 +567,9 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & 
dim) const
                        dim.wid += 30 + l;
        }
 
-       if (type_ == hullRegexp)
-               dim.wid += 2;
+       // reserve some space for marker.
+       dim.wid += 2;
+
        // make it at least as high as the current font
        int asc = 0;
        int des = 0;
@@ -644,6 +645,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) 
const
                                                            : LM_ST_TEXT);
 
        InsetMathGrid::draw(pi, x + 1, y);
+       drawMarkers2(pi, x, y);
 
        if (numberedType()) {
                int const xx = x + colinfo_.back().offset_ + 
colinfo_.back().width_ + 20;
diff --git a/src/mathed/InsetMathLefteqn.cpp b/src/mathed/InsetMathLefteqn.cpp
index 176c743..c4aa8b1 100644
--- a/src/mathed/InsetMathLefteqn.cpp
+++ b/src/mathed/InsetMathLefteqn.cpp
@@ -34,14 +34,12 @@ void InsetMathLefteqn::metrics(MetricsInfo & mi, Dimension 
& dim) const
        dim.asc += 2;
        dim.des += 2;
        dim.wid = 4;
-       metricsMarkers(mi, dim);
 }
 
 
 void InsetMathLefteqn::draw(PainterInfo & pi, int x, int y) const
 {
-       cell(0).draw(pi, x + 2, y);
-       drawMarkers(pi, x, y);
+       cell(0).draw(pi, x + 1, y);
 }
 
 
diff --git a/src/mathed/InsetMathNest.h b/src/mathed/InsetMathNest.h
index 80f5f6d..06668c9 100644
--- a/src/mathed/InsetMathNest.h
+++ b/src/mathed/InsetMathNest.h
@@ -48,9 +48,6 @@ public:
        void draw(PainterInfo & pi, int x, int y) const;
        /// draw selection background
        void drawSelection(PainterInfo & pi, int x, int y) const;
-       /// draw decorations.
-       void drawDecoration(PainterInfo & pi, int x, int y) const
-       { drawMarkers(pi, x, y); }
        ///
        void updateBuffer(ParIterator const &, UpdateType);
        /// identifies NestInsets
diff --git a/src/mathed/InsetMathOverset.cpp b/src/mathed/InsetMathOverset.cpp
index b903662..cea8840 100644
--- a/src/mathed/InsetMathOverset.cpp
+++ b/src/mathed/InsetMathOverset.cpp
@@ -40,7 +40,6 @@ void InsetMathOverset::metrics(MetricsInfo & mi, Dimension & 
dim) const
        dim.wid = max(dim0.width(), dim1.wid) + 4;
        dim.asc = dim1.asc + dim0.height() + 4;
        dim.des = dim1.des;
-       metricsMarkers(mi, dim);
 }
 
 
@@ -55,7 +54,6 @@ void InsetMathOverset::draw(PainterInfo & pi, int x, int y) 
const
        cell(1).draw(pi, m - dim1.wid / 2, y);
        Changer dummy = pi.base.changeFrac();
        cell(0).draw(pi, m - dim0.width() / 2, yo);
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathPhantom.cpp b/src/mathed/InsetMathPhantom.cpp
index 1ae8eee..583e9f0 100644
--- a/src/mathed/InsetMathPhantom.cpp
+++ b/src/mathed/InsetMathPhantom.cpp
@@ -40,7 +40,6 @@ void InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & 
dim) const
 {
        Changer dummy = mi.base.changeEnsureMath();
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
@@ -53,7 +52,7 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) 
const
        ColorCode const origcol = pi.base.font.color();
        if (visibleContents())
                pi.base.font.setColor(Color_special);
-       cell(0).draw(pi, x + 1, y);
+       cell(0).draw(pi, x, y);
        if (visibleContents())
                pi.base.font.setColor(origcol);
        Dimension const dim = dimension(*pi.base.bv);
@@ -247,8 +246,6 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) 
const
                else
                        pi.pain.line(x2, y1, x2, y5, Color_added_space);
        }
-
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp
index 8c4d1fa..f8f36d8 100644
--- a/src/mathed/InsetMathRoot.cpp
+++ b/src/mathed/InsetMathRoot.cpp
@@ -48,7 +48,6 @@ void InsetMathRoot::metrics(MetricsInfo & mi, Dimension & 
dim) const
        dim.asc = max(dim0.ascent()  + 5, dim1.ascent())  + 2;
        dim.des = max(dim0.descent() - 5, dim1.descent()) + 2;
        dim.wid = dim0.width() + dim1.width() + 10;
-       metricsMarkers(mi, dim);
 }
 
 
@@ -73,7 +72,6 @@ void InsetMathRoot::draw(PainterInfo & pi, int x, int y) const
        xp[2] = x + w - 2;         yp[2] = y + (d - a)/2 + 2;
        xp[3] = x + w - 5;         yp[3] = y + (d - a)/2 + 4;
        pi.pain.lines(xp, yp, 4, pi.base.font.color());
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index a4ffd57..b5e70fd 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -337,7 +337,6 @@ void InsetMathScript::metrics(MetricsInfo & mi, Dimension & 
dim) const
                dim.des = max(nd, des);
        } else
                dim.des = nd;
-       metricsMarkers(mi, dim);
 }
 
 
@@ -357,7 +356,6 @@ void InsetMathScript::draw(PainterInfo & pi, int x, int y) 
const
                up().draw(pi, x + dx1(bv), y - dy1(bv));
        if (hasDown())
                down().draw(pi, x + dx0(bv), y + dy0(bv));
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathSideset.cpp b/src/mathed/InsetMathSideset.cpp
index 02ac4ba..2638fef 100644
--- a/src/mathed/InsetMathSideset.cpp
+++ b/src/mathed/InsetMathSideset.cpp
@@ -222,7 +222,6 @@ void InsetMathSideset::metrics(MetricsInfo & mi, Dimension 
& dim) const
        int nd = ndes(bv);
        int des = dyb(bv) + max(dimbl.descent(), dimbr.descent());
        dim.des = max(nd, des);
-       metricsMarkers(mi, dim);
 }
 
 
@@ -244,7 +243,6 @@ void InsetMathSideset::draw(PainterInfo & pi, int x, int y) 
const
                br().draw(pi, x + dxr(bv), y + dyb(bv));
                tr().draw(pi, x + dxr(bv), y - dyt(bv));
        }
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathSize.cpp b/src/mathed/InsetMathSize.cpp
index 534010b..18d0aaf 100644
--- a/src/mathed/InsetMathSize.cpp
+++ b/src/mathed/InsetMathSize.cpp
@@ -47,7 +47,6 @@ void InsetMathSize::metrics(MetricsInfo & mi, Dimension & 
dim) const
        Changer dummy2 = mi.base.changeEnsureMath();
        Changer dummy = mi.base.font.changeStyle(style_);
        cell(0).metrics(mi, dim);
-       metricsMarkers(mi, dim);
 }
 
 
@@ -55,8 +54,7 @@ void InsetMathSize::draw(PainterInfo & pi, int x, int y) const
 {
        Changer dummy2 = pi.base.changeEnsureMath();
        Changer dummy = pi.base.font.changeStyle(style_);
-       cell(0).draw(pi, x + 1, y);
-       drawMarkers(pi, x, y);
+       cell(0).draw(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathSqrt.cpp b/src/mathed/InsetMathSqrt.cpp
index 1f58dce..4505d70 100644
--- a/src/mathed/InsetMathSqrt.cpp
+++ b/src/mathed/InsetMathSqrt.cpp
@@ -42,26 +42,24 @@ void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & 
dim) const
        dim.asc += 4;
        dim.des += 2;
        dim.wid += 12;
-       metricsMarkers(mi, dim);
 }
 
 
 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
 {
        Changer dummy = pi.base.changeEnsureMath();
-       cell(0).draw(pi, x + 10, y);
+       cell(0).draw(pi, x + 9, y);
        Dimension const dim = dimension(*pi.base.bv);
        int const a = dim.ascent();
        int const d = dim.descent();
        int xp[3];
        int yp[3];
        pi.pain.line(x + dim.width(), y - a + 1,
-               x + 8, y - a + 1, pi.base.font.color());
-       xp[0] = x + 8;            yp[0] = y - a + 1;
-       xp[1] = x + 5;            yp[1] = y + d - 1;
+               x + 7, y - a + 1, pi.base.font.color());
+       xp[0] = x + 7;            yp[0] = y - a + 1;
+       xp[1] = x + 4;            yp[1] = y + d - 1;
        xp[2] = x;                yp[2] = y + (d - a)/2;
        pi.pain.lines(xp, yp, 3, pi.base.font.color());
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathStackrel.cpp b/src/mathed/InsetMathStackrel.cpp
index 4efcfe4..dc01ffc 100644
--- a/src/mathed/InsetMathStackrel.cpp
+++ b/src/mathed/InsetMathStackrel.cpp
@@ -78,7 +78,6 @@ void InsetMathStackrel::metrics(MetricsInfo & mi, Dimension & 
dim) const
                dim.asc = dim1.ascent() + dim0.height() + 4;
                dim.des = dim1.descent();
        }
-       metricsMarkers(mi, dim);
 }
 
 
@@ -98,7 +97,6 @@ void InsetMathStackrel::draw(PainterInfo & pi, int x, int y) 
const
                int y2 = y + dim1.descent() + dim2.ascent() + 1;
                cell(2).draw(pi, m - dim2.width() / 2, y2);
        }
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathUnderset.cpp b/src/mathed/InsetMathUnderset.cpp
index f31ebae..b8c5d14 100644
--- a/src/mathed/InsetMathUnderset.cpp
+++ b/src/mathed/InsetMathUnderset.cpp
@@ -41,7 +41,6 @@ void InsetMathUnderset::metrics(MetricsInfo & mi, Dimension & 
dim) const
        dim.wid = max(dim0.width(), dim1.width()) + 4;
        dim.asc = dim1.ascent();
        dim.des = dim1.descent() + dim0.height() + 4;
-       metricsMarkers(mi, dim);
 }
 
 
@@ -56,7 +55,6 @@ void InsetMathUnderset::draw(PainterInfo & pi, int x, int y) 
const
        cell(1).draw(pi, m - dim1.width() / 2, y);
        Changer dummy = pi.base.changeFrac();
        cell(0).draw(pi, m - dim0.width() / 2, yo);
-       drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/InsetMathXArrow.cpp b/src/mathed/InsetMathXArrow.cpp
index d2121d6..30cce8a 100644
--- a/src/mathed/InsetMathXArrow.cpp
+++ b/src/mathed/InsetMathXArrow.cpp
@@ -52,7 +52,6 @@ void InsetMathXArrow::metrics(MetricsInfo & mi, Dimension & 
dim) const
        dim.wid = max(dim0.width(), dim1.width()) + 10;
        dim.asc = dim0.height() + 10;
        dim.des = dim1.height();
-       metricsMarkers(mi, dim);
 }
 
 
@@ -66,8 +65,7 @@ void InsetMathXArrow::draw(PainterInfo & pi, int x, int y) 
const
        cell(0).draw(pi, x + dim.width()/2 - dim0.width()/2, y - 10);
        Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
        cell(1).draw(pi, x + dim.width()/2 - dim1.width()/2, y + dim1.height());
-       mathed_draw_deco(pi, x + 1, y - 7, dim.wid - 2, 5, name_);
-       drawMarkers(pi, x, y);
+       mathed_draw_deco(pi, x, y - 7, dim.wid, 5, name_);
 }
 
 
diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp
index 8aeb542..bfa841d 100644
--- a/src/mathed/MathMacro.cpp
+++ b/src/mathed/MathMacro.cpp
@@ -67,6 +67,8 @@ public:
        ///
        MathMacro const * owner() { return mathMacro_; }
        ///
+       marker_type marker() const { return NO_MARKER; }
+       ///
        InsetCode lyxCode() const { return ARGUMENT_PROXY_CODE; }
        /// The math data to use for display
        MathData const & displayCell(BufferView const * bv) const
@@ -301,15 +303,17 @@ bool MathMacro::addToMathRow(MathRow & mrow, MetricsInfo 
& mi) const
        // This is the same as what is done in metrics().
        d->editing_[mi.base.bv] = editMode(mi.base.bv);
 
-       /// The macro nesting can change display of insets. Change it locally.
-       Changer chg = make_change(mi.base.macro_nesting, d->nesting_);
-
        if (displayMode() != MathMacro::DISPLAY_NORMAL
            || d->editing_[mi.base.bv])
                return InsetMath::addToMathRow(mrow, mi);
 
+       /// The macro nesting can change display of insets. Change it locally.
+       Changer chg = make_change(mi.base.macro_nesting, d->nesting_);
+
        MathRow::Element e_beg(mi, MathRow::BEG_MACRO);
+       e_beg.inset = this;
        e_beg.macro = this;
+       e_beg.marker = d->nesting_ == 1 ? marker() : NO_MARKER;
        mrow.push_back(e_beg);
 
        d->macro_->lock();
@@ -430,6 +434,27 @@ bool MathMacro::editMetrics(BufferView const * bv) const
 }
 
 
+Inset::marker_type MathMacro::marker() const
+{
+       switch (d->displayMode_) {
+       case DISPLAY_INIT:
+       case DISPLAY_INTERACTIVE_INIT:
+               return NO_MARKER;
+       case DISPLAY_UNFOLDED:
+               return MARKER;
+       default:
+               switch (lyxrc.macro_edit_style) {
+               case LyXRC::MACRO_EDIT_LIST:
+                       return MARKER2;
+               case LyXRC::MACRO_EDIT_INLINE_BOX:
+                       return NO_MARKER;
+               default:
+                       return MARKER;
+               }
+       }
+}
+
+
 void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        /// The macro nesting can change display of insets. Change it locally.
@@ -450,7 +475,6 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) 
const
                dim.wid += bsdim.width() + 1;
                dim.asc = max(bsdim.ascent(), dim.ascent());
                dim.des = max(bsdim.descent(), dim.descent());
-               metricsMarkers(mi, dim);
        } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST
                   && d->editing_[mi.base.bv]) {
                // Macro will be edited in a old-style list mode here:
@@ -490,7 +514,6 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) 
const
                dim.asc += 1;
                dim.des += 1;
                dim.wid += 2;
-               metricsMarkers2(mi, dim);
        } else {
                LBUFERR(d->macro_);
 
@@ -641,16 +664,15 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                pi.pain.text(x, y, from_ascii("\\"), pi.base.font);
                x += mathed_string_width(pi.base.font, from_ascii("\\")) + 1;
                cell(0).draw(pi, x, y);
-               drawMarkers(pi, expx, expy);
        } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST
-                  && d->editing_[pi.base.bv]) {
+                  && d->editing_[pi.base.bv]) {
                // Macro will be edited in a old-style list mode here:
 
                CoordCache const & coords = pi.base.bv->coordCache();
                FontInfo const & labelFont = sane_font;
 
-               // markers and box needs two pixels
-               x += 2;
+               // box needs one pixel
+               x += 1;
 
                // get maximal font height
                Dimension fontDim;
@@ -674,7 +696,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                for (idx_type i = 0; i < nargs(); ++i) {
                        // position of label
                        Dimension const & cdim = 
coords.getArrays().dim(&cell(i));
-                       x = expx + 2;
+                       x = expx + 1;
                        y += max(fontDim.asc, cdim.asc) + 1;
 
                        // draw label
@@ -691,9 +713,8 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                        y += max(fontDim.des, cdim.des);
                }
 
-               pi.pain.rectangle(expx + 1, expy - dim.asc + 1, dim.wid - 3,
+               pi.pain.rectangle(expx, expy - dim.asc + 1, dim.wid - 3,
                                  dim.height() - 2, Color_mathmacroframe);
-               drawMarkers2(pi, expx, expy);
        } else {
                bool drawBox = lyxrc.macro_edit_style == 
LyXRC::MACRO_EDIT_INLINE_BOX;
 
@@ -725,10 +746,6 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                                                  dim.height(), 
Color_mathmacroframe);
                } else
                        d->expanded_.draw(pi, expx, expy);
-
-               if (!drawBox)
-                       drawMarkers(pi, x, y);
-
        }
 
        // edit mode changed?
diff --git a/src/mathed/MathMacro.h b/src/mathed/MathMacro.h
index 6e79523..c7dca26 100644
--- a/src/mathed/MathMacro.h
+++ b/src/mathed/MathMacro.h
@@ -37,6 +37,7 @@ public:
        ///
        virtual MathMacro const * asMacro() const { return this; }
        ///
+       marker_type marker() const;
        /// If the macro is in normal edit mode, dissolve its contents in
        /// the row. Otherwise, just insert the inset.
        bool addToMathRow(MathRow &, MetricsInfo & mi) const;
@@ -44,9 +45,6 @@ public:
        void draw(PainterInfo & pi, int x, int y) const;
        /// draw selection background
        void drawSelection(PainterInfo & pi, int x, int y) const;
-       /// draw decorations.
-       void drawDecoration(PainterInfo & pi, int x, int y) const
-       { drawMarkers2(pi, x, y); }
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        /// was the macro in edit mode when computing metrics?
diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp
index 2c6cbf7..6b61af2 100644
--- a/src/mathed/MathMacroTemplate.cpp
+++ b/src/mathed/MathMacroTemplate.cpp
@@ -269,14 +269,12 @@ Inset * InsetMathWrapper::clone() const
 void InsetMathWrapper::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        value_->metrics(mi, dim);
-       //metricsMarkers2(mi, dim);
 }
 
 
 void InsetMathWrapper::draw(PainterInfo & pi, int x, int y) const
 {
        value_->draw(pi, x, y);
-       //drawMarkers(pi, x, y);
 }
 
 
diff --git a/src/mathed/MathRow.cpp b/src/mathed/MathRow.cpp
index 730d7a4..cfb4164 100644
--- a/src/mathed/MathRow.cpp
+++ b/src/mathed/MathRow.cpp
@@ -38,7 +38,8 @@ namespace lyx {
 
 MathRow::Element::Element(MetricsInfo const & mi, Type t, MathClass mc)
        : type(t), mclass(mc), before(0), after(0), 
macro_nesting(mi.base.macro_nesting),
-         inset(0), compl_unique_to(0), macro(0), color(Color_red)
+         marker(InsetMath::NO_MARKER), inset(0), compl_unique_to(0),
+         macro(0), color(Color_red)
 {}
 
 
@@ -64,28 +65,40 @@ MathRow::MathRow(MetricsInfo & mi, MathData const * ar)
        /* Do spacing only in math mode. This test is a bit clumsy,
         * but it is used in other places for guessing the current mode.
         */
-       if (!isMathFont(mi.base.fontname))
-               return;
+       bool const dospacing = isMathFont(mi.base.fontname);
 
        // update classes
-       for (int i = 1 ; i != static_cast<int>(elements_.size()) - 1 ; ++i) {
-               if (elements_[i].mclass == MC_UNKNOWN)
-                       continue;
-               update_class(elements_[i].mclass, elements_[before(i)].mclass,
-                            elements_[after(i)].mclass);
+       if (dospacing) {
+               for (int i = 1 ; i != static_cast<int>(elements_.size()) - 1 ; 
++i) {
+                       if (elements_[i].mclass != MC_UNKNOWN)
+                               update_class(elements_[i].mclass, 
elements_[before(i)].mclass,
+                                                        
elements_[after(i)].mclass);
+               }
        }
 
        // set spacing
        // We go to the end to handle spacing at the end of equation
        for (int i = 1 ; i != static_cast<int>(elements_.size()) ; ++i) {
-               if (elements_[i].mclass == MC_UNKNOWN)
+               Element & e = elements_[i];
+
+               if (e.mclass == MC_UNKNOWN)
                        continue;
+
                Element & bef = elements_[before(i)];
-               int spc = class_spacing(bef.mclass, elements_[i].mclass, 
mi.base);
-               bef.after = spc / 2;
-               // this is better than spc / 2 to avoid rounding problems
-               elements_[i].before = spc - spc / 2;
+               if (dospacing) {
+                       int spc = class_spacing(bef.mclass, e.mclass, mi.base);
+                       bef.after += spc / 2;
+                       // this is better than spc / 2 to avoid rounding 
problems
+                       e.before += spc - spc / 2;
+               }
+
+               // finally reserve space for markers
+               if (bef.marker != Inset::NO_MARKER)
+                       bef.after = max(bef.after, 1);
+               if (e.marker != Inset::NO_MARKER)
+                       e.before = max(e.before, 1);
        }
+
        // Do not lose spacing allocated to extremities
        if (!elements_.empty()) {
                elements_[after(0)].before += elements_.front().after;
@@ -166,6 +179,18 @@ void MathRow::metrics(MetricsInfo & mi, Dimension & dim) 
const
                        break;
                }
 
+               // handle vertical space for markers
+               switch(e.marker) {
+               case InsetMath::NO_MARKER:
+                       break;
+               case InsetMath::MARKER:
+                       ++d.des;
+                       break;
+               case InsetMath::MARKER2:
+                       ++d.asc;
+                       ++d.des;
+               }
+
                if (!d.empty()) {
                        dim += d;
                        // Now add the dimension to current macros and 
arguments.
@@ -185,6 +210,43 @@ void MathRow::metrics(MetricsInfo & mi, Dimension & dim) 
const
 }
 
 
+namespace {
+
+void drawMarkers(PainterInfo const & pi, MathRow::Element const & e, int const 
x, int const y)
+{
+       if (e.marker == InsetMath::NO_MARKER)
+               return;
+
+       CoordCache const & coords = pi.base.bv->coordCache();
+       Dimension const dim = coords.getInsets().dim(e.inset);
+
+       // the marker is before/after the inset. Normally some space has been 
reserved already.
+       int const l = x + e.before - 1;
+       int const r = x + dim.width() - e.after;
+
+       // Duplicated from Inset.cpp and adapted. It is believed that the
+       // Inset version should die eventually
+       ColorCode pen_color = e.inset->mouseHovered(pi.base.bv) || 
e.inset->editing(pi.base.bv)?
+               Color_mathframe : Color_mathcorners;
+
+       int const d = y + dim.descent();
+       pi.pain.line(l, d - 3, l, d, pen_color);
+       pi.pain.line(r, d - 3, r, d, pen_color);
+       pi.pain.line(l, d, l + 3, d, pen_color);
+       pi.pain.line(r - 3, d, r, d, pen_color);
+
+       if (e.marker == InsetMath::MARKER)
+               return;
+
+       int const a = y - dim.ascent();
+       pi.pain.line(l, a + 3, l, a, pen_color);
+       pi.pain.line(r, a + 3, r, a, pen_color);
+       pi.pain.line(l, a, l + 3, a, pen_color);
+       pi.pain.line(r - 3, a, r, a, pen_color);
+}
+
+}
+
 void MathRow::draw(PainterInfo & pi, int x, int const y) const
 {
        CoordCache & coords = pi.base.bv->coordCache();
@@ -202,11 +264,14 @@ void MathRow::draw(PainterInfo & pi, int x, int const y) 
const
                        e.inset->draw(pi, x + e.before, y);
                        coords.insets().add(e.inset, x, y);
                        coords.insets().add(e.inset, d);
+                       drawMarkers(pi, e, x, y);
                        x += d.wid;
                        break;
                }
                case BEG_MACRO:
                        coords.insets().add(e.macro, x, y);
+
+                       drawMarkers(pi, e, x, y);
                        break;
                case BEG_ARG:
                        coords.arrays().add(e.ar, x, y);
diff --git a/src/mathed/MathRow.h b/src/mathed/MathRow.h
index 818b690..760ac18 100644
--- a/src/mathed/MathRow.h
+++ b/src/mathed/MathRow.h
@@ -12,6 +12,7 @@
 #ifndef MATH_ROW_H
 #define MATH_ROW_H
 
+#include "InsetMath.h"
 #include "MathClass.h"
 
 #include "ColorCode.h"
@@ -69,6 +70,8 @@ public:
                int before, after;
                /// count wether the current mathdata is nested in macro(s)
                int macro_nesting;
+               /// Marker type
+               InsetMath::marker_type marker;
 
                /// When type is INSET
                /// the math inset

commit 605438f26df9e25277e1c3799e6022f3ff18d466
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Thu Jan 5 13:25:28 2017 +0100

    Fix issues with macro_nesting handling
    
    The rewrite of macro_nesting done at 0f15dcc6 was faulty, in
    particular since the information should be available also at draw
    time. To this end, we revert the patch of the said commit that removes
    macro nesting information from MathRow::Element. In the next commit,
    we will change the marker code so that MathRow::draw does not need the
    nesting information.
    
    Actually the code is now cleaner since the macro nesting stack of
    MathRow::metrics can be removed.

diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index ba559e7..093dcda 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -58,9 +58,9 @@ MathClass InsetMath::mathClass() const
 }
 
 
-bool InsetMath::addToMathRow(MathRow & mrow, MetricsInfo & ) const
+bool InsetMath::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
 {
-       MathRow::Element e(MathRow::INSET, mathClass());
+       MathRow::Element e(mi, MathRow::INSET, mathClass());
        e.inset = this;
        mrow.push_back(e);
        return true;
diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp
index 7670f48..8aeb542 100644
--- a/src/mathed/MathMacro.cpp
+++ b/src/mathed/MathMacro.cpp
@@ -85,7 +85,7 @@ public:
                Changer chg = make_change(mi.base.macro_nesting,
                                          mathMacro_->nesting() == 1 ? 0 : 
mathMacro_->nesting());
 
-               MathRow::Element e_beg(MathRow::BEG_ARG);
+               MathRow::Element e_beg(mi, MathRow::BEG_ARG);
                e_beg.macro = mathMacro_;
                e_beg.ar = &mathMacro_->cell(idx_);
                mrow.push_back(e_beg);
@@ -98,13 +98,13 @@ public:
                // then we insert a box instead.
                if (!has_contents && mathMacro_->nesting() == 1) {
                        // mathclass is ord because it should be spaced as a 
normal atom
-                       MathRow::Element e(MathRow::BOX, MC_ORD);
+                       MathRow::Element e(mi, MathRow::BOX, MC_ORD);
                        e.color = Color_mathline;
                        mrow.push_back(e);
                        has_contents = true;
                }
 
-               MathRow::Element e_end(MathRow::END_ARG);
+               MathRow::Element e_end(mi, MathRow::END_ARG);
                e_end.macro = mathMacro_;
                e_end.ar = &mathMacro_->cell(idx_);
 
@@ -308,7 +308,7 @@ bool MathMacro::addToMathRow(MathRow & mrow, MetricsInfo & 
mi) const
            || d->editing_[mi.base.bv])
                return InsetMath::addToMathRow(mrow, mi);
 
-       MathRow::Element e_beg(MathRow::BEG_MACRO);
+       MathRow::Element e_beg(mi, MathRow::BEG_MACRO);
        e_beg.macro = this;
        mrow.push_back(e_beg);
 
@@ -320,13 +320,13 @@ bool MathMacro::addToMathRow(MathRow & mrow, MetricsInfo 
& mi) const
        // insert a grey box instead.
        if (!has_contents && mi.base.macro_nesting == 1) {
                // mathclass is unknown because it is irrelevant for spacing
-               MathRow::Element e(MathRow::BOX);
+               MathRow::Element e(mi, MathRow::BOX);
                e.color = Color_mathmacroblend;
                mrow.push_back(e);
                has_contents = true;
        }
 
-       MathRow::Element e_end(MathRow::END_MACRO);
+       MathRow::Element e_end(mi, MathRow::END_MACRO);
        e_end.macro = this;
        mrow.push_back(e_end);
 
diff --git a/src/mathed/MathRow.cpp b/src/mathed/MathRow.cpp
index 703d25e..730d7a4 100644
--- a/src/mathed/MathRow.cpp
+++ b/src/mathed/MathRow.cpp
@@ -36,16 +36,16 @@ using namespace std;
 namespace lyx {
 
 
-MathRow::Element::Element(Type t, MathClass mc)
-       : type(t), mclass(mc), before(0), after(0), inset(0),
-         compl_unique_to(0), macro(0), color(Color_red)
+MathRow::Element::Element(MetricsInfo const & mi, Type t, MathClass mc)
+       : type(t), mclass(mc), before(0), after(0), 
macro_nesting(mi.base.macro_nesting),
+         inset(0), compl_unique_to(0), macro(0), color(Color_red)
 {}
 
 
 MathRow::MathRow(MetricsInfo & mi, MathData const * ar)
 {
        // First there is a dummy element of type "open"
-       push_back(Element(DUMMY, MC_OPEN));
+       push_back(Element(mi, DUMMY, MC_OPEN));
 
        // Then insert the MathData argument
        bool const has_contents = ar->addToMathRow(*this, mi);
@@ -53,13 +53,13 @@ MathRow::MathRow(MetricsInfo & mi, MathData const * ar)
        // empty arrays are visible when they are editable
        // we reserve the necessary space anyway (even if nothing gets drawn)
        if (!has_contents) {
-               Element e(BOX, MC_ORD);
+               Element e(mi, BOX, MC_ORD);
                e.color = mi.base.macro_nesting == 0 ? Color_mathline : 
Color_none;
                push_back(e);
        }
 
        // Finally there is a dummy element of type "close"
-       push_back(Element(DUMMY, MC_CLOSE));
+       push_back(Element(mi, DUMMY, MC_CLOSE));
 
        /* Do spacing only in math mode. This test is a bit clumsy,
         * but it is used in other places for guessing the current mode.
@@ -122,12 +122,9 @@ void MathRow::metrics(MetricsInfo & mi, Dimension & dim) 
const
        // arguments, it is necessary to keep track of them.
        map<MathMacro const *, Dimension> dim_macros;
        map<MathData const *, Dimension> dim_arrays;
-       // this vector remembers the stack of macro nesting values
-       vector<int> macro_nesting;
-       macro_nesting.push_back(mi.base.macro_nesting);
        CoordCache & coords = mi.base.bv->coordCache();
        for (Element const & e : elements_) {
-               mi.base.macro_nesting = macro_nesting.back();
+               mi.base.macro_nesting = e.macro_nesting;
                Dimension d;
                switch (e.type) {
                case DUMMY:
@@ -138,14 +135,12 @@ void MathRow::metrics(MetricsInfo & mi, Dimension & dim) 
const
                        coords.insets().add(e.inset, d);
                        break;
                case BEG_MACRO:
-                       macro_nesting.push_back(e.macro->nesting());
                        e.macro->macro()->lock();
                        // Add a macro to current list
                        dim_macros[e.macro] = Dimension();
                        break;
                case END_MACRO:
                        LATTEST(dim_macros.find(e.macro) != dim_macros.end());
-                       macro_nesting.pop_back();
                        e.macro->macro()->unlock();
                        // Cache the dimension of the macro and remove it from
                        // tracking map.
@@ -154,18 +149,14 @@ void MathRow::metrics(MetricsInfo & mi, Dimension & dim) 
const
                        break;
                        // This is basically like macros
                case BEG_ARG:
-                       if (e.macro) {
-                               macro_nesting.push_back(e.macro->nesting());
+                       if (e.macro)
                                e.macro->macro()->unlock();
-                       }
                        dim_arrays[e.ar] = Dimension();
                        break;
                case END_ARG:
                        LATTEST(dim_arrays.find(e.ar) != dim_arrays.end());
-                       if (e.macro) {
-                               macro_nesting.pop_back();
+                       if (e.macro)
                                e.macro->macro()->lock();
-                       }
                        coords.arrays().add(e.ar, dim_arrays[e.ar]);
                        dim_arrays.erase(e.ar);
                        break;
diff --git a/src/mathed/MathRow.h b/src/mathed/MathRow.h
index f7f156c..818b690 100644
--- a/src/mathed/MathRow.h
+++ b/src/mathed/MathRow.h
@@ -59,7 +59,7 @@ public:
        struct Element
        {
                ///
-               Element(Type t, MathClass mc = MC_UNKNOWN);
+               Element(MetricsInfo const & mi, Type t, MathClass mc = 
MC_UNKNOWN);
 
                /// Classifies the contents of the object
                Type type;
@@ -67,6 +67,8 @@ public:
                MathClass mclass;
                /// the spacing around the element
                int before, after;
+               /// count wether the current mathdata is nested in macro(s)
+               int macro_nesting;
 
                /// When type is INSET
                /// the math inset

commit 30da554e5952c7280338b0ef4225022a8655684f
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Wed Jan 11 10:43:54 2017 +0100

    Update man page

diff --git a/lyx.1in b/lyx.1in
index ed1be04..afdc134 100644
--- a/lyx.1in
+++ b/lyx.1in
@@ -85,6 +85,11 @@ else other than "\fBall\fR", "\fBmain\fR" or "\fBnone\fR", 
the behavior is as
 if "\fBall\fR" was specified, but what follows is left on the command line for
 further processing.
 .TP
+\fB \-\-ignore\-error\-message\fP \fIwhich
+allows you to ignore specific LaTeX error messages.
+Do not use for final documents! Currently supported values:
+"\fBmissing_glyphs\fR" Fontspec "missing glyphs" error.
+.TP
 \fB \-n [\-\-no\-remote]\fP
 open documents passed as arguments in a new instance, even if another
 instance of LyX is already running.

-----------------------------------------------------------------------

Summary of changes:
 lyx.1in                                            |    5 +
 src/insets/Inset.h                                 |   12 +-
 src/mathed/InsetMath.cpp                           |   39 ++-----
 src/mathed/InsetMath.h                             |   12 +--
 src/mathed/InsetMathBoldSymbol.cpp                 |    4 +-
 src/mathed/InsetMathBox.cpp                        |   32 +++---
 src/mathed/InsetMathBox.h                          |    4 +
 src/mathed/InsetMathBrace.cpp                      |    2 -
 src/mathed/InsetMathCancel.cpp                     |    5 +-
 src/mathed/InsetMathCancelto.cpp                   |   11 +-
 src/mathed/InsetMathClass.cpp                      |    4 +-
 src/mathed/InsetMathColor.cpp                      |    4 +-
 src/mathed/InsetMathComment.cpp                    |    4 +-
 src/mathed/InsetMathDecoration.cpp                 |    5 +-
 src/mathed/InsetMathEnsureMath.cpp                 |    2 -
 src/mathed/InsetMathEnv.cpp                        |    4 +-
 src/mathed/InsetMathFont.cpp                       |    4 +-
 src/mathed/InsetMathFontOld.cpp                    |    4 +-
 src/mathed/InsetMathFrac.cpp                       |   20 ++--
 src/mathed/InsetMathFrac.h                         |    5 +-
 src/mathed/InsetMathGrid.cpp                       |    3 -
 src/mathed/InsetMathGrid.h                         |    7 +-
 src/mathed/InsetMathHull.cpp                       |    6 +-
 src/mathed/InsetMathLefteqn.cpp                    |    4 +-
 src/mathed/InsetMathNest.h                         |    3 -
 src/mathed/InsetMathOverset.cpp                    |    2 -
 src/mathed/InsetMathPhantom.cpp                    |    5 +-
 src/mathed/InsetMathRoot.cpp                       |    2 -
 src/mathed/InsetMathScript.cpp                     |    2 -
 src/mathed/InsetMathSideset.cpp                    |    2 -
 src/mathed/InsetMathSize.cpp                       |    4 +-
 src/mathed/InsetMathSqrt.cpp                       |   10 +-
 src/mathed/InsetMathStackrel.cpp                   |    2 -
 src/mathed/InsetMathUnderset.cpp                   |    2 -
 src/mathed/InsetMathXArrow.cpp                     |    4 +-
 src/mathed/MathMacro.cpp                           |   61 +++++++----
 src/mathed/MathMacro.h                             |    4 +-
 src/mathed/MathMacroTemplate.cpp                   |    2 -
 src/mathed/MathRow.cpp                             |  116 +++++++++++++++-----
 src/mathed/MathRow.h                               |    7 +-
 src/tex2lyx/test/CJK.lyx.lyx                       |    2 +-
 src/tex2lyx/test/CJKutf8.lyx.lyx                   |    2 +-
 src/tex2lyx/test/DummyDocument.lyx.lyx             |    2 +-
 src/tex2lyx/test/Dummy~Document.lyx.lyx            |    2 +-
 src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx         |    2 +-
 src/tex2lyx/test/algo2e.lyx.lyx                    |    2 +-
 .../test/box-color-size-space-align.lyx.lyx        |    2 +-
 src/tex2lyx/test/test-insets-basic.lyx.lyx         |    9 ++-
 src/tex2lyx/test/test-insets.lyx.lyx               |    9 ++-
 src/tex2lyx/test/test-memoir.lyx.lyx               |    2 +-
 src/tex2lyx/test/test-modules.lyx.lyx              |    2 +-
 src/tex2lyx/test/test-refstyle-theorems.lyx.lyx    |   29 +++++-
 src/tex2lyx/test/test-scr.lyx.lyx                  |    2 +-
 src/tex2lyx/test/test-structure.lyx.lyx            |    2 +-
 src/tex2lyx/test/test.lyx.lyx                      |    4 +-
 src/tex2lyx/test/verbatim.lyx.lyx                  |    2 +-
 56 files changed, 271 insertions(+), 234 deletions(-)


hooks/post-receive
-- 
Repository for new features

Reply via email to