mapping a markup-command across strings in lyricmode

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mapping a markup-command across strings in lyricmode

Mark Polesky
I wrote a markup command which takes a string and parses
it to make a special markup.  I'm leaving out the details,
but the input might look something like:

\markup \foo #"abc123"

I want to use this in a Lyrics context, but constantly
retyping "\markup \foo #" is annoying and takes up a lot
of space in my file:

\lyricmode {
  \markup \foo #"abc123" __ _
  \markup \foo #"def456"
  \markup \foo #"ghi789" __ _ _
}

Is there a way to simplify the user interface?  This would
be ideal, but I'm open to other suggestions:

\lyricmode \mapFoo {
  "abc123" __ _ "def456" "ghi789" __ _ _
}

Thanks.
- Mark


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: mapping a markup-command across strings in lyricmode

David Kastrup
Mark Polesky <[hidden email]> writes:

> I wrote a markup command which takes a string and parses
> it to make a special markup.  I'm leaving out the details,
> but the input might look something like:
>
> \markup \foo #"abc123"
>
> I want to use this in a Lyrics context, but constantly
> retyping "\markup \foo #" is annoying and takes up a lot
> of space in my file:
>
> \lyricmode {
>   \markup \foo #"abc123" __ _
>   \markup \foo #"def456"
>   \markup \foo #"ghi789" __ _ _
> }
>
> Is there a way to simplify the user interface?  This would
> be ideal, but I'm open to other suggestions:
>
> \lyricmode \mapFoo {
>   "abc123" __ _ "def456" "ghi789" __ _ _
> }

Try \mapFoo \lyricmode { ... } instead, making \mapFoo a music
function.  You then iterate through the music using something like

mapFoo =
#(define-music-function (parser location music) (ly:music?)
  (for-each
    (lambda (m)
      (set! (ly:music-property m 'text)
            #{ \markup \foo $(ly:music-property m 'text) #}))
    (extract-typed-music music 'lyric-text)))

--
David Kastrup


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user