2.6.1 Context evaluation

Contexts can be modified during interpretation with Scheme code.
In a LilyPond code block, the syntax for this is:

\applyContext function

In Scheme code, the syntax is:

(make-apply-context function)

function should be a Scheme function that takes a
single argument: the context in which the \applyContext
command is being called. The function can access as well as
override/set grob properties and context properties. Any actions
taken by the function that depend on the state of the context are
limited to the state of the context when the function is
called. Also, changes effected by a call to \applyContext
remain in effect until they are directly modified again, or
reverted, even if the initial conditions that they depended on
have changed.

The following scheme functions are useful when using
\applyContext:

ly:context-property

look up a context property value

ly:context-set-property!

set a context property

ly:context-grob-definition

ly:assoc-get

look up a grob property value

ly:context-pushpop-property

do a \temporary \override
or a \revert on a grob property

The following example looks up the current fontSize value, and
then doubles it:

This also could be implemented as a music function, in order to
restrict the modifications to a single music block. Notice how
ly:context-pushpop-property is used both as a
\temporary \override and as a \revert: