The situation is that I want to write out my statistical info collected during 
the score block processing to an external CSV.
In my case students are given a lilypond file template which they need to use. 
This template contains a single score block in which they need to put their 
However, some students are rather creative, and spread out the same work over 
multiple score blocks. 

It is very unlikely that they will use book for structuring and in the rare 
case that might happen I can always edit it out manually.
So, it looks like wrapping the toplevel-book-handler and adding my own stats 
writing will be exactly what I need.

Thanks a lot!



> Op 22 feb. 2018, om 10:00 heeft David Kastrup <d...@gnu.org> het volgende 
> geschreven:
> Maurits Lamers <maur...@weidestraat.nl> writes:
>> Hi, 
>> Thanks for your suggestion! Do I understand from your reply that you
>> don't think there is a dynamic option, ie without adjusting the
>> lilypond code being processed?
>> To clarify the context a bit: what I am doing is reviewing homework by
>> students. This means that I am running my reviewer script (lilypond
>> file with embedded guile with event listeners) as a side-load script
>> through the -dinclude-settings option on the lilypond code files they
>> provided.
>> It is of course possible to preprocess the input files by appending
>> such a scheme call (automatically). If I can have a dynamic option
>> (such as listening to an event), I would rather like to have that
>> option as it reduces the amount of things that can go wrong during
>> processing.
> All of the processing of top level expressions (also book level
> expressions) is done through hooks.  You can replace those hooks with
> your own, call the underlying function yourself, and then work with
> stats.  It will still not give you an "end-of-file" hook, though.
> However, if they don't use books for structuring the input, all
> collected scores at the end of file are placed into one book and
> processed then, so the book processing hook might still be good for you.
> The respective hooks are set with
> ly/declarations-init.ly:#(define toplevel-book-handler 
> print-book-with-defaults)
> ly/declarations-init.ly:#(define toplevel-bookpart-handler 
> collect-bookpart-for-book)
> ly/declarations-init.ly:#(define toplevel-music-handler 
> collect-music-for-book)
> ly/declarations-init.ly:#(define toplevel-score-handler 
> collect-scores-for-book)
> ly/declarations-init.ly:#(define toplevel-text-handler 
> collect-scores-for-book)
> -- 
> David Kastrup

lilypond-user mailing list

Reply via email to