]> git.donarmstrong.com Git - lilypond.git/commitdiff
Use book-(score|text|music)-handlers in book_body elements, after the
authorNicolas Sceaux <nicolas.sceaux@free.fr>
Fri, 18 May 2007 14:16:48 +0000 (16:16 +0200)
committerNicolas Sceaux <nicolas.sceaux@free.fr>
Fri, 18 May 2007 14:16:48 +0000 (16:16 +0200)
fashion of the toplevel-(score|text|music)-handlers used for
toplevel_expressions.
Allow composite_music (and thus \pageBreak) in \book blocks.

lily/book-scheme.cc
lily/parser.yy
ly/declarations-init.ly
scm/lily-library.scm

index 7bb9ba0c6b15a3347701e1a5a72caff015b6995d..567504cf070c739e21ecf1ab1fbcc5f18b8a3d30 100644 (file)
@@ -89,3 +89,12 @@ LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
   return SCM_UNSPECIFIED;
 }
 
+LY_DEFINE (ly_book_add_score_x, "ly:book-add-score!",
+          2, 0, 0, (SCM book_smob, SCM score),
+          "Add @var{score} to @var{book_smob} score list.")
+{
+  LY_ASSERT_SMOB (Book, book_smob, 1);
+  Book *book = unsmob_book (book_smob); 
+  book->add_score (score);
+  return SCM_UNSPECIFIED;
+}
index 9df1034d165a2fbabb5b4c052cf917d8698dcbd3..9d209b9462cdb881cc973911f10fa4715b891823 100644 (file)
@@ -651,12 +651,19 @@ book_body:
                $2->unprotect ();
        }
        | book_body score_block {
-               SCM s = $2->self_scm ();
-               $$->add_score (s);
-               $2->unprotect();
+               Score *score = $2;
+               SCM proc = PARSER->lexer_->lookup_identifier ("book-score-handler");
+               scm_call_2 (proc, $$->self_scm (), score->self_scm ());
+               score->unprotect ();
+       }
+       | book_body composite_music {
+               Music *music = unsmob_music ($2);
+               SCM proc = PARSER->lexer_->lookup_identifier ("book-music-handler");
+               scm_call_3 (proc, PARSER->self_scm (), $$->self_scm (), music->self_scm ());
        }
        | book_body full_markup {
-               $$->add_score ($2);
+               SCM proc = PARSER->lexer_->lookup_identifier ("book-text-handler");
+               scm_call_2 (proc, $$->self_scm (), $2);
        }
        | book_body lilypond_header {
                $$->header_ = $2;
index 015e6dc75408d3918d526bddc542ead7af0b3747..364068c043c0f8cd60bb9abc48139c53860c37ed 100644 (file)
@@ -113,3 +113,6 @@ setDefaultDurationToQuarter = { c4 }
 #(define toplevel-score-handler collect-scores-for-book)
 #(define toplevel-text-handler collect-scores-for-book)
 
+#(define book-music-handler collect-book-music-for-book)
+#(define book-score-handler ly:book-add-score!)
+#(define book-text-handler ly:book-add-score!)
index 2758825016cae1ed73b0aafeee287991754e32a8..7a1141d8f4e284af472aa6d6ae0331587d283784 100644 (file)
@@ -63,7 +63,7 @@
    parser 'toplevel-scores
    (cons score (ly:parser-lookup parser 'toplevel-scores))))
 
-(define-public (collect-music-for-book parser music)
+(define (collect-music-aux score-handler parser music)
   (define (music-property symbol)
     (let ((value (ly:music-property music symbol)))
       (if (not (null? value))
         (for-each (lambda (symbol)
                     (let ((permission (music-property symbol)))
                       (if (symbol? permission)
-                          (collect-scores-for-book
-                           parser
+                          (score-handler
                            (ly:make-page-marker symbol
                                                 (if (eqv? 'forbid permission)
                                                     '()
                                                     permission))))))
                   (list 'line-break-permission 'page-break-permission
-                         'page-turn-permission)))
+                        'page-turn-permission)))
        ((not (music-property 'void))
         ;; a regular music expression: make a score with this music
         ;; void music is discarded
-        (collect-scores-for-book parser (scorify-music music parser)))))
+        (score-handler (scorify-music music parser)))))
+
+(define-public (collect-music-for-book parser music)
+  "Top-level music handler"
+  (collect-music-aux (lambda (score)
+                      (collect-scores-for-book parser score))
+                     parser
+                    music))
+
+(define-public (collect-book-music-for-book parser book music)
+  "Book music handler"
+  (collect-music-aux (lambda (score)
+                      (ly:book-add-score! book score))
+                     parser
+                    music))
 
 (define-public (scorify-music music parser)
   "Preprocess MUSIC."