Am 24.04.2018 um 13:46 schrieb David Kastrup:

parser.yy is actually quite explicit here:

// We must not have lookahead tokens parsed in lyric mode.  In order
// to save confusion, we take almost the same set as permitted with
// \lyricmode and/or \lyrics.  However, music identifiers are also
// allowed, and they obviously do not require switching into lyrics
// mode for parsing.

lyric_mode_music:
        {
                parser->lexer_->push_lyric_state ();
        } grouped_music_list
        {
                parser->lexer_->pop_state ();
                $$ = $2;
        }
        | MUSIC_IDENTIFIER
        ;

It's not like LilyPond is overdocumented.  When there is an explicit
comment, chances are that it's sort-of relevant.

I read that comment. But nevertheless I do not see how a music
function could disturb anything at that point.

Usage example attached ...

Knut
\version "2.21.0"

myscore = #(define-scheme-function () () 
           (ly:parser-include-string #{
            "\score {\music \addlyrics { \words }  \layout {}}" #}))
%                                      |        |
%     I'd like to get rid of those curly brackets
%
% At some places the lilypond gammar does not allow to
% use a MUSIC_FUNCTION instead of a MUSIC_IDENTIFIER or a
% grouped_music_list. The solution is to use "{ \name }"
% instead of "\name" in those cases. 


% If you use
%
%    name = some_music_or_lyrics
%
% name is given the meaning that some_music_or_lyrics has at
% the time of the definition.
%
% If you use
%
%   \macro "name = some_music_or_lyrics"
%
% instead, name is defined to be a music function with the
% meaning of some_music_or_lyrics at the time of its usage.


macro = #(define-scheme-function (arg) (string?)
           (let* (
               (index (string-index arg #\=))
               (left (string-take arg index))
               (right (string-drop arg (+ 1 index))))
           (ly:parser-include-string  (string-append
               left " = #(define-music-function () () #{ " right  " #})" ))))

musA = \relative { c'4 e d f g2 }
musB = \relative { g'4 g a b c2 }
musC = \relative { g'4 g f d c2 }
musD = \relative { a'4 a a b c1 \bar "|." }

lyrA = \lyricmode { A B C D E }
lyrB = \lyricmode { F G H I J }
lyrC = \lyricmode { f g h i j }
lyrD = \lyricmode { V W X Y Z }

\macro "music = \musA \musB \musD"
\macro "words = \lyrA \lyrB \lyrD"
\myscore

musB = \musC
lyrB = \lyrC
\myscore

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to