lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: \applyContext, StaffSymbol, and \stopStaff \startStaff


From: David Kastrup
Subject: Re: \applyContext, StaffSymbol, and \stopStaff \startStaff
Date: Mon, 19 Oct 2015 07:56:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Paul Morris <address@hidden> writes:

> % 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'
> }

I think your main problem is that you are using \applyContext here at
Voice level where it does not really do anything worthwhile.

Try \context Staff \applyContext ...

Though frankly I have no idea what \myFunc is trying to do.  You are
keeping state in a global variable which is not going to work when using
\myFunc in several contexts in parallel.

-- 
David Kastrup



reply via email to

[Prev in Thread] Current Thread [Next in Thread]