]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4537/1: Let \addlyrics accept an optional context mod
authorDavid Kastrup <dak@gnu.org>
Mon, 3 Aug 2015 07:23:40 +0000 (09:23 +0200)
committerDavid Kastrup <dak@gnu.org>
Sat, 8 Aug 2015 07:40:10 +0000 (09:40 +0200)
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
scm/ly-syntax-constructors.scm

index 3ed3216cd4886a7ab01479784268bf84dd7741a3..87edcdafed7cc33c4cf48e4dc68c4998789e67dd 100644 (file)
@@ -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<Context_mod> ($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<Context_mod> ($3);
+               SCM mods = SCM_EOL;
+               if (ctxmod)
+                       mods = ctxmod->get_mods ();
+               $$ = scm_acons ($4, mods, $1);
        }
        ;
 
index cd200fa2c28f41301e66fedbd0525de62ee1bab5..810a30b333e2f63852bf89c96ca06b3f6010c28d 100644 (file)
@@ -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))))