From 00e7e96f8393ad1fe86f57cf90f4567142bd4e72 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sat, 8 Feb 2014 19:05:16 +0100 Subject: [PATCH] Issue 3827: remove the necessity to have a \layout block in a \markup \score ... 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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lily/parser.yy b/lily/parser.yy index 4b063960d6..b89c561ea8 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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 (); } -- 2.39.2