The branch, cleanup/updateMacros4, has been updated.
  discards  e63184eb41cee93129502394263661d4b0363ac7 (commit)
  discards  f85a259237630c219d056bad202dd5106766764d (commit)
  discards  0cbdec8e97afb4af4798b773254321b8ecd0695d (commit)
  discards  f9f22e7be975850628efb8730b46c27412d43063 (commit)
  discards  5ea5c5dc09ccc7e9e2dc60741dea444cefd7272d (commit)
  discards  668ad347a0b199792c8c35e2c0cc421d1634db1e (commit)
  discards  5fbe354bfa7f6d91ce3364592b0d95e1b46fd2fe (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (e63184eb41cee93129502394263661d4b0363ac7)
            \
             N -- N -- N (f0feeeee51ed7d1e609699c6d568a892e2c69030)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

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

commit f0feeeee51ed7d1e609699c6d568a892e2c69030
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Thu Nov 12 19:26:44 2020 -0500

    Move updateMacros code to Paragraph class.
    
    My dream is that this will eventually allow us to run updateMacros
    only on a Paragraph when, say, a character is entered.

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index c668f3b..8a97209 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4553,6 +4553,21 @@ void Paragraph::updateWords()
 }
 
 
+void Paragraph::updateMacros(DocIterator const & us, DocIterator const & scope)
+{
+       // We expect a DocIterator pointing at the beginning of this paragraph.
+       LBUFERR(&us.paragraph() == this && us.pos() == 0);
+       DocIterator it = us;
+       // iterate over the insets of the current paragraph
+       for (auto const & insit : insetList()) {
+               it.pos() = insit.pos;
+               it.push_back(CursorSlice(*insit.inset));
+               insit.inset->updateMacros(it, scope);
+               it.pop_back();
+       }
+}
+
+
 void Paragraph::Private::appendSkipPosition(SkipPositions & skips, pos_type 
const pos) const
 {
        SkipPositionsIterator begin = skips.begin();
diff --git a/src/Paragraph.h b/src/Paragraph.h
index 4812684..24bdbc8 100644
--- a/src/Paragraph.h
+++ b/src/Paragraph.h
@@ -476,6 +476,8 @@ public:
                word_location const loc, bool const ignore_deleted = false) 
const;
        ///
        void updateWords();
+       ///
+       void updateMacros(DocIterator const & us, DocIterator const & scope);
 
        /// Spellcheck word at position \p from and fill in found misspelled 
word
        /// and \p suggestions if \p do_suggestion is true.
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index ee04ee3..942ef77 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -925,14 +925,7 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
        pit_type const lastpit = it.lastpit();
        // look for macros in each paragraph
        while (it.pit() <= lastpit) {
-               Paragraph & par = it.paragraph();
-               // iterate over the insets of the current paragraph
-               for (auto const & insit : par.insetList()) {
-                       it.pos() = insit.pos;
-                       it.push_back(CursorSlice(*insit.inset));
-                       insit.inset->updateMacros(it, ourscope);
-                       it.pop_back();
-               }
+               it.paragraph().updateMacros(it, ourscope);
                // next paragraph
                it.pit()++;
                it.pos() = 0;

commit 36bf21c493ceb4522559760d2ad808d1032b9e58
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Thu Nov 12 18:07:35 2020 -0500

    Now just use the Inset::updateMacros method.
    
    I did all this step by step so (a) I could check the output along
    the way and (b) so it will be easier to isolate problems if those
    should arise.

diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 6585586..ee04ee3 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -926,48 +926,13 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
        // look for macros in each paragraph
        while (it.pit() <= lastpit) {
                Paragraph & par = it.paragraph();
-
                // iterate over the insets of the current paragraph
                for (auto const & insit : par.insetList()) {
                        it.pos() = insit.pos;
-
-                       if (InsetText * itext = insit.inset->asInsetText()) {
-                               // collect macros in inset
-                               it.push_back(CursorSlice(*insit.inset));
-                               itext->updateMacros(it, ourscope);
-                               it.pop_back();
-                               continue;
-                       }
-
-                       if (InsetTabular * itext = 
insit.inset->asInsetTabular()) {
-                               it.push_back(CursorSlice(*insit.inset));
-                               itext->updateMacros(it, ourscope);
-                               it.pop_back();
-                               continue;
-                       }
-
-                       // is it an external file?
-                       if (insit.inset->lyxCode() == INCLUDE_CODE) {
-                               insit.inset->updateMacros(it, ourscope);
-                               continue;
-                       }
-
-                       InsetMath * im = insit.inset->asInsetMath();
-                       if (im)  {
-                               InsetMathHull * hull = im->asHullInset();
-                               if (hull)
-                                       hull->updateMacros(it, ourscope);
-                       }
-
-                       if (insit.inset->lyxCode() != MATHMACRO_CODE)
-                               continue;
-
-                       // get macro data
-                       InsetMathMacroTemplate * macroTemplate =
-                               insit.inset->asInsetMath()->asMacroTemplate();
-                       macroTemplate->updateMacros(it, ourscope);
+                       it.push_back(CursorSlice(*insit.inset));
+                       insit.inset->updateMacros(it, ourscope);
+                       it.pop_back();
                }
-
                // next paragraph
                it.pit()++;
                it.pos() = 0;

commit e19bf434f61c100cef88f7515026e0a36e4b39df
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Thu Nov 12 18:03:36 2020 -0500

    Move updateMacros code into InsetMathMacroTemplate.

diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index dcf7576..6585586 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -963,21 +963,9 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
                                continue;
 
                        // get macro data
-                       InsetMathMacroTemplate & macroTemplate =
-                               *insit.inset->asInsetMath()->asMacroTemplate();
-                       MacroContext mc(&buffer(), it);
-                       macroTemplate.updateToContext(mc);
-
-                       // valid?
-                       bool valid = macroTemplate.validMacro();
-                       // FIXME: Should be fixNameAndCheckIfValid() in fact,
-                       // then the BufferView's cursor will be invalid in
-                       // some cases which leads to crashes.
-                       if (!valid)
-                               continue;
-
-                       // register macro
-                       buffer().registerMacro(macroTemplate.name(), it, 
ourscope);
+                       InsetMathMacroTemplate * macroTemplate =
+                               insit.inset->asInsetMath()->asMacroTemplate();
+                       macroTemplate->updateMacros(it, ourscope);
                }
 
                // next paragraph
diff --git a/src/mathed/InsetMathMacroTemplate.cpp 
b/src/mathed/InsetMathMacroTemplate.cpp
index e5c7db9..a445b4d 100644
--- a/src/mathed/InsetMathMacroTemplate.cpp
+++ b/src/mathed/InsetMathMacroTemplate.cpp
@@ -460,6 +460,25 @@ docstring InsetMathMacroTemplate::name() const
 }
 
 
+void InsetMathMacroTemplate::updateMacros(DocIterator const & us, DocIterator 
const & scope)
+{
+       // This matches the previous code, but I am not sure why it
+       // should be like this.
+       DocIterator it = us;
+       it.pop_back();
+       MacroContext mc(&buffer(), it);
+       updateToContext(mc);
+       // FIXME: Should be fixNameAndCheckIfValid() in fact,
+       // then the BufferView's cursor will be invalid in
+       // some cases which leads to crashes.
+       if (!validMacro())
+               return;
+
+       // register macro
+       buffer().registerMacro(name(), it, scope);
+}
+
+
 void InsetMathMacroTemplate::updateToContext(MacroContext const & mc)
 {
        redefinition_ = mc.get(name()) != nullptr;
diff --git a/src/mathed/InsetMathMacroTemplate.h 
b/src/mathed/InsetMathMacroTemplate.h
index 0940896..7c9a680 100644
--- a/src/mathed/InsetMathMacroTemplate.h
+++ b/src/mathed/InsetMathMacroTemplate.h
@@ -87,6 +87,8 @@ public:
 
        /// decide whether its a redefinition
        void updateToContext(MacroContext const & mc);
+       ///
+       void updateMacros(DocIterator const & us, DocIterator const & scope) 
override;
 
        ///
        void draw(PainterInfo & pi, int x, int y) const override;

commit a946efe7590de26c79e48fed552d5689f65cd763
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Thu Nov 12 17:48:51 2020 -0500

    Move updateMacros code to InsetInclude.

diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index 75a41c3..eff6fb5 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -1400,6 +1400,16 @@ void InsetInclude::updateCommand()
 }
 
 
+void InsetInclude::updateMacros(DocIterator const & us, DocIterator const & 
scope)
+{
+       buffer().setMacroLock();
+       loadIfNeeded();
+       buffer().clearMacroLock();
+       if (child_buffer_)
+               buffer().registerChild(child_buffer_, us, scope);
+}
+
+
 void InsetInclude::updateBuffer(ParIterator const & it, UpdateType utype, bool 
const deleted)
 {
        file_exist_ = includedFileExist();
diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h
index a254254..046f481 100644
--- a/src/insets/InsetInclude.h
+++ b/src/insets/InsetInclude.h
@@ -106,6 +106,8 @@ public:
        ///
        void updateBuffer(ParIterator const &, UpdateType, bool const deleted = 
false) override;
        ///
+       void updateMacros(DocIterator const & us, DocIterator const & scope) 
override;
+       ///
        std::string contextMenuName() const override;
        //@}
 
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 834bf73..dcf7576 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -948,15 +948,7 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
 
                        // is it an external file?
                        if (insit.inset->lyxCode() == INCLUDE_CODE) {
-                               // get buffer of external file
-                               InsetInclude const & incinset =
-                                       static_cast<InsetInclude const 
&>(*insit.inset);
-                               buffer().setMacroLock();
-                               Buffer * child = incinset.loadIfNeeded();
-                               buffer().clearMacroLock();
-                               if (!child)
-                                       continue;
-                               buffer().registerChild(child, it, ourscope);
+                               insit.inset->updateMacros(it, ourscope);
                                continue;
                        }
 

commit a8d793ecae67947d6013b35b0f4d234b9634df69
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Thu Nov 12 17:43:57 2020 -0500

    Move code to InsetMathHull::updateMacros.

diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index d268d2e..834bf73 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -964,7 +964,7 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
                        if (im)  {
                                InsetMathHull * hull = im->asHullInset();
                                if (hull)
-                                       hull->recordLocation(it);
+                                       hull->updateMacros(it, ourscope);
                        }
 
                        if (insit.inset->lyxCode() != MATHMACRO_CODE)
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 43f4958..5464115 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -238,6 +238,13 @@ namespace {
 } // namespace
 
 
+// FIXME This may or may not be the right place to do this.
+void InsetMathHull::updateMacros(DocIterator const & us, DocIterator const &)
+{
+       recordLocation(us);
+}
+
+
 void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype, 
bool const deleted)
 {
        if (!buffer_) {
diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h
index 0b085a1..ef77a75 100644
--- a/src/mathed/InsetMathHull.h
+++ b/src/mathed/InsetMathHull.h
@@ -50,6 +50,8 @@ public:
        void setBuffer(Buffer &) override;
        ///
        void updateBuffer(ParIterator const &, UpdateType, bool const deleted = 
false) override;
+       /// This must be called by any subclass that overrides it!
+       void updateMacros(DocIterator const & us, DocIterator const & scope) 
override;
        ///
        void addToToc(DocIterator const & di, bool output_active,
                                  UpdateType utype, TocBackend & backend) const 
override;

commit c41b72acc491e330c4b77393cb53ecb3abafdbe6
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Thu Nov 12 17:20:48 2020 -0500

    Move updateMacros code into InsetTabular

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index e6c9892..75886f5 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -4813,6 +4813,19 @@ void InsetTabular::edit(Cursor & cur, bool front, 
EntryDirection)
 }
 
 
+void InsetTabular::updateMacros(DocIterator const & us, DocIterator const & 
scope)
+{
+       DocIterator pos = us;
+       size_t const numcells = pos.nargs();
+       for (size_t c = 0; c < numcells; ++c, pos.top().forwardIdx()) {
+               shared_ptr<InsetTableCell> cp = cell(c);
+               // this test should be unnecessary, right?
+               if (cp)
+                       cp->updateMacros(pos, scope);
+       }
+}
+
+
 void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype, bool 
const /*deleted*/)
 {
        // In a longtable, tell captions what the current float is
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index 2ee107a..c27fec0 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -1054,6 +1054,8 @@ public:
        /// Update the counters of this inset and of its contents
        void updateBuffer(ParIterator const &, UpdateType, bool const deleted = 
false) override;
        ///
+       void updateMacros(DocIterator const & us, DocIterator const & scope) 
override;
+       ///
        void addToToc(DocIterator const & di, bool output_active,
                                  UpdateType utype, TocBackend & backend) const 
override;
 
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 95768ae..d268d2e 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -62,6 +62,7 @@
 #include "mathed/InsetMathHull.h"
 #include "mathed/MacroTable.h"
 #include "mathed/InsetMathMacroTemplate.h"
+#include "insets/InsetTabular.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
@@ -938,14 +939,10 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
                                continue;
                        }
 
-                       if (insit.inset->asInsetTabular()) {
-                               CursorSlice slice(*insit.inset);
-                               size_t const numcells = slice.nargs();
-                               for (; slice.idx() < numcells; 
slice.forwardIdx()) {
-                                       it.push_back(slice);
-                                       updateMacros(it, ourscope);
-                                       it.pop_back();
-                               }
+                       if (InsetTabular * itext = 
insit.inset->asInsetTabular()) {
+                               it.push_back(CursorSlice(*insit.inset));
+                               itext->updateMacros(it, ourscope);
+                               it.pop_back();
                                continue;
                        }
 

commit 22ca29f722c0e66129bdbc3d630e55289f6785d6
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Thu Nov 12 16:33:28 2020 -0500

    Move some processing from the loop into the main InsetText routine.

diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index c6fbfdb..7885046 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -571,6 +571,9 @@ public:
        /// The boolean indicates whether we are preparing for output, e.g.,
        /// of XHTML.
        virtual void updateBuffer(ParIterator const &, UpdateType, bool const) 
{}
+       /// Note that \param us is expected to be a DocIterator pointing at 
this inset.
+       /// We will assert otherwise.
+       virtual void updateMacros(DocIterator const & /* us */, DocIterator 
const & /* scope */) {}
 
        /// Updates the inset's dialog
        virtual Buffer const * updateFrontend() const;
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 9c32d49..95768ae 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -922,7 +922,6 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
 
        DocIterator it = us;
        pit_type const lastpit = it.lastpit();
-
        // look for macros in each paragraph
        while (it.pit() <= lastpit) {
                Paragraph & par = it.paragraph();
@@ -931,20 +930,10 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
                for (auto const & insit : par.insetList()) {
                        it.pos() = insit.pos;
 
-                       if (InsetText const * itext = 
insit.inset->asInsetText()) {
+                       if (InsetText * itext = insit.inset->asInsetText()) {
                                // collect macros in inset
                                it.push_back(CursorSlice(*insit.inset));
-                               if (itext->producesOutput()) {
-                                       // the simple case
-                                       updateMacros(it, scope);
-                               } else {
-                                       // We don't want macros declared in 
notes, comments, etc,
-                                       // to affect anything outside them.
-                                       // New scope which ends just behind the 
inset
-                                       DocIterator new_scope = it;
-                                       ++new_scope.pos();
-                                       updateMacros(it, new_scope);
-                               }
+                               itext->updateMacros(it, ourscope);
                                it.pop_back();
                                continue;
                        }
@@ -954,7 +943,7 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
                                size_t const numcells = slice.nargs();
                                for (; slice.idx() < numcells; 
slice.forwardIdx()) {
                                        it.push_back(slice);
-                                       updateMacros(it, scope);
+                                       updateMacros(it, ourscope);
                                        it.pop_back();
                                }
                                continue;
@@ -970,7 +959,7 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
                                buffer().clearMacroLock();
                                if (!child)
                                        continue;
-                               buffer().registerChild(child, it, scope);
+                               buffer().registerChild(child, it, ourscope);
                                continue;
                        }
 
@@ -999,7 +988,7 @@ void InsetText::updateMacros(DocIterator const & us, 
DocIterator const & scope)
                                continue;
 
                        // register macro
-                       buffer().registerMacro(macroTemplate.name(), it, scope);
+                       buffer().registerMacro(macroTemplate.name(), it, 
ourscope);
                }
 
                // next paragraph
diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h
index 9fdfb6f..079d0f4 100644
--- a/src/insets/InsetText.h
+++ b/src/insets/InsetText.h
@@ -173,7 +173,7 @@ public:
        /// Update the counters of this inset and of its contents
        void updateBuffer(ParIterator const &, UpdateType, bool const deleted = 
false) override;
        ///
-       void updateMacros(DocIterator const & us, DocIterator const & scope);
+       void updateMacros(DocIterator const & us, DocIterator const & scope) 
override;
        ///
        void setMacrocontextPositionRecursive(DocIterator const & pos);
        ///

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

Summary of changes:


hooks/post-receive
-- 
Repository for new features
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to