"Rick Hansen (aka RickH)" <[EMAIL PROTECTED]> writes: > Has anyone on this list extended the \include lilypond command to also do > simple token replacement as it is "including" the text? IOW like this: > > \include "myFile.ly" @myToken1=a; @myToken2=25; @myToken3="replace with > this" > > Whereby @myToken1, 2 and 3 above will be whole word searched and replaced > with the data between the = sign and semi-colon. > > Or similar? > > Kind of like a "smart" \include? > > If you have done this can you share it or sell it to me? (please dont > suggest m4, I gave up on that monster)
I use in my scores some functions called \includeScore, \includeNotes, \includeLyrics, etc. You can look at the sources at <http://nicolas.sceaux.free.fr/lully/> or this article: <http://nicolas.sceaux.free.fr/index.php/2006/06/29/9> The LilyPond distribution has a function that makes a conditional include: see \includePageLayoutFile in ly/music-functions-init.ly. But then, there is no textual replacement when parsing LilyPond file; instead you should use variables. %% The function definition: myInclude = #(define-music-function (parser location filename bindings) (string? list?) ..set some variables and include the file.. (make-Music 'SequentialMusic 'void #t)) %% Function usage: \myInclude "foo.ily" #'((myPadding . 4) (myString . "hello") (myMusicPattern . #{ c d e f #})) %% foo.ily: \score { \new Staff { \override TextScript #'padding = \myPadding << s0^\markup \italic \myString \repeat unfold 4 \myMusicPattern >> } } nicolas _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user