Hi Jan-Peter,
Jan-Peter Voigt wrote > 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). Wow, thanks, this is a nice solution! So the "conditional-compile.ly" file is the child file (for a single movement) and the "conditional-compile2.ly" file is the parent file (that contains several movements). Below is a version of "conditional-compile.ly" where I added some logging commands if that helps anyone else see how it's working. Your "doScore" function seems to be a workaround for the limitation that music functions can't return a score. (I tried to rewrite it as a music function but got "error: music function cannot return #<Score>". I think this would be a nice standalone snippet for the LSR or openLilyLib. And I need to take a closer look at your lalily template system and edition engraver. Thanks, -Paul BTW, if anyone is wondering what "smob" refers to, for example in "parser-smob" in the docs, I found this ("small object"): https://www.gnu.org/software/guile/manual/html_node/Defining-New-Types-_0028Smobs_0029.html#Defining-New-Types-_0028Smobs_0029 %%%%%%%%%%%%%%%%%%%% % "conditional-compile.ly" \version "2.18.2" #(use-modules (ice-9 regex)) #(define (lalily-test-location? parser location) (let ((outname (ly:parser-output-name parser)) (locname (car (ly:input-file-line-char-column location)))) (display "1. ")(display outname) (newline) (display "2. ")(display locname) (newline) ; check if parser-output-name and location-name match (regexp-match? (string-match (format "^(.*/)?~A\\.i?ly$" outname) locname)) (display "3. ")(display (regexp-match? (string-match (format "^(.*/)?~A\\.i?ly$" outname) locname))) (newline) )) 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 }")) (display "4. ")(display (format "\\score { \\doScoreMusic }"))(newline) ))) % music definition exampleMusic = \relative c'' { c4 b bes a } % create score, if condition is met \doScore #lalily-test-location? \exampleMusic -- View this message in context: http://lilypond.1069038.n5.nabble.com/Pull-in-external-LilyPond-files-into-a-score-of-movements-tp161839p161894.html Sent from the User mailing list archive at Nabble.com. _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user