Mojca Miklavec <mojca.miklavec.li...@gmail.com> writes: > Hi, > > I've learnt some basics of scheme and managed to write some simple > functions, but I'm unable to figure out how to write a function that > would take all the contents between braces as an argument and return a > markup. > > I would be grateful even if I get just the simplified version working, so that > > \A {<foo>} > > would be translated into > > \markup { \small \override #'(direction . 1) { \dir-column { <foo> } } }
Well, first thing to note is that scheme/music functions do not switch modes for their arguments. So you either need to write something like \A \markup <foo> here to get something in markup mode, or be in lyrics mode (which interprets <foo> as lyrics), \A should be a markup command and are already in markup mode, like \markup \A <foo> . > I would use this markup as part of the lyrics as in > > \lyricsto "melody" { > \A {foo bar} > \A {three short lines} > \A {one} > } Ah, we are in lyrics mode already. That simplifies things. Your arguments will then be of type ly:music? and you'll pick off the respective markup from the 'text field of the lyrics. > In a slightly more advanced version it would be nice to be able to type > > \lyricsto "melody" { > % \command { array of values } > % each entry can have an optional "-<number>" > \A {A1-1} > \A {A1-1 C2-2} > \A {A1-1 C2-2 E2-3} > \A {C2 E2-3} > \A {E2} > } Lyrics mode does not really take text scripts I think. All of A1-1 will likely end up one lyrics syllable. > So far I came up with a function definition > > M = #(define-scheme-function (parser location aFinger aButton) (markup? > markup?) > #{ \markup{ \small \bold \with-color #(rgb-color 0.5 0 0) #aFinger > \small \with-color #(rgb-color 0 0 0.5) #aButton } #} > ) > that can handle input like > \M "1" "A1" > and then I would enter multiple lines of lyrics, but this is tedious > to write, even more so when the number of lines varies from one pitch > to the other. Strings are the most simple form of markup, but I guess that pretty much everything else needs to be explicitly preceded by \markup. You could work here with an optional finger argument as a number: M = #(define-scheme-function (parser location aFinger aButton) ((number?) markup?) (if afinger #{ \markup{ \small \bold \with-color #(rgb-color 0.5 0 0) #aFinger \small \with-color #(rgb-color 0 0 0.5) #aButton } #} ;; #{ \markup whatever you want here when no finger is given #} )) which can handle then both \M 1 "A1" as well as \M "A1" That's basically what I can think of out of the box right now. -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user