Hi All,
to use a file for including definitions and also to compile it
stand-alone, I use a command to conditionally create the score. It is
integrated in a system to execute templates:
https://github.com/openlilylib/snippets/tree/master/templates/lalily
Attached is a short example, which conditionally compiles (without the
template framework).
Cheers,
Jan-Peter
Am 27.04.14 09:00, schrieb Nick Payne:
When I'm setting up movements for a piece where I want to be able to
both build them stand-alone and \include them in another file to build
the entire piece, I put the \paper, \header, and \score blocks at the
end of the movement file, surrounded by a comment block:
%{
\paper {
% \paper stuff here
}
\header {
% \header stuff here
}
\score {
% \score stuff here
}
%}
If I want to build the movement on its own, I change the %{ to %%{,
which comments out the comment block beginning, so that \paper,
\header, and \score are all parsed. If I'm including the movement in
another file as part of a complete piece, I just need to change %%{ to
%{ so that \paper, \header, and \score blocks are all commented out.
\version "2.18.2"
#(use-modules (ice-9 regex))
#(define-public (lalily-test-location? parser location)
(let ((outname (ly:parser-output-name parser))
(locname (car (ly:input-file-line-char-column location))))
; check if parser-output-name and location-name match
(regexp-match? (string-match (format "^(.*/)?~A\\.i?ly$" outname) locname))
))
doScore =
#(define-void-function (parser location cond? mus)(procedure? ly:music?)
; if condition is met, parser shall create score
(if (cond? parser location)
(begin
(ly:parser-define! parser 'doScoreMusic mus)
(ly:parser-include-string parser (format "\\score { \\doScoreMusic }"))
)))
% music definition
exampleMusic = \relative c'' { c4 b bes a }
% create score, if condition is met
\doScore #lalily-test-location? \exampleMusic
\version "2.18.2"
% exampleMusic is defined, but not engraved
\include "conditional-compile.ly"
% display defined music
#(display-scheme-music exampleMusic)
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user