| [ << Modifying properties ] | [Top][Contents][Index] | [ Useful concepts and properties >> ] | 
| [ < Overview of modifying properties ] | [ Up: Modifying properties ] | [ \overrideand\revert> ] | 
35.2 \set and \unset
The \set command syntax is
\set context.property = value
where value must be preceded by the ‘#’ character if it is a Scheme object.
The counterpart command \unset’s syntax is
\unset context.property
This removes a previously set definition of the property
from the context.  Any properties that have been set in an
enclosing context are not altered by an \unset in the
same enclosed context.
For example, multi-measure rests are combined into a single bar
(as explained in Compressing empty measures) if the context
property skipBars is set to #t:
R1*2 \set Score.skipBars = ##t R1*2![[image of music]](../af/lily-b9bf26a8.png)
If the context argument is left out, then the property is
set in the current ‘bottom’ context (typically
ChordNames, Voice, TabVoice, or
Lyrics).
<< \set Score.autoBeaming = ##f \relative { e''8 e e e \set autoBeaming = ##t e8 e e e } \\ \relative { c''8 c c c c8 c c c } >>![[image of music]](../09/lily-c2c78f88.png)
Note that the bottom context may not always contain an
engraver that uses the property that you wish to
change.  For example, attempting to set the skipBars
property of the default, bottom context has no effect because it
is a property of the Score, not Voice context.
R1*2 \set skipBars = ##t R1*2![[image of music]](../67/lily-7555b083.png)
Contexts are hierarchical; any change specified for an enclosing
context (e.g., Staff) would also apply to all Voices
in that current Staff context (assuming, of course, that
the Voice context didn’t have an override of its own).
All contexts inherit settings established in the top-most
Global context (via \grobdescriptions), although a
few of those defaults get overridden in their own context
definitions.
<< \set Score.autoBeaming = ##t \relative { \unset autoBeaming e''8 e e e \unset Score.autoBeaming e8 e e e } \\ \relative { c''8 c c c c8 c c c } >>![[image of music]](../48/lily-dbb5c5ca.png)
Like \set, the context argument does not have to be
specified for a bottom context, so the two statements
\set Voice.autoBeaming = ##t \set autoBeaming = ##t
are equivalent if the current bottom context is Voice.
As described above, \unset restores the default value of a
context property.  However, it is sometimes useful to change a
value for some time, then return to the previously used value.
For this purpose, there are the two commands
\pushContextProperty and \popContextProperty: the
first one pushes the current value to a stack, while the second
one pops a value from the stack and restores the property to it.
{ c' \pushContextProperty Staff.fontSize \set Staff.fontSize = 3 c' \pushContextProperty Staff.fontSize \set Staff.fontSize = 6 c' \popContextProperty Staff.fontSize c' \popContextProperty Staff.fontSize c' }![[image of music]](../1d/lily-f312dbf7.png)
| [Top][Contents][Index] |