]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3827: remove the necessity to have a \layout block in a \markup \score ...
authorDavid Kastrup <dak@gnu.org>
Sat, 8 Feb 2014 18:05:16 +0000 (19:05 +0100)
committerDavid Kastrup <dak@gnu.org>
Fri, 14 Feb 2014 08:35:40 +0000 (09:35 +0100)
It turns out that this is not really fixable in the backend since what
is called "layout" in the markup function definitions does not
actually correspond to \layout but rather to \paper.  Very funny.

So this is solved in the parser itself when reading a \score or
\score-lines to be used in a markup or markup list by cloning
$defaultlayout as necessary (which simulates \layout {}) whenever the
score is without an output definition.

lily/parser.yy

index 4b063960d66e6d16b486c03a1098d1641da05414..b89c561ea806d6e8404d69800fb7201f67c9177e 100644 (file)
@@ -3495,7 +3495,13 @@ markup_uncomposed_list:
                SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
                parser->lexer_->push_note_state (nn);
        } '{' score_body '}' {
-               unsmob_score ($4)->origin ()->set_spot (@$);
+               Score *sc = unsmob_score ($4);
+               sc->origin ()->set_spot (@$);
+               if (sc->defs_.empty ()) {
+                       Output_def *od = get_layout (parser);
+                       sc->add_output_def (od);
+                       od->unprotect ();
+               }
                $$ = scm_list_1 (scm_list_2 (ly_lily_module_constant ("score-lines-markup-list"), $4));
                parser->lexer_->pop_state ();
        }
@@ -3572,7 +3578,13 @@ simple_markup:
                SCM nn = parser->lexer_->lookup_identifier ("pitchnames");
                parser->lexer_->push_note_state (nn);
        } '{' score_body '}' {
-               unsmob_score ($4)->origin ()->set_spot (@$);
+               Score *sc = unsmob_score ($4);
+               sc->origin ()->set_spot (@$);
+               if (sc->defs_.empty ()) {
+                       Output_def *od = get_layout (parser);
+                       sc->add_output_def (od);
+                       od->unprotect ();
+               }
                $$ = scm_list_2 (ly_lily_module_constant ("score-markup"), $4);
                parser->lexer_->pop_state ();
        }