Greetings lilyponders,  

I’m trying to figure out how to use \applyContext to modify StaffSymbol grob 
properties.  The examples here

http://www.lilypond.org/doc/v2.19/Documentation/extending/context-evaluation

are very helpful, but I haven’t been able to get things working with 
StaffSymbol and \stopStaff \startStaff.  There’s probably some subtlety that 
I’m missing…  (Maybe it has to do with the difference between \temporary 
\override and \override ?)  Below is a tiny example (not my actual use case).

Thanks for any help with this,
-Paul


\version "2.19.22"

% These work as expected
{
  c'
  \stopStaff
  \startStaff
  \override Staff.StaffSymbol.color = #red
  c'
  \override Staff.StaffSymbol.color = #green
  \stopStaff
  \startStaff
  c’
}

{
  \applyContext
  #(lambda (context)
     ;; access context properties pick a property setting based on them...
     (ly:context-pushpop-property context 'StaffSymbol 'color blue))
  c’
}

% But so far these don’t...

myfunc =
#(define-music-function () ()
   (define mycolor red)
   #{
     \applyContext
     #(lambda (context)
        ;; access context properties and pick a property setting based on 
them...
        (set! mycolor green))
     \override Staff.StaffSymbol.color = #mycolor
   #})

{
  c’
  % the order of these commands does not seem to affect things
  \stopStaff \startStaff
  \applyContext
  #(lambda (context)
     ;; access context properties and pick a property setting based on them...
     (ly:context-pushpop-property context 'StaffSymbol 'color blue))
  c'
  \myfunc
  \stopStaff \startStaff
  c'
}






_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to