- Grob * se = unsmob_grob (e);
-
- Real space = Staff_symbol_referencer::staff_space (se);
- return ly_interval2scm (Interval (-space, space));
+ Grob *me = unsmob_grob (smob);
+ Grob *stem = unsmob_grob (me->get_object ("stem"));
+ Spanner *beam = Stem::get_beam (stem);
+
+ if (beam)
+ {
+ Real dy = 0;
+ SCM s = beam->get_property ("quantized-positions");
+ if (is_number_pair (s))
+ dy = - scm_to_double (scm_car (s)) + scm_to_double (scm_cdr (s));
+
+ Grob *s2 = Beam::last_normal_stem (beam);
+ Grob *s1 = Beam::first_normal_stem (beam);
+
+ Grob *common = s1->common_refpoint (s2, X_AXIS);
+ Real dx = s2->relative_coordinate (common, X_AXIS) -
+ s1->relative_coordinate (common, X_AXIS);
+
+ return scm_from_double (dx ? dy / dx : 0);
+ }
+ else
+ /* down stems with flags should have more sloped trems (helps avoid
+ flag/stem collisions without making the stem very long) */
+ return scm_from_double (
+ (Stem::duration_log (stem) >= 3 && get_grob_direction (stem) == DOWN) ?
+ 0.40 : 0.25);