From e6895cdbcf30f3683a8c1b1c50dbb1b154ca6bdb Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Mon, 3 Aug 2015 09:23:40 +0200 Subject: [PATCH] Issue 4537/1: Let \addlyrics accept an optional context mod Since \addlyrics always creates a new Lyrics context, there seems to be little point in not allowing it to have a \with clause. This change allows the use of the syntax \new Voice {...} \addlyrics \with ... {...} in order to achieve the effect of what previously required << \new Voice = "name" {...} \new Lyrics \with ... \lyricsto "name" {...} >> --- lily/parser.yy | 18 +++++++++++++----- scm/ly-syntax-constructors.scm | 8 +++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lily/parser.yy b/lily/parser.yy index 3ed3216cd4..87edcdafed 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1523,11 +1523,19 @@ context_prefix: ; new_lyrics: - ADDLYRICS lyric_mode_music { - $$ = scm_list_1 ($2); - } - | new_lyrics ADDLYRICS lyric_mode_music { - $$ = scm_cons ($3, $1); + ADDLYRICS optional_context_mod lyric_mode_music { + Context_mod *ctxmod = unsmob ($2); + SCM mods = SCM_EOL; + if (ctxmod) + mods = ctxmod->get_mods (); + $$ = scm_acons ($3, mods, SCM_EOL); + } + | new_lyrics ADDLYRICS optional_context_mod lyric_mode_music { + Context_mod *ctxmod = unsmob ($3); + SCM mods = SCM_EOL; + if (ctxmod) + mods = ctxmod->get_mods (); + $$ = scm_acons ($4, mods, $1); } ; diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm index cd200fa2c2..810a30b333 100644 --- a/scm/ly-syntax-constructors.scm +++ b/scm/ly-syntax-constructors.scm @@ -310,14 +310,16 @@ into a @code{MultiMeasureTextEvent}." 'origin (ly:music-property music 'origin)))) (voice-type (ly:music-property voice 'context-type)) (lyricstos (map - (lambda (mus) + (lambda (mus+mods) (with-location - (ly:music-property mus 'origin) + (ly:music-property (car mus+mods) 'origin) (ly:set-origin! (make-music 'ContextSpeccedMusic 'create-new #t 'context-type 'Lyrics + 'property-operations (cdr mus+mods) 'element (lyric-combine - voice-name voice-type mus))))) + voice-name voice-type + (car mus+mods)))))) addlyrics-list))) (make-simultaneous-music (cons voice lyricstos)))) -- 2.39.2