[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Has anyone extended \include?
From: |
Nicolas Sceaux |
Subject: |
Re: Has anyone extended \include? |
Date: |
Fri, 22 Dec 2006 21:59:22 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) |
"Rick Hansen (aka RickH)" <address@hidden> 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