On 2020-01-15 6:41 pm, Paolo Prete wrote:
Sorry Aaron, I was not precise in my question.
I need to override a property of StaffSymbol, for every staff, outside any music expression/block context. Probably I'm not using the right words even
now.
But what I need is a sort of a "global" variable which is set for any staff without having to put it into some music expression (like \layout {\context
{...}} , or \new Staff \with { ... } etc.).
This is why I asked if is there a Scheme solution

To my knowledge, there is nothing more "global" than the top-level \layout. (The same goes for \header, \paper, and \midi.)

If you are insistent on using Scheme, I believe the following is functionally equivalent:

%%%%
\version "2.19.83"

% LilyPond:
%   \layout { \context { \Staff \override StaffSymbol.color = #red } }
% Scheme:
#(ly:output-def-set-variable! $defaultlayout 'Staff
    (ly:context-def-modify
      (ly:output-def-lookup $defaultlayout 'Staff)
      #{ \with { \override StaffSymbol.color = #red } #}))

<< \new Staff { b'4 } \new Staff { b'4 } >>
%%%%

Note that I still use LilyPond syntax to define the context-mod (i.e. \with block), but even that could be completely done in Scheme:

%%%%
\version "2.19.83"

#(ly:output-def-set-variable! $defaultlayout 'Staff
    (ly:context-def-modify
      (ly:output-def-lookup $defaultlayout 'Staff)
      ; LilyPond:
      ;   #{ \with { \override StaffSymbol.color = #red } #}
      ; Scheme:
      (ly:make-context-mod
        `((assign StaffSymbol ,(ly:make-grob-properties
             `((color . ,red))))))))

<< \new Staff { b'4 } \new Staff { b'4 } >>
%%%%

However, why jump through such Scheme hoops when LilyPond syntax is more direct?


-- Aaron Hill

Reply via email to