From 2a3b30a8a0269f9f6359706887b315c52fbe0142 Mon Sep 17 00:00:00 2001
From: hanwen <hanwen>
Date: Sat, 13 Mar 2004 10:51:51 +0000
Subject: [PATCH] * lily/include/global-context.hh (Context): clean-up data
 hiding.

* lily/include/music-iterator.hh (class Music_iterator): clean-up
data hiding.

* lily/include/grace-fixup.hh (struct Grace_fixup): new file.

* input/regression/stem-shorten.ly: add chord case.

* lily/stem.cc (get_default_stem_end_position): shorten stems
triggered by note-head positions, not by forced-direction. This
fixes a bug with too short stems.
---
 ChangeLog                           | 15 +++++++++
 input/regression/staccato-pos.ly    | 23 ++++++++------
 input/regression/stem-shorten.ly    | 21 ++++++++-----
 lily/global-context.cc              | 28 +++++++----------
 lily/hyphen-engraver.cc             |  6 ++--
 lily/include/global-context.hh      |  5 +--
 lily/include/grace-fixup.hh         | 49 +++++++++++++++++++++++++++++
 lily/include/lily-proto.hh          |  5 +--
 lily/include/music-iterator.hh      |  2 +-
 lily/include/sequential-iterator.hh | 33 +------------------
 lily/multi-measure-rest-engraver.cc | 38 +++++++++++++---------
 lily/music-iterator.cc              |  1 +
 lily/score.cc                       |  7 +++--
 lily/sequential-iterator.cc         | 29 +++++++++--------
 lily/span-bar-engraver.cc           | 15 ++-------
 lily/stem.cc                        | 10 ++----
 lily/timing-translator.cc           |  4 +--
 scm/define-grobs.scm                |  2 +-
 18 files changed, 163 insertions(+), 130 deletions(-)
 create mode 100644 lily/include/grace-fixup.hh

diff --git a/ChangeLog b/ChangeLog
index a5faceed65..d8a0907ed5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2004-03-13  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+	* lily/include/global-context.hh (Context): clean-up data hiding.
+
+	* lily/include/music-iterator.hh (class Music_iterator): clean-up
+	data hiding.
+
+	* lily/include/grace-fixup.hh (struct Grace_fixup): new file.
+
+	* input/regression/stem-shorten.ly: add chord case.
+
+	* lily/stem.cc (get_default_stem_end_position): shorten stems
+	triggered by note-head positions, not by forced-direction. This
+	fixes a bug with too short stems.  
+ 
 2004-03-12  Jan Nieuwenhuizen  <janneke@gnu.org>
 
 	* scripts/lilypond-book.py (Lilypond_snippet.output_html,
diff --git a/input/regression/staccato-pos.ly b/input/regression/staccato-pos.ly
index f4fbedc00d..adcc018918 100644
--- a/input/regression/staccato-pos.ly
+++ b/input/regression/staccato-pos.ly
@@ -2,19 +2,22 @@
 \version "2.1.30"
 
 \header{
-texidoc="
-The staccato dot (and all scripts with follow-into-staff set) must
-not be on staff lines.
-"
+
+    texidoc=" The staccato dot (and all scripts with follow-into-staff
+set) must not be on staff lines. The staccato dot is close to the
+notehead. If the head is in a space, then the dot is in the space next
+to it.  "
+
 }
+
 \score { 
-  \context Voice \notes\relative c' {
-	e'4-. f-. d-. c-. b-.
+    \context Voice \notes\relative c' {
+	e'4-. f-. g-. d-. c-. b-.
 	\stemDown
 	e,-. d-. c-. b-. a-. g-.    
-  }
-  \paper {
-    raggedright = ##t
-  }  
+    }
+    \paper {
+	raggedright = ##t
+    }  
 }
 
diff --git a/input/regression/stem-shorten.ly b/input/regression/stem-shorten.ly
index a3c511c95a..cfa16c8990 100644
--- a/input/regression/stem-shorten.ly
+++ b/input/regression/stem-shorten.ly
@@ -3,15 +3,22 @@
 
 \header {
     
-    texidoc = "Stems in forced directions (as well as the ones
-    starting from the middle line) are shortened."
+    texidoc = "If note head is `over' the center line, the stem is
+ shortened.  This happens with forced stem directions, and with some
+ chord configurations."
 
 }
 
 \score {
-    \notes \relative c'' { \stemDown d c b a g f e
-			   \stemBoth
-			   \stemUp a b c d e f g a 
-		       } 
-    \paper  {raggedright = ##t }
+    \notes \relative c'' {
+	\stemDown d c b a g f e
+	\stemBoth
+	\stemUp a b c d e f g a
+	\stemBoth
+	<g, e'>2 <b e g> <c e g> <d f g>
+	
+    } 
+    \paper  {
+	raggedright = ##t
+    }
 }
diff --git a/lily/global-context.cc b/lily/global-context.cc
index 7ea4f98732..5c273a1893 100644
--- a/lily/global-context.cc
+++ b/lily/global-context.cc
@@ -16,10 +16,12 @@
 #include "score-context.hh"
 #include "context-def.hh"
 #include "music-output-def.hh"
+#include "grace-fixup.hh"
 
-Global_context::Global_context (Music_output_def*o)
+Global_context::Global_context (Music_output_def *o, Moment final)
 {
   output_def_ = o;
+  final_mom_ = final;
   definition_ = o->find_context_def (ly_symbol2scm ("Global"));
   unsmob_context_def (definition_)->apply_default_property_operations (this);
   accepts_list_ = scm_list_1 (ly_symbol2scm ("Score"));
@@ -34,7 +36,7 @@ Global_context::get_output_def () const
 void
 Global_context::add_moment_to_process (Moment m)
 {
-  if (m  > final_mom_)
+  if (m > final_mom_)
     return;
 
   if (m < now_mom_)
@@ -125,17 +127,6 @@ Global_context::run_iterator_on_me (Music_iterator * iter)
       if (w.main_part_.is_infinity ())
 	break ;
       
-#if 0      
-      //      printf ("proccing %s\n ",       w.to_string ().to_str0 ());
-      if (first)
-	{
-	  /*
-	    Huh? 
-	   */
-	  set_property ("measurePosition", w.smobbed_copy ());
-	}
-#endif
-      
       prepare (w);
 
       if (iter->ok ())
@@ -157,7 +148,7 @@ Global_context::run_iterator_on_me (Music_iterator * iter)
 	}
       
       one_time_step ();
-      first = false;      
+      first = false;
     }
 }
 
@@ -173,8 +164,8 @@ Global_context::apply_finalizations ()
 }
 
 /*
-   Add a function to execute before stepping to the next time step.
- */
+  Add a function to execute before stepping to the next time step.
+*/
 void
 Global_context::add_finalization (SCM x)
 {
@@ -183,3 +174,8 @@ Global_context::add_finalization (SCM x)
   set_property ("finalizations" ,lst); 
 }
 
+Moment
+Global_context::previous_moment () const
+{
+  return prev_mom_;
+}
diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc
index 96ec03b3fc..96839f8f99 100644
--- a/lily/hyphen-engraver.cc
+++ b/lily/hyphen-engraver.cc
@@ -15,9 +15,9 @@
 
 class Hyphen_engraver : public Engraver
 {
-  Music* ev_;
-  Spanner* hyphen_;
-  Spanner * finished_hyphen_;  
+  Music *ev_;
+  Spanner *hyphen_;
+  Spanner *finished_hyphen_;  
 public:
   TRANSLATOR_DECLARATIONS (Hyphen_engraver);
 
diff --git a/lily/include/global-context.hh b/lily/include/global-context.hh
index ba75d26087..f48f943138 100644
--- a/lily/include/global-context.hh
+++ b/lily/include/global-context.hh
@@ -20,7 +20,7 @@ class Global_context : public virtual Context
   
   friend class Music_output_def;
 public:
-  Global_context (Music_output_def*);
+  Global_context (Music_output_def*, Moment final);
   int get_moments_left () const;
   Moment sneaky_insert_extra_moment (Moment);
   void add_moment_to_process (Moment);
@@ -37,10 +37,11 @@ public:
   virtual Music_output_def* get_output_def () const; 
   virtual Moment now_mom () const;
 
+  Moment previous_moment () const;
+protected:
   Moment final_mom_;
   Moment prev_mom_;
   Moment now_mom_;
-protected:
 };
 
 
diff --git a/lily/include/grace-fixup.hh b/lily/include/grace-fixup.hh
new file mode 100644
index 0000000000..22b4a74136
--- /dev/null
+++ b/lily/include/grace-fixup.hh
@@ -0,0 +1,49 @@
+/*   
+     grace-fixup.hh -- declare Grace_fixup
+
+     source file of the GNU LilyPond music typesetter
+
+     (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#ifndef GRACE_FIXUP_HH
+#define GRACE_FIXUP_HH
+
+#include "moment.hh"
+
+/*
+
+  This is a lookahead list for grace notes.
+
+   {  ... X \grace Y  Z ... }
+
+   normally, the ending of X is the start of Z. In case of a grace
+   note, we take off a little at the end of X. What is stored: START
+   (start point of X), LENGTH (length of X), GRACE_START (start_music
+   of Y), and the next fixup element.
+
+  This is also done for nested musics, i.e.
+
+  voiceA = \notes { \grace b16 c'2 }
+  voiceB = \notes { c'2 \voiceA }
+
+  the iterator for voiceB will contain a fixup entry with (START=0/1,
+  LENGTH=2/1, GRACE_START=(0G-1/16) ) 
+   
+  Graces at the start of a sequential music iterator are handled
+  by initting here_mom_ with Music::start_music (); no fixups are needed.
+
+*/
+struct Grace_fixup 
+{
+  Moment start_;
+  Moment length_;
+
+  Rational grace_start_;
+
+  Grace_fixup * next_;
+};
+
+#endif /* GRACE_FIXUP_HH */
+
diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh
index 017271de13..b537a981a9 100644
--- a/lily/include/lily-proto.hh
+++ b/lily/include/lily-proto.hh
@@ -33,7 +33,6 @@ class Auto_change_music;
 class Axis_group_engraver;
 class Bar_engraver;
 class Bar_req_collect_engraver;
-class Base_span_bar_engraver;
 class Beaming_info_list;
 class Bezier;
 class Bezier_bow;
@@ -52,11 +51,10 @@ class Folded_repeat_iterator;
 class Font_metric;
 class Font_size_engraver;
 class Global_context;
+class Grace_fixup;
 class Gourlay_breaking;
-class Grace_engraver_group;
 class Grace_iterator;
 class Grace_music;
-class Grace_performer_group;
 class Hara_kiri_engraver;
 class Hara_kiri_line_group_engraver;
 class Includable_lexer;
@@ -70,7 +68,6 @@ class Ligature_engraver;
 class Ligature_bracket_engraver;
 class Line_group_engraver_group;
 class System;
-class Local_key_item;
 class Lookup;
 class Lyric_combine_music;
 class Lyric_combine_music_iterator;
diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh
index b482b7ccc5..5622e16601 100644
--- a/lily/include/music-iterator.hh
+++ b/lily/include/music-iterator.hh
@@ -62,7 +62,7 @@ protected:
 public:
   
   Moment music_get_length () const;
-  Moment music_start_mom () const;
+  virtual Moment music_start_mom () const;
   Music_iterator ();
 
   /**
diff --git a/lily/include/sequential-iterator.hh b/lily/include/sequential-iterator.hh
index eac01f3f77..c0c37e3943 100644
--- a/lily/include/sequential-iterator.hh
+++ b/lily/include/sequential-iterator.hh
@@ -12,37 +12,6 @@
 #include "music-iterator.hh"
 #include "protected-scm.hh"
 
-/*
-
-  This is a lookahead list for grace notes.
-
-   {  ... X \grace Y  Z ... }
-
-   normally, the ending of X is the start of Z. In case of a grace
-   note, we take off a little at the end of X. What is stored: START
-   (start point of X), LENGTH (length of X), GRACE_START (start_music
-   of Y), and the next fixup element.
-
-  This is also done for nested musics, i.e.
-
-  voiceA = \notes { \grace b16 c'2 }
-  voiceB = \notes { c'2 \voiceA }
-
-  the iterator for voiceB will contain a fixup entry with (START=0/1,
-  LENGTH=2/1, GRACE_START=(0G-1/16) ) 
-   
-  Graces at the start of a sequential music iterator are handled
-  by initting here_mom_ with Music::start_music (); no fixups are needed.
-
-*/
-struct Grace_fixup 
-{
-  Moment start_;
-  Moment length_;
-
-  Rational grace_start_;  
-  Grace_fixup *next_;
-};
 
 /** Sequential_music iteration: walk each element in turn, and
   construct an iterator for every element.
@@ -77,8 +46,8 @@ protected:
   void next_grace_fixup ();
   
 private:
+  Moment last_mom_;
   Moment here_mom_;
-  SCM list_;
   SCM cursor_;
   Grace_fixup * grace_fixups_;
   
diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc
index 7d66ce48be..598477b5f4 100644
--- a/lily/multi-measure-rest-engraver.cc
+++ b/lily/multi-measure-rest-engraver.cc
@@ -17,7 +17,6 @@
 
 /**
    The name says it all: make multi measure rests 
-
 */
 class Multi_measure_rest_engraver : public Engraver
 {
@@ -39,7 +38,7 @@ private:
   Moment stop_moment_;
   
   bool bar_seen_;
-  
+  Item *last_command_item_ ;
   Spanner *last_rest_;
   Spanner *mmrest_;
 
@@ -49,6 +48,7 @@ private:
 
 Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
 {
+  last_command_item_ = 0;
   bar_seen_ = false;
   start_measure_ = 0;
   mmrest_ = 0;
@@ -151,24 +151,34 @@ Multi_measure_rest_engraver::stop_translation_timestep ()
       Grob *cmc = unsmob_grob (get_property ("breakableSeparationItem"));
       if (!cmc)
 	cmc = unsmob_grob (get_property ("currentCommandColumn"));
-      
-      Item *it = dynamic_cast<Item*> (cmc);
-      
+
+      /*
+	Ugh, this is a kludge - need this for multi-measure-rest-grace.ly
+       */
+      last_command_item_ = dynamic_cast<Item*> (cmc);
+    }
+
+  if (last_command_item_ &&  (mmrest_ || last_rest_))
+    {
+          
+      if (last_rest_)
+	{
+	  add_bound_item (last_rest_, last_command_item_);
+	  for (int i = 0; i < last_numbers_.size (); i++)
+	    add_bound_item (last_numbers_[i], last_command_item_);
+	}
+
       if (mmrest_)
 	{
-	  add_bound_item (mmrest_, it);
+	  add_bound_item (mmrest_, last_command_item_);
 	  for (int i = 0; i < numbers_.size (); i++)
-	    add_bound_item (numbers_[i], it);
+	    add_bound_item (numbers_[i], last_command_item_);
+
+	  last_command_item_ = 0;
 	}
-      
-      if (last_rest_)
-	{
-	  add_bound_item (last_rest_,it);
-	  for (int i = 0; i < last_numbers_.size (); i++)
-	    add_bound_item (last_numbers_[i], it);
-	}      
     }
   
+  
   SCM smp = get_property ("measurePosition");
   Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
 
diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc
index 9af76a408f..02e6200abb 100644
--- a/lily/music-iterator.cc
+++ b/lily/music-iterator.cc
@@ -98,6 +98,7 @@ Music_iterator::get_static_get_iterator (Music *m)
   assert (m);
   p->music_length_ = m->get_length ();
   p->start_mom_ = m->start_mom ();
+  
   return iter;
 }
 
diff --git a/lily/score.cc b/lily/score.cc
index d0124b2c74..d007e2a2a2 100644
--- a/lily/score.cc
+++ b/lily/score.cc
@@ -113,7 +113,9 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
   
   Cpu_timer timer;
   
-  Global_context * trans = new Global_context (odef);
+  Global_context * trans = new Global_context (odef,
+					       music->get_length ()
+					       );
   
   if (!trans)
     {
@@ -122,7 +124,6 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
     }
   progress_indication (_ ("Interpreting music..."));
   
-  trans->final_mom_ = music->get_length ();
   SCM protected_iter = Music_iterator::get_static_get_iterator (music);
   Music_iterator * iter = unsmob_iterator (protected_iter);
   iter->init_translator (music, trans);
@@ -132,7 +133,7 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
   if (! iter->ok ())
     {
       warning (_ ("Need music in a score"));
-      return SCM_BOOL_F;	// todo: shoudl throw exception.
+      return SCM_BOOL_F;	// todo: should throw exception.
     }
 
   trans->run_iterator_on_me (iter);
diff --git a/lily/sequential-iterator.cc b/lily/sequential-iterator.cc
index 81e9dac296..39cc1a5bd5 100644
--- a/lily/sequential-iterator.cc
+++ b/lily/sequential-iterator.cc
@@ -10,8 +10,7 @@
 #include "context.hh"
 #include "sequential-iterator.hh"
 #include "music-list.hh"
-
-Grace_fixup *get_grace_fixups (SCM cursor);
+#include "grace-fixup.hh"
 
 /*
   
@@ -38,7 +37,6 @@ Grace_fixup *get_grace_fixups (SCM cursor);
 Sequential_iterator::Sequential_iterator ()
 {
   here_mom_ = Moment (0);
-  list_ = SCM_EOL;
   cursor_ = SCM_EOL; 
   grace_fixups_ = 0;
   iter_ = 0;
@@ -61,23 +59,24 @@ Sequential_iterator::do_quit ()
 
 
 void
-Sequential_iterator::derived_mark ()const
+Sequential_iterator::derived_mark () const
 {
   if (iter_)
     scm_gc_mark (iter_->self_scm ());
-  scm_gc_mark (list_);
   scm_gc_mark (cursor_);
 }
 
 
 void
-Sequential_iterator::derived_substitute (Context *f,Context *t)
+Sequential_iterator::derived_substitute (Context *f, Context *t)
 {
   if (iter_)
-    iter_->substitute_outlet (f,t);
-  
+    iter_->substitute_outlet (f, t);
 }
 
+/*
+  TODO: this should be made lazily.
+ */
 Grace_fixup *
 create_grace_fixup_list (SCM cursor)
 {
@@ -121,13 +120,12 @@ create_grace_fixup_list (SCM cursor)
 void
 Sequential_iterator::construct_children ()
 {
-  list_ = get_music_list ();
-  cursor_ = list_; 
+  cursor_ = get_music_list ();
 
   iter_ = 0;
   if (gh_pair_p (cursor_))
     {
-      Music *m  =unsmob_music (ly_car (cursor_));
+      Music *m = unsmob_music (ly_car (cursor_));
       iter_ = unsmob_iterator (get_iterator (m));
     }
   
@@ -136,6 +134,7 @@ Sequential_iterator::construct_children ()
       next_element (true);
     }
 
+  last_mom_ = Moment (-1);
   here_mom_ = get_music ()->start_mom ();
   grace_fixups_ = create_grace_fixup_list (cursor_);
 
@@ -161,7 +160,8 @@ Sequential_iterator::next_element (bool)
       && get_grace_fixup ())
     {
       Grace_fixup *gf = get_grace_fixup ();
-      
+
+      last_mom_ = here_mom_;
       here_mom_ += gf->length_;
       here_mom_.grace_part_ += gf->grace_start_;
 
@@ -169,6 +169,7 @@ Sequential_iterator::next_element (bool)
     }
   else if (len.grace_part_ && !len.main_part_)
     {
+      last_mom_ = here_mom_;
       here_mom_.grace_part_ =0;
     }
   else
@@ -180,6 +181,7 @@ Sequential_iterator::next_element (bool)
 	in that chunk should be in len.grace_part_
 
       */
+      last_mom_ = here_mom_;;
       here_mom_ += len;
     }
   
@@ -212,8 +214,6 @@ Sequential_iterator::descend_to_child ()
     set_translator (child_report);
 }
 
-
-
 void
 Sequential_iterator::process (Moment until)
 {
@@ -299,7 +299,6 @@ Sequential_iterator::next_grace_fixup ()
   grace_fixups_ = n;
 }
 
-
 Grace_fixup*
 Sequential_iterator::get_grace_fixup () const
 {
diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc
index a75ef41fe1..15e7234259 100644
--- a/lily/span-bar-engraver.cc
+++ b/lily/span-bar-engraver.cc
@@ -25,7 +25,7 @@
   */
 class Span_bar_engraver : public Engraver
 {
-  Item * spanbar_;
+  Item *spanbar_;
   Link_array<Item> bars_;
 
 public:
@@ -33,17 +33,13 @@ public:
 protected:
   virtual void acknowledge_grob (Grob_info);
   virtual void stop_translation_timestep ();
-
 };
 
-
 Span_bar_engraver::Span_bar_engraver ()
 {
   spanbar_ =0;
 }
 
-
-
 void
 Span_bar_engraver::acknowledge_grob (Grob_info i)
 {
@@ -58,11 +54,11 @@ Span_bar_engraver::acknowledge_grob (Grob_info i)
 	  spanbar_ = make_item ("SpanBar");
 
 	  spanbar_->set_parent (bars_[0], X_AXIS);
-
 	  announce_grob (spanbar_, SCM_EOL);
 	}
     }
 }
+
 void
 Span_bar_engraver::stop_translation_timestep ()
 {
@@ -73,7 +69,7 @@ Span_bar_engraver::stop_translation_timestep ()
 
       SCM vissym =ly_symbol2scm ("break-visibility");
       SCM vis = bars_[0]->internal_get_property (vissym);	  
-      if (scm_equal_p (spanbar_->internal_get_property (vissym), vis) != SCM_BOOL_T)
+      if (gh_equal_p (spanbar_->internal_get_property (vissym), vis))
 	spanbar_->internal_set_property (vissym, vis);
 
       typeset_grob (spanbar_);
@@ -83,11 +79,6 @@ Span_bar_engraver::stop_translation_timestep ()
 }
 
 
-
-
-
-
-
 ENTER_DESCRIPTION (Span_bar_engraver,
 /* descr */       "This engraver makes cross-staff barlines: It catches all normal "
 "bar lines, and draws a single span-bar across them.",
diff --git a/lily/stem.cc b/lily/stem.cc
index 1a80ca8199..30fc0040c8 100644
--- a/lily/stem.cc
+++ b/lily/stem.cc
@@ -302,8 +302,6 @@ Stem::get_default_stem_end_position (Grob*me)
 	}
     }
 
-
-
   /* URGURGURG
      'set-default-stemlen' sets direction too
    */
@@ -314,14 +312,10 @@ Stem::get_default_stem_end_position (Grob*me)
       set_grob_direction (me, dir);
     }
 
-
   /* stems in unnatural (forced) direction should be shortened, 
     according to [Roush & Gourlay] */
-  if (!chord_start_y (me)
-      || (get_direction (me) != get_default_dir (me)))
+  if (dir * head_positions (me)[dir] >= 0)
     {
-      
-  
       SCM sshorten = me->get_property ("stem-shorten");
       SCM scm_shorten = gh_pair_p (sshorten) ?
 	robust_list_ref ((duration_log (me) - 2) >? 0, sshorten): SCM_EOL;
@@ -329,7 +323,7 @@ Stem::get_default_stem_end_position (Grob*me)
       
   
       /* On boundary: shorten only half */
-      if (abs (head_positions (me)[get_direction (me)]) <= 1)
+      if (abs (head_positions (me)[dir]) <= 1)
 	shorten *= 0.5;
   
       length -= shorten;
diff --git a/lily/timing-translator.cc b/lily/timing-translator.cc
index e097d93197..85bffc00b6 100644
--- a/lily/timing-translator.cc
+++ b/lily/timing-translator.cc
@@ -96,8 +96,8 @@ Timing_translator::start_translation_timestep ()
 {
   Global_context *global =get_global_context ();
 
-  Moment now = global->now_mom_;
-  Moment dt = now  - global->prev_mom_;
+  Moment now = global->now_mom ();
+  Moment dt = now  - global->previous_moment ();
   if (dt < Moment (0))
     {
       programming_error ("Moving backwards in time");
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 1920f4a57c..3cc5892502 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -791,7 +791,7 @@
 
 	;; This value is sensitive: if too large, staccato dots will move a
 	;; space a away.
-	(padding . 0.25)
+	(padding . 0.20)
 	(staff-padding . 0.25)
 	;; (script-priority . 0) priorities for scripts, see script.scm
 	(X-offset-callbacks . (,Self_alignment_interface::centered_on_parent))
-- 
2.39.5