+ }
+
+ if (gh_pair_p (right_neighbors))
+ {
+ cols[i]->set_grob_property ("right-neighbors", right_neighbors);
+ }
+ }
+}
+
+/*
+ Set neighboring columns that have no left/right-neighbor set
+ yet. Only do breakable non-musical columns, and musical columns.
+*/
+void
+Spacing_spanner::set_implicit_neighbor_columns (Link_array<Grob> cols)
+{
+ for (int i = 0; i < cols.size (); i++)
+ {
+ Item * it = dynamic_cast<Item*>(cols[i]);
+ if (!Item::breakable_b (it) && !Paper_column::musical_b (it))
+ continue;
+
+ // it->breakable || it->musical
+
+ /*
+ sloppy with typnig left/right-neighbors should take list, but paper-column found instead.
+ */
+ SCM ln = cols[i] ->get_grob_property ("left-neighbors");
+ if (!gh_pair_p (ln) && i )
+ {
+ cols[i]->set_grob_property ("left-neighbors", gh_cons (cols[i-1]->self_scm(), SCM_EOL));
+ }
+
+ SCM rn = cols[i] ->get_grob_property ("right-neighbors");
+ if (!gh_pair_p (rn) && i < cols.size () - 1)
+ {
+ cols[i]->set_grob_property ("right-neighbors", gh_cons (cols[i + 1]->self_scm(), SCM_EOL));
+ }
+ }
+}
+
+
+MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs,1);
+SCM
+Spacing_spanner::set_springs (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+
+ Link_array<Grob> all (me->pscore_l_->line_l_->column_l_arr ()) ;
+
+ set_explicit_neighbor_columns (all);
+
+ Rational global_shortest = find_shortest (me, all);
+ prune_loose_colunms (me, &all, global_shortest);
+ set_implicit_neighbor_columns (all);
+
+
+ int j = 0;
+ for (int i = 1; i < all.size (); i++)
+ {
+ Grob *sc = all[i];
+ if (Item::breakable_b (sc))
+ {
+ Link_array<Grob> measure (all.slice (j, i+1));
+ do_measure (global_shortest, me, &measure);
+ j = i;
+ }
+ }
+
+ return SCM_UNSPECIFIED;
+}
+
+
+/*
+ We want the shortest note that is also "common" in the piece, so we
+ find the shortest in each measure, and take the most frequently
+ found duration.
+
+ This probably gives weird effects with modern music, where every
+ note has a different duration, but hey, don't write that kind of
+ stuff, then.
+
+*/
+Rational
+Spacing_spanner::find_shortest (Grob *me, Link_array<Grob> const &cols)
+{
+ /*
+ ascending in duration
+ */
+ Array<Rational> durations;
+ Array<int> counts;
+
+ Rational shortest_in_measure;
+ shortest_in_measure.set_infinite (1);
+
+ for (int i =0 ; i < cols.size (); i++)
+ {
+ if (Paper_column::musical_b (cols[i]))
+ {
+ Moment *when = unsmob_moment (cols[i]->get_grob_property ("when"));
+
+ /*
+ ignore grace notes for shortest notes.
+ */
+ if (when && when->grace_part_)
+ continue;