On Wed, Jun 30, 2021 at 2:43 AM Jean Abou Samra <j...@abou-samra.fr> wrote: > > Hello, > >... > > I'm not sure how you got this output. The way > the code is written, the \applyOutput is separate > from the main \score, so it is a score of its own > containing no actual music. If you move it to > the beginning of the music, you should get at > least one NoteHead, as illustrated here: > > \version "2.22.0" > > { > \applyOutput Score > #(lambda (grob origin context) > (ly:message "~s" grob) > (set! (ly:grob-property grob 'color) > red)) > << > { c d e f } > \\ > { g a b c' } > >> > } > > This also shows the reason why \applyOutput > isn't working as you are expecting. \applyOutput > applies to one single time step. Think of it > as a \once \override. I don't think there > currently exists an equivalent of \applyOutput > for the whole score (perhaps because there were > not many use cases before output-attributes). > > However, this problem can be solved by writing > an engraver (those are the powerful tools that > \applyOutput uses under the hood). > > \version "2.22.0" > > \layout { > \context { > \Score > \consists > #(lambda (context) > (make-engraver > (acknowledgers > ((grob-interface engraver grob source-engraver) > (set! (ly:grob-property grob 'output-attributes) > `((class . ,(grob::name grob)))))))) > } > } > > << > { c d e f } > \\ > { g a b c' } > >> > > > Out of curiosity: what tool is this for? > > Best, > Jean
Thanks for picking up on those errors in the scheme function, Jean. I may have been a little cavelier in copying over the minimal code examples, and I hadn't picked up the quoting error. The output came from inserting (display name "\n"), to observe the output in the compilation process. I tried a variety of locations to place \applyOutput Score #add-class and this one gave me the most objects. Thanks for getting the ball rolling with the suggestion of a custom engraver - it looks like I have some documentation to read! They seem wonderfully useful. I really appreciate your response - thank you again. Cheers, Matt.