From 72f2b7d532d4396a66b0951615226101b7bd7da8 Mon Sep 17 00:00:00 2001
From: Valentin Villenave <valentin@localhost.(none)>
Date: Thu, 9 Oct 2008 23:36:02 +0200
Subject: [PATCH] new showFirstLength feature

This commits implements a showFirstLength property, that does
the opposite of showLastLength (both properties may be set,
but in this case the beginning and the end of the piece are printed
without any separation between them).  This new feature
may be very convenient, e.g. to print the index of a book
containing only the beginning of each \score.

Documentation and regtests have been updated as well.
---
 .../skiptypesetting-show-last-or-first.ly          |   23 ++++++++++++
 input/regression/skiptypesetting-show-last.ly      |   18 ---------
 scm/music-functions.scm                            |   37 ++++++++++++++++++-
 3 files changed, 58 insertions(+), 20 deletions(-)
 create mode 100644 input/regression/skiptypesetting-show-last-or-first.ly
 delete mode 100644 input/regression/skiptypesetting-show-last.ly

diff --git a/input/regression/skiptypesetting-show-last-or-first.ly b/input/regression/skiptypesetting-show-last-or-first.ly
new file mode 100644
index 0000000..f3e04e8
--- /dev/null
+++ b/input/regression/skiptypesetting-show-last-or-first.ly
@@ -0,0 +1,23 @@
+\header {
+
+  texidoc = "@code{showLastLength} will only show the last bit of a score;
+@code{showFirstLength} will only show the beginning."
+
+  }
+
+\version "2.11.62"
+
+music = {
+  c1 c1
+  c1 c1
+  c1 c1
+}
+
+showLastLength = R1*3
+
+\new Staff \music
+
+showLastLength = ""
+showFirstLength = R1
+
+\new Staff \music
\ No newline at end of file
diff --git a/input/regression/skiptypesetting-show-last.ly b/input/regression/skiptypesetting-show-last.ly
deleted file mode 100644
index def23fc..0000000
--- a/input/regression/skiptypesetting-show-last.ly
+++ /dev/null
@@ -1,18 +0,0 @@
-\header {
-
-  texidoc = "@code{showLastLength} will only show the last bit of a score"
-
-  }
-
-\version "2.11.51"
-
-showLastLength = R1*3
-\paper {
-  ragged-right = ##T
-}
-
-{
-  c1 c1
-  c1 c1
-  c1 c1
-}
diff --git a/scm/music-functions.scm b/scm/music-functions.scm
index 490cafe..5c28ce4 100644
--- a/scm/music-functions.scm
+++ b/scm/music-functions.scm
@@ -823,8 +823,39 @@ Syntax:
 	(ly:music-length music))
   music)
 
-(define (skip-to-last music parser)
+(define (skip-after-first music parser)
+  "Replace MUSIC by
+
+<< { LENGTHOF(\\showFirstLength)
+     \\set skipTypesetting = ##t }
+    MUSIC >>
+
+if appropriate.
+ "
+  (let*
+      ((show-first  (ly:parser-lookup parser 'showFirstLength)))
+    
+    (if (ly:music? show-first)
+	(let*
+	    ((skip-length (ly:music-length show-first)))
 
+	  (make-simultaneous-music
+	   (list
+	    (make-sequential-music
+	     (list
+        (context-spec-music (make-property-set 'skipTypesetting #f)
+				  'Score)
+	      (make-music 'SkipMusic 'duration
+			  (ly:make-duration
+			   0 0
+			   (ly:moment-main-numerator skip-length)
+			   (ly:moment-main-denominator skip-length)))
+	      (context-spec-music (make-property-set 'skipTypesetting #t)
+				  'Score)))
+	    music)))
+	music)))
+
+(define (skip-to-last music parser)
   "Replace MUSIC by
 
 << { \\set skipTypesetting = ##t
@@ -872,7 +903,9 @@ if appropriate.
    (lambda (x parser) (music-map cue-substitute x))
  
    (lambda (x parser)
-     (skip-to-last x parser)
+    (skip-after-first x parser))
+   (lambda (x parser)
+    (skip-to-last x parser)
    )))
 
 
-- 
1.6.0.2

