[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: \include problem in Scheme function
From: |
David Kastrup |
Subject: |
Re: \include problem in Scheme function |
Date: |
Thu, 09 May 2013 13:21:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Urs Liska <address@hidden> writes:
> Am Donnerstag, den 09.05.2013, 11:38 +0200 schrieb David Kastrup:
>> Urs Liska <address@hidden> writes:
>>
>> > Hi,
>> >
>> > I want to implement a way to compile a score from a given music
>> > expression. THe idea is to have a huge score edited in small chunks and
>> > being able to only compile the tiny chunk one works on currently.
>> >
>> > First I tried several things to compile a book within the function but
>> > didn't succeed.
>>
>> Minimal example?
>>
>
> Minimal example (for that part) is already the solution (sometimes you
> have to post a question in order to be able to answer it yourself :-)
>
> compileSegment =
> #(define-void-function (parser location segment)
> (ly:music?)
> ; construct book
> (let ((book #{ \book { \score { \new Staff $segment } } #}))
> (ly:book-process book #{ \paper {} #} #{ \layout {} #}
> (ly:parser-output-name parser))
> ); close let
> ) % end function
>
> music = { c d e d c \origBreak } % origBreak is defined in an include-file
>
> \compileSegment \music
>
> ################################################
>
> What I didn't achieve so far is how to \include library files.
Separate \include library
perhaps?
> It seems I can write an \include statement within \book before \score,
> and it seems to find the file.
> But it seems there are two problems with that:
> a)
> 'music' is parsed before the \include is done within the function, so
> \origBreak is still 'unknown'
> b)
> I get all sorts of messages about syntax errors in the included file, so
> I have the impression such an \include from within a Scheme function is
> something quite different from a regular \include in LilyPond mode.
It is more like an \include from within a \book being something quite
different. Also with #{ ... #}, ... is not "top level" but a music
expression.
To get top-level, you'll need something like
$(begin
(ly:parser-parse-string (ly:parser-clone parser) "\\include \"zzz.ly\"")
#{ \xxx c' c' c' c' #})
which works reasonably well here.
--
David Kastrup
- \include problem in Scheme function, Urs Liska, 2013/05/09
- Re: \include problem in Scheme function, David Kastrup, 2013/05/09
- Re: \include problem in Scheme function, Urs Liska, 2013/05/09
- Re: \include problem in Scheme function,
David Kastrup <=
- Re: \include problem in Scheme function, Urs Liska, 2013/05/09
- Re: \include problem in Scheme function, David Nalesnik, 2013/05/09
- Re: \include problem in Scheme function, Urs Liska, 2013/05/09
- Re: \include problem in Scheme function, David Nalesnik, 2013/05/09
- Re: \include problem in Scheme function, Urs Liska, 2013/05/09
Re: \include problem in Scheme function, Phil Holmes, 2013/05/09