[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More explanations to make-engraver available
From: |
David Kastrup |
Subject: |
Re: More explanations to make-engraver available |
Date: |
Sun, 10 Jun 2018 09:01:50 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Urs Liska <address@hidden> writes:
> Am I understanding the following things right?
>
> 1)
>
> (listeners ((note-event engraver event) <body>))
>
> creates a function that is called for each note-event. It is passed
> the engraver (from which the context can be derived) and the event
> itself, and these can be used in the function body.
>
> To create multiple listeners I can simply add further list elements of
> the form
> ((<event-class> engraver event) <body>)
Basically.
> 2)
> From the above I'm slightly confused about what the "engraver" is
> here. Somehow the engraver I'm creating with make-engraver must be a
> different object than the one that is passed to the listener, isn't
> it?
make-engraver creates an engraver description, basically an alist. It's
a convenience macro since otherwise you need to juggle a lot with
backquotes and lambdas and whatnot.
What's passened to the listener is the actual context-residing engraver
created from this description.
> 3)
> As an alternative to the above syntax I can write
> (listeners
> (<event-class> . <handler>))
> where <handler> is a function that expects the same <engraver> and
> <event> arguments as the ad-hoc functions above.
That's sort of a pass-through for the make-engraver macro. The
resulting alist is the same.
> 4)
> (initialize) is called once, when the context is started being
> parsed(?),
Iterated. Parsing happens when encountering it in the text.
> and the <translator> only has information about the context, not about
> any elements (music) within. So that can be used to set up things,
> like printing a message, preparing some storage, reading/setting
> options etc.
>
> 5)
> What are start-translation-timestep and stop-translation-timestep used
> for? IIUC they don't get information about any grobs, so are they used
> to do set-up/housekeeping before or after a timestep is processed?
Basically. start-translation-timestep is not reliable: for implicitly
created contexts, we might already be in the process-music stage and
then the first start-translation-timestep after initialize may be
missing. Engravers need to be able to account for that. Haven't been
able to fix that so far.
> And (of course) a few more questions:
>
> 1)
> acknowledgers and end-acknowledgers are a little unclear to me.
> The functions in acknowledgers are called whenever a grob is created,
> right? But is that while processing the input or later while doing
> engraving?
When an engraver announces a grob (or the end of a spanner)
acknowledgers (or end-acknowledgers) are called.
> And what is it we can do here with the <engraver> and
> <source-engraver> arguments?
<engraver> is your own engraver, <source-engraver> is the engraver that
created the grob.
> When are the functions in end-acknowledgers called?
>
> 2)
> When are process-music and process-acknowledgers called and to what
> information do we have access in these functions?
process-music is called once after the iterators have called all
listeners for the current timestep.
process-acknowledgers is described well enough in the engraver tutorial
I think.
--
David Kastrup