From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Mon, 18 Apr 2005 15:18:16 +0000 (+0000)
Subject: * lily/percent-repeat-engraver.cc (try_music): add measure before
X-Git-Tag: release/2.5.20~4
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=92d9505d744bdd4eaede532bbac5958ea3c55e8f;p=lilypond.git

* lily/percent-repeat-engraver.cc (try_music): add measure before
next_moment to future processing moment. Fixes:
percent-repeat-mm-rest.ly
(process_music): don't add moment for 2nd time.

* input/regression/repeat-percent.ly: add mmrests as extra test.

* lily/axis-group-engraver.cc (acknowledge_grob): read
keepAliveInterfaces to decide what to kill.

* ly/engraver-init.ly (AncientRemoveEmptyStaffContext): add
percent-repeat-interface to keepAliveInterfaces. This fixes
percent-repeat-harakiri.
---

diff --git a/ChangeLog b/ChangeLog
index 1296215845..b6b2c27031 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-04-18  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+	* lily/percent-repeat-engraver.cc (try_music): add measure before
+	next_moment to future processing moment. Fixes:
+	percent-repeat-mm-rest.ly
+	(process_music): don't add moment for 2nd time.
+
+	* input/regression/repeat-percent.ly: add mmrests as extra test.
+
+	* lily/axis-group-engraver.cc (acknowledge_grob): read
+	keepAliveInterfaces to decide what to kill.
+
+	* ly/engraver-init.ly (AncientRemoveEmptyStaffContext): add
+	percent-repeat-interface to keepAliveInterfaces. This fixes
+	percent-repeat-harakiri.
+
 2005-04-17  Jan Nieuwenhuizen  <janneke@gnu.org>
 
 	* SCons updates.
diff --git a/input/regression/repeat-percent.ly b/input/regression/repeat-percent.ly
index 750a735e6a..b30f5b0258 100644
--- a/input/regression/repeat-percent.ly
+++ b/input/regression/repeat-percent.ly
@@ -1,13 +1,19 @@
 \version "2.4.0"
 \header {
-texidoc = "Measure repeats may be nested with beat repeats."
+  texidoc = "Measure repeats may be nested with beat repeats."
 }
-	
-\score {  \relative c'' \context Voice { \time 4/4
-   % riff
-   \repeat "percent" 2 { r8. a16 g8. a16 bes8. a16 f8 d |  a c8 ~ c8 d8 ~ d8 r8 r4 }
-   
-   \repeat "percent" 2 { \repeat "percent" 4 { c8 es } }   
-  }
+
+\paper {
+  raggedright = ##t
+}
+\relative c'' \context Voice {
+  \set Score.skipBars = ##t
+  \time 4/4
+				% riff
+  \repeat "percent" 2 { r8. a16 g8. a16 bes8. a16 f8 d |  a c8 ~ c8 d8 ~ d8 r8 r4 }
+
+  R1*2
+  \repeat "percent" 2 { \repeat "percent" 4 { c8 es } }
+  R1*2
 }
 
diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc
index 88c7be909c..6d74ade67c 100644
--- a/lily/axis-group-engraver.cc
+++ b/lily/axis-group-engraver.cc
@@ -154,10 +154,21 @@ protected:
   virtual Spanner *get_spanner ();
   virtual void acknowledge_grob (Grob_info);
   virtual void add_element (Grob *e);
+  virtual void start_translation_timestep ();
+
+  SCM interesting_;
 public:
   TRANSLATOR_DECLARATIONS (Hara_kiri_engraver);
 };
 
+void
+Hara_kiri_engraver::start_translation_timestep ()
+{
+  Axis_group_engraver::start_translation_timestep ();
+  interesting_ = get_property ("keepAliveInterfaces");
+}
+
+
 void
 Hara_kiri_engraver::add_element (Grob *e)
 {
@@ -176,16 +187,19 @@ void
 Hara_kiri_engraver::acknowledge_grob (Grob_info i)
 {
   Axis_group_engraver::acknowledge_grob (i);
-  if (staffline_
-      && (i.grob_->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface"))
-	  || i.grob_->internal_has_interface (ly_symbol2scm ("lyric-interface"))))
+  if (staffline_)
     {
-      Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob_);
+      for (SCM s = interesting_; scm_is_pair (s); s = scm_cdr (s))
+	{
+	  if (i.grob_->internal_has_interface (scm_car (s)))
+	    Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob_);
+	}
     }
 }
 
 Hara_kiri_engraver::Hara_kiri_engraver ()
 {
+  interesting_ = SCM_EOL;
 }
 
 ADD_TRANSLATOR (Hara_kiri_engraver,
@@ -194,7 +208,7 @@ ADD_TRANSLATOR (Hara_kiri_engraver,
 		/* creats*/ "RemoveEmptyVerticalGroup",
 		/* accepts */ "",
 		/* acks  */ "grob-interface",
-		/* reads */ "",
+		/* reads */ "keepAliveInterfaces",
 		/* write */ "");
 
 ADD_TRANSLATOR (Axis_group_engraver,
diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc
index f41f5aaade..eb1b317b22 100644
--- a/lily/percent-repeat-engraver.cc
+++ b/lily/percent-repeat-engraver.cc
@@ -93,7 +93,6 @@ Percent_repeat_engraver::try_music (Music *m)
       else if (Moment (2) * meas_len == body_length_)
 	{
 	  repeat_sign_type_ = DOUBLE_MEASURE;
-	  next_moment_ += meas_len;
 	}
       else
 	{
@@ -105,16 +104,19 @@ Percent_repeat_engraver::try_music (Music *m)
       repeat_ = m;
 
       Global_context *global = get_global_context ();
-      for (int i = 0; i < count; i++)
+      for (int i = 1; i < count; i++)
 	{
-	  global->add_moment_to_process (next_moment_
-					 + Moment (i) * body_length_);
+	  Moment m = next_moment_ + Moment (i) * body_length_;
+	  global->add_moment_to_process (m);
 
 	  /* bars between % too.  */
 	  if (repeat_sign_type_ == DOUBLE_MEASURE)
-	    global->add_moment_to_process (next_moment_ + meas_len + Moment (i) * body_length_);
+	    global->add_moment_to_process (m - meas_len);
 	}
 
+      if (repeat_sign_type_ == DOUBLE_MEASURE)
+	next_moment_ += meas_len;
+      
       return true;
     }
 
@@ -144,8 +146,6 @@ Percent_repeat_engraver::process_music ()
 	  get_score_engraver ()->forbid_breaks ();	// guh. Use properties!      
 	}
       next_moment_ = next_moment_ + body_length_;
-
-      get_global_context ()->add_moment_to_process (next_moment_);
     }
 }
 
diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly
index 9fed117387..7fd0abefd4 100644
--- a/ly/engraver-init.ly
+++ b/ly/engraver-init.ly
@@ -559,6 +559,7 @@ AncientRemoveEmptyStaffContext = \context {
     (Voice Slur direction -1)
   )
 
+  keepAliveInterfaces = #'(rhythmic-grob-interface lyric-interface percent-repeat-interface)
   quotedEventTypes = #'(note-event rest-event time-scaled-music tie-event)
   instrumentTransposition = #(ly:make-pitch 0 0 0)
 
@@ -778,6 +779,7 @@ EasyNotation = \context {	%% TODO: why \context override?
   \override TextSpanner #'enclose-bounds = #1
   \override TextSpanner #'edge-text = #'("" . "")
 }
+
 \context {
   \Staff
   \name "GregorianTranscriptionStaff"
diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm
index 2c3654be3c..6a57b70dea 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -231,6 +231,8 @@ Function taking a string (instrument name), and returning a (@var{min} . @var{ma
 the instrument. Its value is the pitch that sounds like middle C. This
 is used to transpose the MIDI output, and @code{\\quote}s.")
 
+     (keepAliveInterfaces ,list? "List of symbols, signifying grob interfaces that
+are worth keeping a RemoveEmptyStaff staff around for.")   
      (keyAccidentalOrder ,list? " Alist that defines in what order
 alterations should be printed.  The format is (@var{name}
 . @var{alter}), where @var{name} is from 0 .. 6 and @var{alter} from