+ if (recheck_needed)
+ recheck_beam ();
+}
+
+void
+Auto_beam_engraver::recheck_beam ()
+{
+ /*
+ Recheck the beam after the shortest duration has changed
+ If shorter duration has created a new break, typeset the
+ first part of the beam and reset the current beam to just
+ the last part of the beam
+ */
+ Beaming_pattern *new_grouping_ = 0;
+ vector<Item *> *new_stems_ = 0;
+ Moment temporary_shortest_mom;
+ SCM temporary_beam_settings;
+
+ bool found_end;
+
+
+ for (vsize i = 0; i < stems_->size () - 1;)
+ {
+ found_end = test_moment (STOP,
+ grouping_->end_moment (i),
+ shortest_mom_);
+ if (!found_end)
+ i++;
+ else
+ {
+ /*
+ Save the current beam settings and shortest_mom_
+ Necessary because end_beam destroys them
+ */
+ temporary_shortest_mom = shortest_mom_;
+ temporary_beam_settings = beam_settings_;
+
+ /* Eliminate (and save) the items no longer part of the first beam */
+
+ new_grouping_ = grouping_->split_pattern (i);
+ new_stems_ = remove_end_stems (i);
+
+ end_beam ();
+ typeset_beam ();
+
+ /* now recreate the unbeamed data structures */
+ stems_ = new_stems_;
+ grouping_ = new_grouping_;
+ shortest_mom_ = temporary_shortest_mom;
+ beam_settings_ = temporary_beam_settings;
+
+ i = 0;
+ }
+
+ }
+
+}
+
+/*
+ Remove all stems with an index greater than split_index
+ from stems_, and return a vector containing all of the
+ removed stems
+*/
+vector <Item *> *
+Auto_beam_engraver::remove_end_stems (vsize split_index)
+{
+ vector <Item *> *removed_stems = 0;
+ removed_stems = new vector <Item *>;
+
+ for (vsize j = split_index + 1; j < stems_->size (); j++)
+ removed_stems->push_back ((*stems_).at (j));
+ for (vsize j = split_index + 1; j < stems_->size ();)
+ stems_->pop_back ();
+ return removed_stems;