lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"include" music-function


From: Jan-Peter Voigt
Subject: "include" music-function
Date: Thu, 05 Jan 2012 12:32:57 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111108 Lightning/1.0b2 Thunderbird/3.1.16

Dear lily-list-members,

first of all: A happy new year!

In my projects I often combine several files, each containing one piece, to a book. In fact, I store the music in a scheme-based structure to instantiate it later. The included files shall intentionally not create a PDF, so that instantiation can be organized in bookparts as needed. But when I work on a specific piece I want to debug it without compiling the whole book. One solution would be to use frescobaldi and a comment %%master: ../<main>.ly at the end of the file. But then I have to create a master-file for each part. So I created a music-function to include a testfile wich contains instructions to instantiate the music stored in my structures only if I am compiling this file directly:
--snip--
#(define-public includeLocal (define-music-function (parser location file)(string?)
    (let ((outname (format "~A.ly" (ly:parser-output-name parser)))
          (locname (car (ly:input-file-line-char-column location))))
(if (or (string=? outname locname)(string-suffix? outname locname))
             (let ((content (ly:gulp-file file)))
                  (ly:parser-include-string parser content)))
         (make-music 'SequentialMusic 'void #t))))

\includeLocal "test.ly"
--snip--
This function first compares the outname with the location name and only includes the file if they match. (This should not work, if you have set some output-suffix!)

This is a usable solution to me. But I would like to have the correct location info available, while parsing the included file. Is it possible to create an arbitrary "include"-music-function? This would make it possible, to (for example) include all files in a directory or matching a specific pattern.

Cheers,
Jan-Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]