lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing lyrics in a music function


From: David Kastrup
Subject: Re: Parsing lyrics in a music function
Date: Thu, 15 Sep 2011 21:16:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Michael Ellis <address@hidden> writes:

> I've written some music functions I use frequently to operate on
> lyrics.  For example, there's one call "lacc" that allows me to
> intermix lyrics and notation by accumulating the lyrics into a list I
> can instantiate later in the \score block.   Very nice and convenient,
> but the usage is a little messy:
>
>
> \lacc \lyricmode { This is a ly -- ric line. }
> c4 d e f | g a
>
> \lacc \lyricmode { Here is the next. }
> b c  | d c2. |
>
> Normally, I deal with the messiness by defining a keystroke macro in
> my editor that wraps a line of bare text in the necessary commands and
> braces.  I now find myself   (skipping a long story)  needing to work
> in an environment where keystroke macros will not be available.  
>
> Is it possible to define a music function that will do the work of my
> keystroke macro?  Ideally I'd like to be able to  write in an input
> file something like
>
> \lyr This is a lyric line
>
> and have LilyPond do the rest,  but none of my attempts thus far have
> worked.

The arguments of a music function are parsed before it is called, so
no.  However, if you already are in lyrics mode, you can pick up the
music in that manner.  You may also think about doing

\lacc " This is a lyric line "

and then using ly:parser-parse-string to pick up lyricmode expressions.
It might be nice at one point of time to be able to call #{ \lyricmode
\somefunction-taking-a-music-argument #} or similar trickery, but this
kind of closure is not available yet.

Make a feature request and offer a bounty...  Perhaps someone will take
it up.

-- 
David Kastrup




reply via email to

[Prev in Thread] Current Thread [Next in Thread]