From: Graham Percival Date: Tue, 2 Aug 2005 07:46:58 +0000 (+0000) Subject: Yoshinobu Ishizaki's multiple header definition patch. Thanks! X-Git-Tag: release/2.7.4~39 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5150591b92618e65e8718e72dfd6230d4cfba438;p=lilypond.git Yoshinobu Ishizaki's multiple header definition patch. Thanks! --- diff --git a/ChangeLog b/ChangeLog index 52cd078d3f..3749220e1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-08-02 Yoshinobu Ishizaki + + * lily/lily-parser.cc (get_header): new function. Enable multiple + \header definitions. + + * lily/parser.yy (lilypond_header_body): use get_header. + + * ly/init.ly: + * scm/lily-library.scm (print-score-with-defaults): renamed + $globalheader to $defaultheader + + * Documentation/user/global.itely (Creating titles): added short + explanation that multiple headers are useable. + + 2005-08-01 Han-Wen Nienhuys * lily/module-scheme.cc (LY_DEFINE): new file. diff --git a/Documentation/user/global.itely b/Documentation/user/global.itely index 89adefbef3..f76191eadd 100644 --- a/Documentation/user/global.itely +++ b/Documentation/user/global.itely @@ -943,6 +943,25 @@ may use any @ref{Text markup} commands in the header. } @end lilypond +As demonstrated before, you can use multiple @code{\header} blocks. +When same fields appear in different blocks, the latter is used. +Here is a short example. + +@example +\header @{ + composer = "Composer" +@} +\header @{ + title = "Title" +@} +\score @{ + \new Staff @{ c'4 @} + \header @{ + title = "New title" %overwrite previous one + @} +@} +@end example + A more advanced option is to change the definitions of the following variables in the @code{\paper} block. The init file @file{ly/titling-init.ly} lists the default layout. diff --git a/lily/include/lily-parser.hh b/lily/include/lily-parser.hh index 9a2fd02f63..c971d94c32 100644 --- a/lily/include/lily-parser.hh +++ b/lily/include/lily-parser.hh @@ -72,5 +72,6 @@ SCM ly_parser_scorify (SCM, SCM); Output_def *get_layout (Lily_parser *parser); Output_def *get_midi (Lily_parser *parser); Output_def *get_paper (Lily_parser *parser); +SCM get_header(Lily_parser *parser); #endif /* LILY_PARSER_HH */ diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index 08fae1ad64..0119f99398 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -215,3 +215,12 @@ get_paper (Lily_parser *parser) return layout; } +SCM +get_header(Lily_parser *parser) +{ + SCM id = parser->lexer_->lookup_identifier("$defaultheader"); + if (!ly_is_module (id)) + id = ly_make_anonymous_module (be_safe_global); + + return id; +} diff --git a/lily/parser.yy b/lily/parser.yy index 511351e137..eb0dc92973 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -568,7 +568,7 @@ object_id_setting: toplevel_expression: lilypond_header { - THIS->lexer_->set_identifier (ly_symbol2scm ("$globalheader"), $1); + THIS->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1); } | add_quote { @@ -625,7 +625,7 @@ embedded_scm: lilypond_header_body: { - $$ = ly_make_anonymous_module (be_safe_global); + $$ = get_header(THIS); THIS->lexer_->add_scope ($$); } | lilypond_header_body assignment { @@ -754,7 +754,7 @@ book_body: $$->set_spot (@$); $$->paper_ = dynamic_cast (unsmob_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"))->clone ()); $$->paper_->unprotect (); - $$->header_ = THIS->lexer_->lookup_identifier ("$globalheader"); + $$->header_ = THIS->lexer_->lookup_identifier ("$defaultheader"); } | book_body paper_block { $$->paper_ = $2; diff --git a/ly/init.ly b/ly/init.ly index c17531f6b6..e9b5a76398 100644 --- a/ly/init.ly +++ b/ly/init.ly @@ -15,7 +15,7 @@ #(ly:set-option 'old-relative #f) #(define toplevel-scores '()) #(define output-count 0) -#(define $globalheader #f) +#(define $defaultheader #f) #(define version-seen? #f) \maininput @@ -37,4 +37,4 @@ #(if (pair? toplevel-scores) (toplevel-book-handler parser - (apply ly:make-book $defaultpaper $globalheader toplevel-scores))) + (apply ly:make-book $defaultpaper $defaultheader toplevel-scores))) diff --git a/scm/lily-library.scm b/scm/lily-library.scm index fefab95947..ceb2e7d69a 100644 --- a/scm/lily-library.scm +++ b/scm/lily-library.scm @@ -43,19 +43,19 @@ ;; parser stuff. (define-public (print-music-as-book parser music) - (let* ((head (ly:parser-lookup parser '$globalheader)) + (let* ((head (ly:parser-lookup parser '$defaultheader)) (book (ly:make-book (ly:parser-lookup parser $defaultpaper) head score))) (ly:parser-print-book parser book))) (define-public (print-score-as-book parser score) - (let* ((head (ly:parser-lookup parser '$globalheader)) + (let* ((head (ly:parser-lookup parser '$defaultheader)) (book (ly:make-book (ly:parser-lookup parser $defaultpaper) head score))) (ly:parser-print-book parser book))) (define-public (print-score parser score) - (let* ((head (ly:parser-lookup parser '$globalheader)) + (let* ((head (ly:parser-lookup parser '$defaultheader)) (book (ly:make-book (ly:parser-lookup parser $defaultpaper) head score))) (ly:parser-print-score parser book))) @@ -100,7 +100,7 @@ (let* ((paper (ly:parser-lookup parser '$defaultpaper)) (layout (ly:parser-lookup parser '$defaultlayout)) - (header (ly:parser-lookup parser '$globalheader)) + (header (ly:parser-lookup parser '$defaultheader)) (count (ly:parser-lookup parser 'output-count)) (base (ly:parser-output-name parser)))