lilypond-user
[Top][All Lists]
Advanced

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

Re: "include" music-function


From: Jan-Peter Voigt
Subject: Re: "include" music-function
Date: Sat, 7 Jan 2012 11:33:32 +0100

Ah, yes ... I will rewrite this, when I'm in my machine again 

Cheers, Jan-Peter


Am 07.01.2012 um 09:42 schrieb David Kastrup <address@hidden>:

> 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
> 
> 
> _______________________________________________
> lilypond-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-devel



reply via email to

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