]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/regression/newaddlyrics.ly: New file.
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 19 Apr 2004 13:40:48 +0000 (13:40 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 19 Apr 2004 13:40:48 +0000 (13:40 +0000)
* Documentation/topdocs/NEWS.texi: Update.

* lily/parser.yy (new_lyrics): Return SCM list of lyric musics.
(Music_list): Allow embedded scm.

* lily/score.cc (ly:score-bookify): New function.

* lily/music.cc (ly:music-scorify): Idem.

* lily/my-lily-parser.cc (ly:parser-print-book): Idem.
(ly:parser-print-score): Idem.

* scm/lily.scm (default-toplevel-book-handler): Idem.
(default-toplevel-music-handler): Idem.
(default-toplevel-score-handler): Idem.

* ly/declarations-init.ly: Set default toplevel handlers.

* lily/parser.yy (book_block, score_block, toplevel_music): Use them.

* scripts/lilypond-book.py (PREAMBLE_LY): Select classic score
printer for score at toplevel.

17 files changed:
ChangeLog
Documentation/topdocs/NEWS.texi
Documentation/user/notation.itely
Documentation/user/tutorial.itely
input/regression/newaddlyrics.ly [new file with mode: 0644]
lily/include/my-lily-parser.hh
lily/lexer.ll
lily/music.cc
lily/my-lily-parser.cc
lily/parser.yy
lily/score.cc
lily/source-file.cc
ly/declarations-init.ly
ly/init.ly
scm/lily.scm
scm/music-functions.scm
scripts/lilypond-book.py

index 8d94ba6e51635fd3f20eaa76904d59bd5cb707dc..a12a6654d72babaa4a1b81afd08e1b2c680fed7c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2004-04-19  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * input/regression/newaddlyrics.ly: New file.
+
+       * Documentation/topdocs/NEWS.texi: Update.
+
+       * lily/parser.yy (new_lyrics): Return SCM list of lyric musics.
+       (Music_list): Allow embedded scm.
+
+       * lily/score.cc (ly:score-bookify): New function.
+
+       * lily/music.cc (ly:music-scorify): Idem.
+
+       * lily/my-lily-parser.cc (ly:parser-print-book): Idem.
+       (ly:parser-print-score): Idem.
+
+       * scm/lily.scm (default-toplevel-book-handler): Idem.
+       (default-toplevel-music-handler): Idem.
+       (default-toplevel-score-handler): Idem.
+
+       * ly/declarations-init.ly: Set default toplevel handlers.
+
+       * lily/parser.yy (book_block, score_block, toplevel_music): Use them.
+
+       * scripts/lilypond-book.py (PREAMBLE_LY): Select classic score
+       printer for score at toplevel.
+
 2004-04-18  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * lily/parser.yy (NEWLYRICS): Switch to LYRICS mode for lyrics.
index bb1a5db4521b9edfe7b45bb2370534f79300562e..6f9b0db3d00f6d43ac96aec9ac12fa3b0eb774ba 100644 (file)
@@ -8,6 +8,53 @@
 
 @itemize @bullet
 
+@c FIXME: un-geekify
+@item Music lists are allowed at toplevel, and are handled by
+@code{default-toplevel-music-handler}.  Similarly, a @code{score} block
+at toplevel is handled by @code{default-toplevel-score-handler} an a
+@code{book} at toplevel is handled by @code{default-toplevel-book-handler}.
+
+These default handlers have the following effect.  A Music list at
+toplevel is encapsulated in a @code{score} block, and a @code{score}
+block at toplevel is encapsulated in a @code{book} block.  A
+@code{book} block at toplevel generates printed output.
+
+@example
+\header @{ title = "The Title" @}
+\notes @{ a b c @}
+@end example
+
+is the same as
+
+@example
+\header @{ title = "The Title" @}
+\book @{
+  \score @{
+    \notes @{ a b c @}
+  @}
+@}    
+@end example
+
+@item Start pitch for @code{relative} music is optional for music lists.
+The default value is one octave below middle C.
+
+@c update-me?  formal definition of newaddlyrics, once it works
+@item Combining lyrics with music can be @code{newaddlyrics}
+
+@example
+<<
+    \relative @{
+       \clef bass
+       d2 d c4 bes a2 \break
+       c2 c d4 f g2
+    @}
+    \newlyrics @{
+       My first Li -- ly song,
+       Not much can go wrong!
+    @}
+>>
+@end example
+
 @item The parser is encapsulated in a Scheme function
 @code{ly:parse-file}, so the following fragment processes two files
 
index 48227e93c0f2bae7d00756791e2ad6faf04dc1ce..7907f01a097bde784ac3ca2b7210277ebef8ec23 100644 (file)
@@ -3595,7 +3595,7 @@ Stanza numbers can be added by setting @code{stanza}, e.g.
 <<
   \context Voice = duet {
     \time 3/4 g2 e4 a2 f4 g2. }
-   \lyrics \lyricsto "duet" \new Lyrics {
+    \lyricsto "duet" \new Lyrics \lyrics {
      \set stanza = "1. "
      Hi, my name is Bert. }
 >>
index 4cc564878b6216019e951105e793cb508f3354ba..fbf723586f73544f53946bd342ac30400882018e 100644 (file)
@@ -1091,7 +1091,7 @@ Twin -- kle twin -- kle
       \time 2/4
       f4 f c' c
     }
-    \new Lyrics \lyrics \lyricsto "bla" { Twin -- kle twin -- kle }
+    \new Lyrics \lyricsto "bla" \lyrics { Twin -- kle twin -- kle }
   >>
 }
 @end lilypond
diff --git a/input/regression/newaddlyrics.ly b/input/regression/newaddlyrics.ly
new file mode 100644 (file)
index 0000000..daef387
--- /dev/null
@@ -0,0 +1,39 @@
+\header {
+    texidoc = "newlyrics -- multiple stanzas broken as yet."
+}
+
+%% Testing newlyrics 
+%%\new PianoStaff <<
+<<
+    \new Staff \relative {
+       d'2 d c4 bes a2 \break
+       c2 c d4 f g2
+    }
+    \newlyrics <<
+       {
+           My first Li -- ly song,
+           Not much can go wrong!
+       }
+       {
+           My se -- cond ly verse
+           Not much can go wrong!
+       }
+    >>
+    \new Staff \relative {
+       \clef bass
+       d2 d c4 bes a2 \break
+       c2 c d4 f g2
+    }
+    \newlyrics <<
+       {
+           MY FIRST LI -- LY SONG,
+           NOT MUCH CAN GO WRONG!
+       }
+       {
+           MY SE -- COND LY VERSE
+           NOT MUCH CAN GO WRONG!
+       }
+    >>
+>>
+
+\version "2.3.0"
index eadac03ccd4f3178abc1a98b90b5feda1646da74..58afacb25786ae5d6c93d8ad1b420381ef5d5b49 100644 (file)
@@ -72,6 +72,10 @@ DECLARE_UNSMOB (My_lily_parser, my_lily_parser);
 
 SCM ly_parse_file (SCM);
 SCM ly_parse_string (SCM);
-SCM ly_parser_add_book_and_score (SCM, SCM);
+// SCM ly_parser_add_book_and_score (SCM, SCM);
+SCM ly_parser_print_book (SCM, SCM);
+SCM ly_parser_print_score (SCM, SCM);
+SCM ly_parser_bookify (SCM, SCM);
+SCM ly_parser_scorify (SCM, SCM);
 
 #endif /* MY_LILY_PARSER_HH */
index aa44ebf2f6796cd6ad39533075663dad74542968..8b25deb071c507bd01b7ea8ef9b39f21985bd5c3 100644 (file)
@@ -313,10 +313,10 @@ HYPHEN            --
 }
 <INITIAL,notes,lyrics>{ 
        \<\<   {
-               return LESSLESS;
+               return DOUBLE_ANGLE_OPEN;
        }
        \>\>   {
-               return MOREMORE;
+               return DOUBLE_ANGLE_CLOSE;
        }
 }
 <figures>{
index 4c58b9c757ccd51226b38a5f8c05ef73050f8cc0..21356b6745c894acaa58caddd247d13e42637743 100644 (file)
@@ -6,14 +6,14 @@
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "main.hh"
 #include "input-smob.hh"
-#include "music.hh"
-#include "music-list.hh"
-#include "warn.hh"
-#include "pitch.hh"
 #include "ly-smobs.icc"
 #include "main.hh"
+#include "music-list.hh"
+#include "music.hh"
+#include "pitch.hh"
+#include "score.hh"
+#include "warn.hh"
 
 
 bool
@@ -215,6 +215,18 @@ Music::origin () const
   return ip ? ip : & dummy_input_global;
 }
 
+
+Music*
+make_music_by_name (SCM sym)
+{
+  SCM make_music_proc = ly_scheme_function ("make-music");
+  SCM rv = scm_call_1 (make_music_proc, sym);
+
+  /* UGH. */
+  scm_gc_protect_object (rv);
+  return unsmob_music (rv);
+}
+
 LY_DEFINE (ly_music_length, "ly:music-length",
           1, 0, 0, (SCM mus),
          "Get the length of music expression @var{mus}, and return as a @code{Moment} object.")
@@ -359,14 +371,24 @@ LY_DEFINE (ly_music_compress, "ly:music-compress",
   return sc->self_scm ();
 }
 
-Music*
-make_music_by_name (SCM sym)
-{
-  SCM make_music_proc = ly_scheme_function ("make-music");
-  SCM rv = scm_call_1 (make_music_proc, sym);
 
-  /* UGH. */
-  scm_gc_protect_object (rv);
-  return unsmob_music (rv);
+LY_DEFINE (ly_music_scorify, "ly:music-scorify",
+          1, 0, 0,
+          (SCM music),
+          "Return MUSIC encapsulated in SCORE.")
+{
+#if 0
+  SCM_ASSERT_TYPE (ly_c_music_p (music), music, SCM_ARG1, __FUNCTION__, "music");
+#endif
+  Score *score = new Score;
+  
+  /* URG? */
+  SCM check_funcs = ly_scheme_function ("toplevel-music-functions");
+  for (; ly_c_pair_p (check_funcs); check_funcs = ly_cdr (check_funcs))
+    music = scm_call_1 (ly_car (check_funcs), music);
+  
+  score->music_ = music;
+  scm_gc_unprotect_object (score->self_scm ());
+  return score->self_scm ();
 }
 
index e0820239f753a020737c0d05d8e4538149049cd4..47cbade68e5d89a8e107fae02aeaf565a4c4aca9 100644 (file)
@@ -100,8 +100,6 @@ My_lily_parser::parse_string (String ly_code)
   lexer_ = new My_lily_lexer (sources_);
   lexer_->main_input_name_ = "<string>";
   lexer_->main_input_b_ = true;
-  SCM nn = lexer_->lookup_identifier ("pitchnames");
-  lexer_->push_note_state (alist_to_hashq (nn));
 
   set_yydebug (0);
   lexer_->new_input (lexer_->main_input_name_, ly_code, sources_);
@@ -313,27 +311,60 @@ LY_DEFINE (ly_parse_string, "ly:parse-string",
   return SCM_UNSPECIFIED;
 }
 
+static Music_output_def*
+get_paper (My_lily_parser *parser)
+{
+  SCM id = parser->lexer_->lookup_identifier ("$defaultpaper");
+  Music_output_def *paper = unsmob_music_output_def (id);
+  return paper ? paper->clone () : new Paper_def;
+}
 
-LY_DEFINE (ly_parser_add_book_and_score, "ly:parser-add-book-and-score",
+LY_DEFINE (ly_parser_print_score, "ly:parser-print-score",
           2, 0, 0,
-          (SCM purple, SCM music),
-          "Handle the toplevel-music MUSIC by adding BOOK and SCORE.")
+          (SCM parser_smob, SCM score_smob),
+          "Print score, i.e., the classic way.")
 {
 #if 0
   SCM_ASSERT_TYPE (ly_c_parser_p (parser), music, SCM_ARG1, __FUNCTION__, "parser");
   SCM_ASSERT_TYPE (ly_c_music_p (music), music, SCM_ARG1, __FUNCTION__, "music");
 #endif
-  My_lily_parser *parser = unsmob_my_lily_parser (purple);
-  Score *score = new Score;
+  My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+  Score *score = unsmob_score (score_smob);
+
+  SCM header = is_module (score->header_) ? score->header_
+    : parser->header_.to_SCM ();
   
-  /* URG? */
-  SCM check_funcs = ly_scheme_function ("toplevel-music-functions");
-  for (; ly_c_pair_p (check_funcs); check_funcs = ly_cdr (check_funcs))
-    music = scm_call_1 (ly_car (check_funcs), music);
-  score->music_ = music;
-  Book *book = new Book;
-  book->scores_.push (score);
-  scm_gc_unprotect_object (score->self_scm ());
+  Path outname = split_path (parser->output_basename_);
+  int *c = &parser->book_count_;
+  if (*c)
+    outname.base += "-" + to_string (*c);
+  (*c)++;
+
+  SCM os = scm_makfrom0str (outname.to_string ().to_str0 ());
+  for (int i = 0; i < score->defs_.size (); i++)
+    default_rendering (score->music_, score->defs_[i]->self_scm (), header,
+                      os);
+
+  if (score->defs_.is_empty ())
+    {
+      Music_output_def *paper = get_paper (parser);
+      default_rendering (score->music_, paper->self_scm (), header, os);
+      scm_gc_unprotect_object (paper->self_scm ());
+    }
+  return SCM_UNDEFINED;
+}
+
+LY_DEFINE (ly_parser_print_book, "ly:parser-print-book",
+          2, 0, 0,
+          (SCM parser_smob, SCM book_smob),
+          "Print book.")
+{
+#if 0
+  SCM_ASSERT_TYPE (ly_c_parser_p (parser_smob), parser_smob, SCM_ARG1, __FUNCTION__, "parser_smob");
+  SCM_ASSERT_TYPE (ly_c_music_p (book_smob), book_smob, SCM_ARG1, __FUNCTION__, "book_smob");
+#endif
+  My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+  Book *book = unsmob_book (book_smob);
   
   SCM header = parser->header_;
   Path outname = split_path (parser->output_basename_);
@@ -341,11 +372,8 @@ LY_DEFINE (ly_parser_add_book_and_score, "ly:parser-add-book-and-score",
   if (*c)
     outname.base += "-" + to_string (*c);
   (*c)++;
-  My_lily_lexer *lexer = parser->lexer_;
-  Music_output_def *dp
-    = unsmob_music_output_def (lexer->lookup_identifier ("$defaultpaper"));
-  book->process (outname.to_string (),
-                dp ? dp->clone () : new Paper_def, header);
-  scm_gc_unprotect_object (book->self_scm ());
+  Music_output_def *paper = get_paper (parser);
+  book->process (outname.to_string (), paper, header);
+  scm_gc_unprotect_object (paper->self_scm ());
   return SCM_UNDEFINED;
 }
index 56ca971ea6e9154282718021159be18be623eafe..1930b93aa552cd2eb6618977eea34cca39564d26 100644 (file)
@@ -81,14 +81,6 @@ tag_music (Music *m, SCM tag, Input ip)
        m->set_property ("tags", tags);
 }
 
-Music_output_def*
-get_paper (My_lily_parser *parser)
-{
-       SCM id = parser->lexer_->lookup_identifier ("$defaultpaper");
-       Music_output_def *paper = unsmob_music_output_def (id);
-       return paper ? paper->clone () : new Paper_def;
-}
-
 bool
 is_regular_identifier (SCM id)
 {
@@ -265,8 +257,8 @@ or
 %token CHANGE
 %token CHORDMODIFIERS
 %token CHORDS
-%token LESSLESS
-%token MOREMORE
+%token DOUBLE_ANGLE_OPEN
+%token DOUBLE_ANGLE_CLOSE
 %token CLEF
 %token COMMANDSPANREQUEST
 %token CONSISTS
@@ -330,15 +322,6 @@ or
 %token CHORD_BASS CHORD_COLON CHORD_MINUS CHORD_CARET  CHORD_SLASH
 %token FIGURE_SPACE
 
-%type <book>   book_block book_body
-%type <i>      exclamations questions dots optional_rest
-%type <i>       bass_mod
-%type <scm>    grace_head
-%type <scm>    oct_check
-%type <scm>    context_mod_list
-%type <scm>    lyric_element
-%type <scm>    bass_number br_bass_figure bass_figure figure_list figure_spec
-%type <music>  new_lyrics
 %token <i>     DIGIT
 %token <scm>   NOTENAME_PITCH
 %token <scm>   TONICNAME_PITCH
@@ -374,6 +357,15 @@ or
 %token <scm> MARKUP_IDENTIFIER MARKUP_HEAD_LIST0
 %type <scm> markup markup_line markup_list  markup_list_body full_markup
 
+%type <book>   book_block book_body
+%type <i>      exclamations questions dots optional_rest
+%type <i>       bass_mod
+%type <scm>    grace_head
+%type <scm>    oct_check
+%type <scm>    context_mod_list
+%type <scm>    lyric_element
+%type <scm>    bass_number br_bass_figure bass_figure figure_list figure_spec
+%type <scm>    new_lyrics
 %type <outputdef> output_def
 %type <scm>    lilypond_header lilypond_header_body
 %type <music>  open_event close_event
@@ -450,59 +442,28 @@ toplevel_expression:
        lilypond_header {
                THIS->header_ = $1;
        }
-       | toplevel_music {
-               Music_output_def *paper = get_paper (THIS);
-               SCM proc = THIS->lexer_->lookup_identifier ("toplevel-music-handler");
-               if (proc == SCM_UNDEFINED)
-                       proc = ly_scheme_function ("ly:parser-add-book-and-score");
-               scm_call_2 (proc, THIS->self_scm (), $1->self_scm ());
-               scm_gc_unprotect_object (paper->self_scm ());
-       }
        | add_quote {
        
        }
        | book_block {
                Book *book = $1;
-               SCM header = THIS->header_;
-               Path outname = split_path (THIS->output_basename_);
-               int *c = &THIS->book_count_;
-               if (*c)
-                       outname.base += "-" + to_string (*c);
-               (*c)++;
-               Music_output_def *paper = get_paper (THIS);
-               book->process (outname.to_string (), paper, header);
+               SCM proc = THIS->lexer_->lookup_identifier ("toplevel-book-handler");
+               scm_call_2 (proc, THIS->self_scm (), book->self_scm ());
                scm_gc_unprotect_object (book->self_scm ());
-               scm_gc_unprotect_object (paper->self_scm ());
        }
        | score_block {
-               /* TODO: implicit book, depending on --no-book/--no-page-layout
-                  option? */
                Score *score = $1;
-               SCM head = is_module (score->header_) ? score->header_
-                       : THIS->header_.to_SCM ();
-
-               Path p = split_path (THIS->output_basename_);
-               int *c = &THIS->score_count_;
-               if (*c)
-                       p.base += "-" + to_string (*c);
-
-               (*c)++;
-               SCM outname = scm_makfrom0str (p.to_string ().to_str0());
-
-               for (int i = 0; i < score->defs_.size (); i++)
-                       default_rendering (score->music_,
-                                          score->defs_[i]->self_scm (), head,
-                                          outname);
-
-               if (score->defs_.is_empty ())
-               {
-                  Music_output_def *paper = get_paper (THIS);
-                  default_rendering (score->music_, paper->self_scm (), head,
-                       outname);
-                  scm_gc_unprotect_object (paper->self_scm ());
-               }
+               
+               SCM proc = THIS->lexer_->lookup_identifier ("toplevel-score-handler");
+               scm_call_2 (proc, THIS->self_scm (), score->self_scm ());
                scm_gc_unprotect_object (score->self_scm ());
        }
+       | toplevel_music {
+               Music *music = $1;
+               SCM proc = THIS->lexer_->lookup_identifier ("toplevel-music-handler");
+               scm_call_2 (proc, THIS->self_scm (), music->self_scm ());
+               scm_gc_unprotect_object (music->self_scm ());
+       }
        | output_def {
                SCM id = SCM_EOL;
                if (dynamic_cast<Paper_def*> ($1))
@@ -814,6 +775,8 @@ Music_list:
                        scm_set_car_x (s, c); /* set first cons */
                scm_set_cdr_x (s, c);  /* remember last cell */
        }
+       | Music_list embedded_scm {
+       }
        | Music_list error {
        }
        ;
@@ -1052,8 +1015,8 @@ basic music objects too, since the meaning is different.
                $$ = context_spec_music ($2, SCM_UNDEFINED, $4, $3);
        }
        | NEWCONTEXT string optional_context_mod Music {
-               $$ = context_spec_music ($2, get_next_unique_context (),
-                                        $4, $3);
+               $$ = context_spec_music ($2, get_next_unique_context (), $4,
+                       $3);
        }
 
        | TIMES {
@@ -1186,20 +1149,17 @@ new_lyrics:
            \repeat \alternative */
                THIS->lexer_->pop_state ();
 #if 0
-               $$ = $3;
-#else
                Music *music = MY_MAKE_MUSIC ("SimultaneousMusic");
                music->set_property ("elements", scm_list_1 ($3->self_scm ()));
                $$ = music;
+#else
+               $$ = scm_cons ($3->self_scm (), SCM_EOL);
 #endif
        }
        | new_lyrics NEWLYRICS { THIS->lexer_->push_lyric_state (); }
        Grouped_music_list {
                THIS->lexer_->pop_state ();
-               Music *music = MY_MAKE_MUSIC ("SimultaneousMusic");
-               music->set_property ("elements", scm_cons ($4->self_scm (),
-                       $1->get_property ("elements")));
-               $$ = music;
+               $$ = scm_cons ($4->self_scm (), $1);
        }
        ;
 
@@ -1214,35 +1174,30 @@ re_rhythmed_music:
        }
        | Grouped_music_list new_lyrics {
 
-               /* TODO: loop over simultaneous lyric musics? */
+               /* FIXME: should find out uniqueXXX name from music */
+               SCM name = $1->get_property ("context-id");
+               //if (name == SCM_EOL)
+               if (!ly_c_string_p (name))
+                       name = scm_makfrom0str ("");
 
-               Music *music = $2;
-               SCM name = scm_makfrom0str ("");
                SCM context = scm_makfrom0str ("Lyrics");
                Music *all = MY_MAKE_MUSIC ("SimultaneousMusic");
-#if 0 // simple only
-               Music *combined = make_lyric_combine_music (name, music);
-               Music *csm = context_spec_music (context, SCM_UNDEFINED,
-                       combined, SCM_EOL);
-               all->set_property ("elements", scm_listify ($1->self_scm (),
-                       csm->self_scm (), SCM_UNDEFINED));
-#else
+
                SCM lst = SCM_EOL;
-               for (SCM s = music->get_property ("elements"); ly_c_pair_p (s);
-                       s = ly_cdr (s))
+               for (SCM s = $2; ly_c_pair_p (s); s = ly_cdr (s))
                {
+                       Music *music = unsmob_music (ly_car (s));
                        Music *com = make_lyric_combine_music (name, music);
                        Music *csm = context_spec_music (context,
-                               SCM_UNDEFINED, com, SCM_EOL);
-                       //lst = ly_snoc (csm->self_scm (), lst);
+                               get_next_unique_context (), com, SCM_EOL);
                        lst = scm_cons (csm->self_scm (), lst);
                }
-#endif
+               /* FIXME: only first lyric music is accepted,
+                         the rest is junked */
                all->set_property ("elements", scm_cons ($1->self_scm (),
                        lst));
                $$ = all;
                scm_gc_unprotect_object ($1->self_scm ());
-               scm_gc_unprotect_object ($2->self_scm ());
        }
        | LYRICSTO string Music {
                Music *music = $3;
@@ -1426,10 +1381,10 @@ chord_open: '<'
 chord_close: '>'
        ;
 
-simul_open: LESSLESS
+simul_open: DOUBLE_ANGLE_OPEN
        ;
 
-simul_close: MOREMORE
+simul_close: DOUBLE_ANGLE_CLOSE
        ;
 
 chord_body:
@@ -2658,15 +2613,12 @@ context_spec_music (SCM type, SCM id, Music *m, SCM ops)
        return csm;
 }
 
-
 SCM
 get_next_unique_context ()
 {
        static int new_context_count;
-
        char s[1024];
-       snprintf (s, 1024, "uniqueContext%d", new_context_count ++);
-               
+       snprintf (s, 1024, "uniqueContext%d", new_context_count++);
        return scm_makfrom0str (s);
 }
 
index e793931efb17b4f9f73f5c2bf93e17d211f2e940..7a82662dd9ccd037d5ae2a3a021a26a2e74f4a32 100644 (file)
@@ -8,23 +8,22 @@
 
 #include <stdio.h>
 
+#include "book.hh"
+#include "cpu-timer.hh"
+#include "global-context.hh"
+#include "ly-module.hh"
 #include "ly-smobs.icc"
-
-#include "score.hh"
-#include "warn.hh"
+#include "main.hh"
+#include "music-iterator.hh"
 #include "music-output-def.hh"
 #include "music-output.hh"
-#include "music-iterator.hh"
 #include "music.hh"
-#include "global-context.hh"
-#include "scm-hash.hh"
-#include "cpu-timer.hh"
-#include "main.hh"
-#include "paper-def.hh"
-#include "ly-module.hh"
 #include "paper-book.hh"
+#include "paper-def.hh"
 #include "paper-score.hh"
-
+#include "scm-hash.hh"
+#include "score.hh"
+#include "warn.hh"
 
 /*
   TODO: junkme.
@@ -209,3 +208,20 @@ Score::book_rendering (String outname, Music_output_def *default_def,
     }
   return systems;
 }
+
+LY_DEFINE (ly_score_bookify, "ly:score-bookify",
+          1, 0, 0,
+          (SCM score_smob),
+          "Return SCORE encapsulated in a BOOK.")
+{
+#if 0
+  SCM_ASSERT_TYPE (ly_c_parser_p (parser_smob), parser_smobd, SCM_ARG1, __FUNCTION__, "parser_smob");
+  SCM_ASSERT_TYPE (ly_c_score_p (score_smob), score_smob, SCM_ARG1, __FUNCTION__, "score_smob");
+#endif
+  
+  Score *score = unsmob_score (score_smob);
+  Book *book = new Book;
+  book->scores_.push (score);
+  scm_gc_unprotect_object (book->self_scm ());
+  return book->self_scm ();
+}
index eb83b0e1de40308ac598ac1312a0d5232e8f6dd0..d735fd26ff30359cce0a0061afc62bd4713eae57 100644 (file)
@@ -67,9 +67,6 @@ gulp_file (String filename, int *filesize)
   return str;
 }
 
-/*
-  Unused.
- */
 Source_file::Source_file (String filename, String data)
 {
   name_ = filename;
@@ -103,12 +100,9 @@ Source_file::Source_file (String filename_string)
 void
 Source_file::init_port ()
 {
-  SCM str =scm_makfrom0str (contents_str0_);
-  
-  str_port_ = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_RDNG,
-                            __FUNCTION__);
-  scm_set_port_filename_x (str_port_,
-                          scm_makfrom0str (name_.get_str0()));
+  SCM str = scm_makfrom0str (contents_str0_);
+  str_port_ = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_RDNG, __FUNCTION__);
+  scm_set_port_filename_x (str_port_, scm_makfrom0str (name_.get_str0 ()));
 }
 
 int
index 360c178ea072712c89d5007513035e8d6a6d6979..671b97470c6e95e5ad07418bfdbae49c33d92586 100644 (file)
@@ -146,4 +146,6 @@ unusedEntry = \notes { c4 }
 #(define musicQuotes (make-hash-table 29))
 
 %%#(define-public toplevel-music-handler ly:parser-add-book-and-score)
+#(define toplevel-book-handler default-toplevel-book-handler)
 #(define toplevel-music-handler default-toplevel-music-handler)
+#(define toplevel-score-handler default-toplevel-score-handler)
index 9d8b15f8e954eb42bb7cf84e6f37d8be120a9fd9..9a881e8ec6e2d4348edc2666d42df471747edc1a 100644 (file)
@@ -21,6 +21,7 @@
 %%
 
 #(if (and (ly:get-option 'old-relative)
+      (defined? 'input-file-name)
       (not (ly:get-option 'old-relative-used)))
   (ly:warn (string-append
            "\n"
index 963f064ce1e532c7fb9f917e355edde1e1d2342a..5ca36f86f8ebd8f4d5c982f8f1413002f5330123 100644 (file)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; lily specific variables.
-(define-public default-toplevel-music-handler ly:parser-add-book-and-score)
 
 (define-public default-script-alist '())
 
 (define-public safe-mode? #f)
 
+;; parser stuff.
+(define-public (print-music-as-book parser music)
+  (let* ((score (ly:music-scorify music))
+        (book (ly:score-bookify score)))
+    (ly:parser-print-book parser book)))
+
+(define-public (print-score-as-book parser score)
+  (let ((book (ly:score-bookify score)))
+    (ly:parser-print-book parser book)))
+
+(define-public (print-score parser score)
+  (let ((book (ly:score-bookify score)))
+    (ly:parser-print-score parser book)))
+               
+(define-public default-toplevel-music-handler print-music-as-book)
+(define-public default-toplevel-book-handler ly:parser-print-book)
+(define-public default-toplevel-score-handler print-score-as-book)
+;;(define-public toplevel-music-handler print-music-as-book)
+;;(define-public toplevel-music-handler toplevel-music-functions)
+;;(define-public toplevel-music-handler
+;;  (lambda (x y) (print-music-as-book x y)))
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Unassorted utility functions.
 
index 6207329357acf94246067b5b2936139ae487f5fb..bdbe2d393d53b030b980c98aeec5016d50c7b3a6 100644 (file)
@@ -1,11 +1,11 @@
-;;;; music-functions.scm -- implement Scheme output routines for PostScript
+;;;; music-functions.scm --
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
 ;;;; (c)  1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
-;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;;;                 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
-(use-modules (ice-9 optargs)) 
+;; (use-modules (ice-9 optargs)) 
 
 ;;; ly:music-property with setter
 ;;; (ly:music-property my-music 'elements)
@@ -723,5 +723,3 @@ use PianoStaff as a context. "
       (else
        (ly:warn (string-append "Unknown accidental style: " (symbol->string style)))
        (make-sequential-music '()))))))
-
-
index eaafc7dbad8a289ba12192d5d72886df152c9d69..2689e9bce35c1e86e600aaf7c45f543117464ef4 100644 (file)
@@ -298,6 +298,7 @@ output = {
 
 PREAMBLE_LY = r'''%%%% Generated by %(program_name)s
 %%%% Options: [%(option_string)s]
+#(define toplevel-score-handler ly:parser-print-score)
 %(preamble_string)s
 \paper {%(paper_string)s
 }