lilypond-devel
[Top][All Lists]
Advanced

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

Re: "include" music-function


From: David Kastrup
Subject: Re: "include" music-function
Date: Sat, 07 Jan 2012 09:42:12 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Jan-Peter Voigt <address@hidden> writes:

> Am 06.01.2012 10:17, schrieb Jan-Peter Voigt:
>> Am 06.01.2012 09:35, schrieb Jan-Peter Voigt:
>>> Hello David,
>>>
>>> the \sourcefilename hint is helpful! Thank you!
>>> If I use this in my function and do a ly:parser-clone, the location
>>> is up to date:
>>> ...
>>> Now I will look, if this is working also with
>>> ly:parser-include-string while resetting filename and fileline at
>>> the end, so that definitions in the included file get into the
>>> current parser.
>>>
>>>
>> ... yes it does:
>>
>> --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)))
>>           (locpos (cadr (ly:input-file-line-char-column location))))
>>          (if (or (string=? outname locname)(string-suffix? outname
>> locname))
>>              (begin
>>                (ly:parser-include-string parser (format
>> "\\sourcefilename \"~A\" \\sourcefileline 0\n" (ly:find-file file)))
>>                (ly:parser-include-string parser (ly:gulp-file file))
>>                (ly:parser-include-string parser (format "
>> \\sourcefilename \"~A\" \\sourcefileline ~A\n" locname locpos))))
>>          (make-music 'SequentialMusic 'void #t))))
>> --snip--
>>
>> ... but if I include a file in an included file, it will not
>> parse. I will investigate that for more info.
> OK, now I had lunch and saw my own mistakes ...
>
> Here are the two functions I implemented ... still a bit clumsy, but
> it works for now ... if you are interested *how* and *why* to use
> them, don't hesitate to mail me!

Actually, this is quite too complicated...

(ly:parser-include-string parser
  (format #f "\\include ~S" file))

should likely be all that is needed here.

Sorry for thinking too complicated.

-- 
David Kastrup




reply via email to

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