From b0fb176bbda801fdd513fc15c6197ca7fab71b3a Mon Sep 17 00:00:00 2001
From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Tue, 20 Aug 2002 17:34:10 +0000
Subject: [PATCH] * lily/completion-note-heads-engraver.cc (class
 Completion_heads_engraver): don't be confused by polyphonic rhythms.

* input/regression/completion-heads-polyphony.ly: new file.
---
 ChangeLog                                     |  7 ++++++
 .../regression/completion-heads-polyphony.ly  | 23 +++++++++++++++++++
 lily/completion-note-heads-engraver.cc        | 18 +++++++++++----
 make/lilypond.redhat.spec.in                  |  2 +-
 make/ly-rules.make                            |  2 +-
 5 files changed, 46 insertions(+), 6 deletions(-)
 create mode 100644 input/regression/completion-heads-polyphony.ly

diff --git a/ChangeLog b/ChangeLog
index 789526ad4e..743d4f0d44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-08-20  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+	* lily/completion-note-heads-engraver.cc (class
+	Completion_heads_engraver): don't be confused by polyphonic rhythms.
+
+	* input/regression/completion-heads-polyphony.ly: new file.
+
 2002-08-19  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
 	* GNUmakefile.in (web-ext): distribute .ly with web tarball too.
diff --git a/input/regression/completion-heads-polyphony.ly b/input/regression/completion-heads-polyphony.ly
new file mode 100644
index 0000000000..ceed2507b8
--- /dev/null
+++ b/input/regression/completion-heads-polyphony.ly
@@ -0,0 +1,23 @@
+\header {
+
+    texidoc = "Completion heads are broken across bar lines. This was
+intended as a debugging tool, but it can be used to ease music entry.
+Completion heads are not fooled by polyphony with a different rhythm.
+"
+
+}
+
+\score{ 
+	\context Staff \notes \relative c'' < 
+	    { c2. c bes2 } \\
+	    { c,2. a8 g4 f4. g4 f  }
+	>
+
+	\paper {
+		\translator{
+			\ThreadContext
+			\remove "Note_heads_engraver"
+			\consists "Completion_heads_engraver"
+		}
+	}
+}
diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc
index 14d4d405c2..ca90b3d5db 100644
--- a/lily/completion-note-heads-engraver.cc
+++ b/lily/completion-note-heads-engraver.cc
@@ -43,7 +43,8 @@ class Completion_heads_engraver : public Engraver
   Moment note_end_mom_;
   bool first_b_;
   Rational left_to_do_;
-
+  Rational do_nothing_until_;
+  
   Moment next_barline_moment ();
   Duration find_nearest_duration (Rational length);
   
@@ -81,6 +82,8 @@ Completion_heads_engraver::try_music (Music *m)
 	  musiclen.main_part_ = Rational (0,1);
 	}
       note_end_mom_  = note_end_mom_ >? (now + musiclen);
+      do_nothing_until_ = Rational (0,0);
+      
       return true;
     }
   else if (dynamic_cast<Busy_playing_req*> (m))
@@ -92,6 +95,9 @@ Completion_heads_engraver::try_music (Music *m)
   
 }
 
+/*
+  The duration _until_ the next barline.
+ */
 Moment
 Completion_heads_engraver::next_barline_moment ( )
 {
@@ -146,8 +152,12 @@ Completion_heads_engraver::process_music ()
 {
   if (!first_b_ && !left_to_do_)
     return ;
-
+  
   first_b_ = false;
+
+  Moment now =  now_mom ();
+  if (do_nothing_until_ > now.main_part_)
+    return ;
   
   Duration note_dur;
   Duration *orig = 0;
@@ -160,15 +170,15 @@ Completion_heads_engraver::process_music ()
       orig = unsmob_duration (note_reqs_[0]->get_mus_property ("duration"));
       note_dur = *orig;
     }
-
   Moment nb = next_barline_moment ();
   if (nb < note_dur.length_mom ())
     {
       note_dur = find_nearest_duration (nb.main_part_);
 
-      Moment next = now_mom();
+      Moment next = now;
       next.main_part_ += note_dur.length_mom ();
       top_engraver ()->add_moment_to_process (next);
+      do_nothing_until_ = next.main_part_;
     }
 
   if (orig)
diff --git a/make/lilypond.redhat.spec.in b/make/lilypond.redhat.spec.in
index 763d1f0c8a..ad858229bb 100644
--- a/make/lilypond.redhat.spec.in
+++ b/make/lilypond.redhat.spec.in
@@ -26,7 +26,7 @@ Group: Applications/Publishing
 
 %description documentation
 
-The documentation of LilyPond, both in HTML and PostScript.
+The documentation and example files of LilyPond.
 
 %prep
 %setup
diff --git a/make/ly-rules.make b/make/ly-rules.make
index f36ae8d718..dd3f297c4f 100644
--- a/make/ly-rules.make
+++ b/make/ly-rules.make
@@ -30,7 +30,7 @@ $(outdir)/%.texi: $(outdir)/%.tely
 # nexi: no-lily texi
 # for plain info doco: don't run lily
 $(outdir)/%.nexi: %.tely
-	chmod a+w $@
+	-chmod a+w $@
 	$(PYTHON) $(LILYPOND_BOOK) $(LILYPOND_BOOK_INCLUDES) --dependencies --outdir=$(outdir) --format=texi --no-lily $(LILYPOND_BOOK_FLAGS) $<
 	mv $(@D)/$(*F).texi $@
 	chmod -w $@
-- 
2.39.5