[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Iterators in Scheme?
From: |
David Kastrup |
Subject: |
Re: Iterators in Scheme? |
Date: |
Fri, 07 Aug 2020 00:18:58 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Niols <niols@niols.fr> writes:
> Hello again,
[...]
> I have not managed to override the "\repeat" music function.
It isn't a music function but a "reserved" word in LilyPond.
> I suspect there is something I do not understand in the order in which
> things are executed in LilyPond.
>
> I have however found a solution based on overriding "make-music". I
> replace "make-music" by a wrapper around it that adds the callback
> from the snippet to all 'VoltaRepeatedMusic and leaves the rest
> alone. This is actually just a few lines:
>
> #(define the-make-music make-music)
>
> #(define (make-music-wrapped name . music-properties)
> (let ((music (apply the-make-music (cons name music-properties))))
> (if (equal? name 'VoltaRepeatedMusic)
> (ly:music-set-property! music 'elements-callback new-volta-set))
> music))
>
> #(set! make-music make-music-wrapped)
>
> It might not be the cleanest, but that is all I have, and that seems
> to work.
It would be easier to do
music-descriptions.VoltaRepeatedMusic.elements-callback = ...
A cursory glance would suggest that might work (though its effect would
not be limited to one session).
You could also try to redefine the make-volta-set function.
>> 2. Maybe there is a way to define a function that will be ran before
>> processing on any music? But this I have no idea if this is
>> possible, or how to do it, and my research has proven ineffective so
>> far.
There are the scorification hooks.
>> 3. Maybe there is a way to override the "make-volta-set" callback
>> instead of creating a new one? Such that then, in LilyPond's normal
>> execution, it uses the new definition and not and old one that then
>> needs to be replaced?
>
> For 2. and 3., I still have no idea as this is far beyond my
> understanding of the internals of LilyPond. I am not really looking
> into it though.
Not a matter of internals.
#(define original-make-volta-set make-volta-set)
(define (make-volta-set ...) ...)
Possibly
(set! make-volta-set (lambda (...) ...))
but I think that the define probably works.
>
> Thank you for your help; have a great Summer!
> — Niols
>
>
--
David Kastrup